IO-2426 Add FCM Cache update for conversation aggregate count.
This commit is contained in:
@@ -12,6 +12,13 @@ export default async function FcmHandler({ client, payload }) {
|
||||
},
|
||||
},
|
||||
});
|
||||
client.cache.modify({
|
||||
fields: {
|
||||
messages_aggregate(cached) {
|
||||
return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
},
|
||||
},
|
||||
});
|
||||
break;
|
||||
case "messaging-outbound":
|
||||
client.cache.modify({
|
||||
@@ -30,6 +37,7 @@ export default async function FcmHandler({ client, payload }) {
|
||||
});
|
||||
break;
|
||||
case "messaging-mark-conversation-read":
|
||||
let previousUnreadCount = 0;
|
||||
client.cache.modify({
|
||||
id: client.cache.identify({
|
||||
__typename: "conversations",
|
||||
@@ -37,10 +45,22 @@ export default async function FcmHandler({ client, payload }) {
|
||||
}),
|
||||
fields: {
|
||||
messages_aggregate(cached) {
|
||||
previousUnreadCount = cached.aggregate.count;
|
||||
return { aggregate: { count: 0 } };
|
||||
},
|
||||
},
|
||||
});
|
||||
client.cache.modify({
|
||||
fields: {
|
||||
messages_aggregate(cached) {
|
||||
return {
|
||||
aggregate: {
|
||||
count: cached.aggregate.count - previousUnreadCount,
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.log("No payload type set.");
|
||||
|
||||
Reference in New Issue
Block a user