From 9a3b9b8a0db03ced9e7778437a015dd11556aed5 Mon Sep 17 00:00:00 2001 From: Anukriti Jagatramka Date: Fri, 18 Oct 2019 11:14:25 +0530 Subject: [PATCH 1/4] PREAPPS-3593: Folder count issue fixed for shared folder. --- src/schema/notifications.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/schema/notifications.ts b/src/schema/notifications.ts index 8dc5eef3b..b14aedf1f 100644 --- a/src/schema/notifications.ts +++ b/src/schema/notifications.ts @@ -145,6 +145,26 @@ export class ZimbraNotifications { this.getApolloClient().queryManager.broadcastQueries(); }; + // Find the actual folder of the shared folder + private findSharedItemId = (item: any) => { + let sharedFolderId: any; + const cachedData = get(this.cache, 'data.data'); + const allFolders = Object.keys(cachedData).filter(f => + f.includes('Folder:') + ); + const idSplit = item.id.split(':'); + for (let folderId in allFolders) { + if ( + cachedData[allFolders[folderId]].ownerZimbraId === idSplit[0] && + cachedData[allFolders[folderId]].sharedItemId === idSplit[1] + ) { + sharedFolderId = cachedData[allFolders[folderId]].id; + break; + } + } + return sharedFolderId; + }; + private handleContactNotifications = (notification: Notification) => { const items = itemsForKey(notification, 'cn'); this.batchProcessItems(items, this.processContactNotifications); @@ -302,8 +322,12 @@ export class ZimbraNotifications { if (items) { items.forEach((i: any) => { const item = normalizeFolder(i); + let itemId: any; + if (i.id.includes(':')) { + itemId = this.findSharedItemId(i); + } this.cache.writeFragment({ - id: `Folder:${item.id}`, + id: `Folder:${itemId}`, fragment: gql` fragment ${generateFragmentName('folderNotification', item.id)} on Folder { ${attributeKeys(item)} From a0d1cab006328c87034a3d10d8d9f543d292fb3f Mon Sep 17 00:00:00 2001 From: Anukriti Jagatramka Date: Fri, 18 Oct 2019 14:31:20 +0530 Subject: [PATCH 2/4] PREAPPS-3593: Testcases failure fixed. --- src/schema/notifications.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schema/notifications.ts b/src/schema/notifications.ts index b14aedf1f..1fc0cea0b 100644 --- a/src/schema/notifications.ts +++ b/src/schema/notifications.ts @@ -322,7 +322,7 @@ export class ZimbraNotifications { if (items) { items.forEach((i: any) => { const item = normalizeFolder(i); - let itemId: any; + let itemId = item.id; if (i.id.includes(':')) { itemId = this.findSharedItemId(i); } From a31ae9c3b7ffa3df5761f91ee124d86ff01c79b9 Mon Sep 17 00:00:00 2001 From: Anukriti Jagatramka Date: Wed, 23 Oct 2019 11:38:02 +0530 Subject: [PATCH 3/4] PREAPPS-3593: Code Improvements. --- src/schema/notifications.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/schema/notifications.ts b/src/schema/notifications.ts index 1fc0cea0b..cdf6d26c2 100644 --- a/src/schema/notifications.ts +++ b/src/schema/notifications.ts @@ -152,13 +152,15 @@ export class ZimbraNotifications { const allFolders = Object.keys(cachedData).filter(f => f.includes('Folder:') ); - const idSplit = item.id.split(':'); - for (let folderId in allFolders) { + 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 ( - cachedData[allFolders[folderId]].ownerZimbraId === idSplit[0] && - cachedData[allFolders[folderId]].sharedItemId === idSplit[1] + folder.ownerZimbraId === idSplit[0] && + folder.sharedItemId === idSplit[1] ) { - sharedFolderId = cachedData[allFolders[folderId]].id; + sharedFolderId = folder.id; break; } } @@ -322,10 +324,9 @@ export class ZimbraNotifications { if (items) { items.forEach((i: any) => { const item = normalizeFolder(i); - let itemId = item.id; - if (i.id.includes(':')) { - itemId = this.findSharedItemId(i); - } + const itemId = get(i, 'id', '').includes(':') + ? this.findSharedItemId(i.id) + : item.id; this.cache.writeFragment({ id: `Folder:${itemId}`, fragment: gql` From 73d5d98e94b519f171d70823efc7589dbb7a3234 Mon Sep 17 00:00:00 2001 From: Anukriti Jagatramka Date: Thu, 24 Oct 2019 13:22:45 +0530 Subject: [PATCH 4/4] PREAPPS-3593: Code Improvements. --- src/schema/notifications.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/schema/notifications.ts b/src/schema/notifications.ts index cdf6d26c2..79c04bbc7 100644 --- a/src/schema/notifications.ts +++ b/src/schema/notifications.ts @@ -147,7 +147,6 @@ export class ZimbraNotifications { // Find the actual folder of the shared folder private findSharedItemId = (item: any) => { - let sharedFolderId: any; const cachedData = get(this.cache, 'data.data'); const allFolders = Object.keys(cachedData).filter(f => f.includes('Folder:') @@ -160,11 +159,9 @@ export class ZimbraNotifications { folder.ownerZimbraId === idSplit[0] && folder.sharedItemId === idSplit[1] ) { - sharedFolderId = folder.id; - break; + return folder.id; } } - return sharedFolderId; }; private handleContactNotifications = (notification: Notification) => { @@ -324,8 +321,8 @@ export class ZimbraNotifications { if (items) { items.forEach((i: any) => { const item = normalizeFolder(i); - const itemId = get(i, 'id', '').includes(':') - ? this.findSharedItemId(i.id) + const itemId = item.id.includes(':') + ? this.findSharedItemId(item.id) : item.id; this.cache.writeFragment({ id: `Folder:${itemId}`,