Commit b36568ad authored by Shashwat Jolly's avatar Shashwat Jolly

Update cache on adding collection

parent 34d38977
...@@ -211,7 +211,7 @@ void CalendarTaskBaseHandler::collectionAdded(const Akonadi::Collection &collect ...@@ -211,7 +211,7 @@ void CalendarTaskBaseHandler::collectionAdded(const Akonadi::Collection &collect
EteSyncJournalPtr journal = etesync_journal_new(journalUid, ETESYNC_CURRENT_VERSION); EteSyncJournalPtr journal = etesync_journal_new(journalUid, ETESYNC_CURRENT_VERSION);
/// TODO: Description? /// TODO: Description?
EteSyncCollectionInfoPtr info = etesync_collection_info_new(etesyncCollectionType(), collection.displayName(), QString(), EteSyncDEFAULT_COLOR); EteSyncCollectionInfoPtr info = etesync_collection_info_new(etesyncCollectionType(), collection.displayName(), QString(), ETESYNC_COLLECTION_DEFAULT_COLOR);
EteSyncCryptoManagerPtr cryptoManager = etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()); EteSyncCryptoManagerPtr cryptoManager = etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair());
...@@ -225,6 +225,7 @@ void CalendarTaskBaseHandler::collectionAdded(const Akonadi::Collection &collect ...@@ -225,6 +225,7 @@ void CalendarTaskBaseHandler::collectionAdded(const Akonadi::Collection &collect
Collection newCollection(collection); Collection newCollection(collection);
mResource->setupCollection(newCollection, journal.get()); mResource->setupCollection(newCollection, journal.get());
mResource->mJournalsCache[newCollection.remoteId()] = std::move(journal);
mResource->changeCommitted(newCollection); mResource->changeCommitted(newCollection);
} }
...@@ -233,7 +234,7 @@ void CalendarTaskBaseHandler::collectionChanged(const Akonadi::Collection &colle ...@@ -233,7 +234,7 @@ void CalendarTaskBaseHandler::collectionChanged(const Akonadi::Collection &colle
const QString journalUid = collection.remoteId(); const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid); const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
auto journalColor = EteSyncDEFAULT_COLOR; auto journalColor = ETESYNC_COLLECTION_DEFAULT_COLOR;
if (collection.hasAttribute<CollectionColorAttribute>()) { if (collection.hasAttribute<CollectionColorAttribute>()) {
const CollectionColorAttribute *colorAttr = collection.attribute<CollectionColorAttribute>(); const CollectionColorAttribute *colorAttr = collection.attribute<CollectionColorAttribute>();
if (colorAttr) { if (colorAttr) {
......
...@@ -210,7 +210,7 @@ void ContactHandler::collectionAdded(const Akonadi::Collection &collection, cons ...@@ -210,7 +210,7 @@ void ContactHandler::collectionAdded(const Akonadi::Collection &collection, cons
const QString journalUid = QStringFromCharPtr(CharPtr(etesync_gen_uid())); const QString journalUid = QStringFromCharPtr(CharPtr(etesync_gen_uid()));
EteSyncJournalPtr journal = etesync_journal_new(journalUid, ETESYNC_CURRENT_VERSION); EteSyncJournalPtr journal = etesync_journal_new(journalUid, ETESYNC_CURRENT_VERSION);
EteSyncCollectionInfoPtr info = etesync_collection_info_new(etesyncCollectionType(), collection.displayName(), QString(), EteSyncDEFAULT_COLOR); EteSyncCollectionInfoPtr info = etesync_collection_info_new(etesyncCollectionType(), collection.displayName(), QString(), ETESYNC_COLLECTION_DEFAULT_COLOR);
EteSyncCryptoManagerPtr cryptoManager = etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()); EteSyncCryptoManagerPtr cryptoManager = etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair());
...@@ -224,6 +224,7 @@ void ContactHandler::collectionAdded(const Akonadi::Collection &collection, cons ...@@ -224,6 +224,7 @@ void ContactHandler::collectionAdded(const Akonadi::Collection &collection, cons
Collection newCollection(collection); Collection newCollection(collection);
mResource->setupCollection(newCollection, journal.get()); mResource->setupCollection(newCollection, journal.get());
mResource->mJournalsCache[newCollection.remoteId()] = std::move(journal);
mResource->changeCommitted(newCollection); mResource->changeCommitted(newCollection);
} }
......
...@@ -160,8 +160,10 @@ void EteSyncResource::slotCollectionsRetrieved(KJob *job) ...@@ -160,8 +160,10 @@ void EteSyncResource::slotCollectionsRetrieved(KJob *job)
Collection collection; Collection collection;
collection.setParentCollection(rootCollection); collection.setParentCollection(rootCollection);
setupCollection(collection, *iter); setupCollection(collection, *iter);
mJournalsCache[collection.remoteId()] = EteSyncJournalPtr(*iter);
list.push_back(collection); list.push_back(collection);
} }
mJournalsCacheUpdateTime = QDateTime::currentDateTime();
free(journals); free(journals);
collectionsRetrieved(list); collectionsRetrieved(list);
collectionsRetrievalDone(); collectionsRetrievalDone();
...@@ -221,9 +223,6 @@ void EteSyncResource::setupCollection(Collection &collection, EteSyncJournal *jo ...@@ -221,9 +223,6 @@ void EteSyncResource::setupCollection(Collection &collection, EteSyncJournal *jo
collection.setRemoteId(journalUid); collection.setRemoteId(journalUid);
collection.setName(journalUid); collection.setName(journalUid);
collection.setContentMimeTypes(mimeTypes); collection.setContentMimeTypes(mimeTypes);
mJournalsCache[journalUid] = EteSyncJournalPtr(journal);
mJournalsCacheUpdateTime = QDateTime::currentDateTime();
} }
BaseHandler *EteSyncResource::fetchHandlerForMimeType(const QString &mimeType) BaseHandler *EteSyncResource::fetchHandlerForMimeType(const QString &mimeType)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment