Directives fixes

This commit is contained in:
Kae 2023-11-25 23:03:46 +11:00
parent 9c7d35ee26
commit f3c7bd1d5e
2 changed files with 15 additions and 7 deletions

View File

@ -277,8 +277,14 @@ String DirectivesGroup::toString() const {
void DirectivesGroup::addToString(String& string) const { void DirectivesGroup::addToString(String& string) const {
for (auto& directives : m_directives) for (auto& directives : m_directives)
if (directives.shared) if (directives.shared) {
string += directives.shared->string; auto& dirString = directives.shared->string;
if (!dirString.empty()) {
if (dirString.utf8().front() != '?')
string += "?";
string += dirString;
}
}
} }
void DirectivesGroup::forEach(DirectivesCallback callback) const { void DirectivesGroup::forEach(DirectivesCallback callback) const {

View File

@ -60,14 +60,16 @@ Json ParallaxLayer::store() const {
void ParallaxLayer::addImageDirectives(Directives const& newDirectives) { void ParallaxLayer::addImageDirectives(Directives const& newDirectives) {
if (newDirectives) { // TODO: Move to Directives += if (newDirectives) { // TODO: Move to Directives +=
if (directives) { if (directives) {
String newString; String dirString = directives.string();
for (auto const& entry : newDirectives.shared->entries) { auto& newString = newDirectives.shared->string;
newString += "+"; if (!newString.empty()) {
newString += entry.string(*newDirectives.shared); if (newString.utf8().front() != '?')
dirString += "?";
dirString += newString;
} }
directives = move(newString); directives = move(dirString);
} }
else else
directives = newDirectives; directives = newDirectives;