-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PREAPPS-3593: Folder count issue fixed for shared folder. #278
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,28 @@ 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.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] | ||
) { | ||
sharedFolderId = folder.id; | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of doing an assignment and a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
} | ||
return sharedFolderId; | ||
}; | ||
|
||
private handleContactNotifications = (notification: Notification) => { | ||
const items = itemsForKey(notification, 'cn'); | ||
this.batchProcessItems(items, this.processContactNotifications); | ||
|
@@ -302,8 +324,11 @@ export class ZimbraNotifications { | |
if (items) { | ||
items.forEach((i: any) => { | ||
const item = normalizeFolder(i); | ||
const itemId = get(i, 'id', '').includes(':') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can access There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
? this.findSharedItemId(i.id) | ||
: item.id; | ||
this.cache.writeFragment({ | ||
id: `Folder:${item.id}`, | ||
id: `Folder:${itemId}`, | ||
fragment: gql` | ||
fragment ${generateFragmentName('folderNotification', item.id)} on Folder { | ||
${attributeKeys(item)} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we destructure id here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tweaked logic to only send id to
findSharedItemId
, hence destructuring will not be required.