Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[buteo-sync-plugins-social] Don't override user-selected calendar col…
…ors. JB#53286
  • Loading branch information
blammit committed Mar 2, 2021
1 parent 665a079 commit 8daa08d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -53,6 +53,7 @@ const int GOOGLE_CAL_SYNC_PLUGIN_VERSION = 3;
const QByteArray NOTEBOOK_SERVER_SYNC_TOKEN_PROPERTY = QByteArrayLiteral("syncToken");
const QByteArray NOTEBOOK_SERVER_ID_PROPERTY = QByteArrayLiteral("calendarServerId");
const QByteArray NOTEBOOK_EMAIL_PROPERTY = QByteArrayLiteral("userPrincipalEmail");
const QByteArray SERVER_COLOR_PROPERTY = QByteArrayLiteral("serverColor");
const int COLLISION_ERROR_MAX_CONSECUTIVE = 8;
const QByteArray VOLATILE_APP = QByteArrayLiteral("VOLATILE");
const QByteArray VOLATILE_NAME = QByteArrayLiteral("SYNC-FAILURE");
Expand Down Expand Up @@ -2461,7 +2462,6 @@ void GoogleCalendarSyncAdaptor::setCalendarProperties(
{
notebook->setIsReadOnly(false);
notebook->setName(calendarInfo.summary);
notebook->setColor(calendarInfo.color);
notebook->setDescription(calendarInfo.description);
notebook->setPluginName(QStringLiteral("google"));
notebook->setSyncProfile(syncProfile);
Expand All @@ -2470,6 +2470,17 @@ void GoogleCalendarSyncAdaptor::setCalendarProperties(
// extra calendars have their own email addresses. using this property to pass it forward.
notebook->setSharedWith(QStringList() << serverCalendarId);
notebook->setAccount(QString::number(accountId));

if (!calendarInfo.color.isEmpty()
&& notebook->customProperty(SERVER_COLOR_PROPERTY) != calendarInfo.color) {
if (!notebook->customProperty(SERVER_COLOR_PROPERTY).isEmpty()) {
// Override user-selected notebook color only on each server change
// and not if there was no server color saved.
notebook->setColor(calendarInfo.color);
}
notebook->setCustomProperty(SERVER_COLOR_PROPERTY, calendarInfo.color);
}

}

void GoogleCalendarSyncAdaptor::applyRemoteChangesLocally()
Expand Down

0 comments on commit 8daa08d

Please sign in to comment.