IO-3000 Adjusted first approach at messaging WS changes.
This commit is contained in:
@@ -1,70 +1,70 @@
|
||||
export default async function FcmHandler({ client, payload }) {
|
||||
console.log("FCM", payload);
|
||||
switch (payload.type) {
|
||||
case "messaging-inbound":
|
||||
client.cache.modify({
|
||||
id: client.cache.identify({
|
||||
__typename: "conversations",
|
||||
id: payload.conversationid
|
||||
}),
|
||||
fields: {
|
||||
messages_aggregate(cached) {
|
||||
return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
}
|
||||
}
|
||||
});
|
||||
client.cache.modify({
|
||||
fields: {
|
||||
messages_aggregate(cached) {
|
||||
return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "messaging-outbound":
|
||||
client.cache.modify({
|
||||
id: client.cache.identify({
|
||||
__typename: "conversations",
|
||||
id: payload.conversationid
|
||||
}),
|
||||
fields: {
|
||||
updated_at(oldupdated0) {
|
||||
return new Date();
|
||||
}
|
||||
// messages_aggregate(cached) {
|
||||
// return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
// },
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "messaging-mark-conversation-read":
|
||||
let previousUnreadCount = 0;
|
||||
client.cache.modify({
|
||||
id: client.cache.identify({
|
||||
__typename: "conversations",
|
||||
id: payload.conversationid
|
||||
}),
|
||||
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.");
|
||||
break;
|
||||
}
|
||||
// switch (payload.type) {
|
||||
// case "messaging-inbound":
|
||||
// client.cache.modify({
|
||||
// id: client.cache.identify({
|
||||
// __typename: "conversations",
|
||||
// id: payload.conversationid
|
||||
// }),
|
||||
// fields: {
|
||||
// messages_aggregate(cached) {
|
||||
// return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// client.cache.modify({
|
||||
// fields: {
|
||||
// messages_aggregate(cached) {
|
||||
// return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// break;
|
||||
// case "messaging-outbound":
|
||||
// client.cache.modify({
|
||||
// id: client.cache.identify({
|
||||
// __typename: "conversations",
|
||||
// id: payload.conversationid
|
||||
// }),
|
||||
// fields: {
|
||||
// updated_at(oldupdated0) {
|
||||
// return new Date();
|
||||
// }
|
||||
// // messages_aggregate(cached) {
|
||||
// // return { aggregate: { count: cached.aggregate.count + 1 } };
|
||||
// // },
|
||||
// }
|
||||
// });
|
||||
// break;
|
||||
// case "messaging-mark-conversation-read":
|
||||
// let previousUnreadCount = 0;
|
||||
// client.cache.modify({
|
||||
// id: client.cache.identify({
|
||||
// __typename: "conversations",
|
||||
// id: payload.conversationid
|
||||
// }),
|
||||
// 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.");
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user