Skip to content

Commit

Permalink
Merge pull request #278 from Zimbra/PREAPPS-3593
Browse files Browse the repository at this point in the history
PREAPPS-3593: Folder count issue fixed for shared folder.
  • Loading branch information
BhavinBathani authored Nov 5, 2019
2 parents ff549b2 + 73d5d98 commit 04ceb43
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/schema/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,25 @@ export class ZimbraNotifications {
this.getApolloClient().queryManager.broadcastQueries();
};

// Find the actual folder of the shared folder
private findSharedItemId = (item: any) => {
const cachedData = get(this.cache, 'data.data');
const allFolders = Object.keys(cachedData).filter(f =>
f.includes('Folder:')
);
const idSplit = item.split(':');
for (const folderId in allFolders) {
const folder: any = cachedData[allFolders[folderId]];
//Find the folder where ownerZimbraId:sharedItemId equals to id
if (
folder.ownerZimbraId === idSplit[0] &&
folder.sharedItemId === idSplit[1]
) {
return folder.id;
}
}
};

private handleContactNotifications = (notification: Notification) => {
const items = itemsForKey(notification, 'cn');
this.batchProcessItems(items, this.processContactNotifications);
Expand Down Expand Up @@ -302,8 +321,11 @@ export class ZimbraNotifications {
if (items) {
items.forEach((i: any) => {
const item = normalizeFolder(i);
const itemId = item.id.includes(':')
? this.findSharedItemId(item.id)
: item.id;
this.cache.writeFragment({
id: `Folder:${item.id}`,
id: `Folder:${itemId}`,
fragment: gql`
fragment ${generateFragmentName('folderNotification', item.id)} on Folder {
${attributeKeys(item)}
Expand Down

0 comments on commit 04ceb43

Please sign in to comment.