04a370e043
This PR is a follow-up of https://github.com/twentyhq/twenty/pull/16966 and implements a new mechanism to handle SSE events. It creates only one event stream per browser tab, then use mutations to tell the backend which query to listen to, without re-mounting the event stream connexion. Then each event that comes from this unique subscription is then dispatched in a new JavaScript CustomEvent, per queryId, on which specific hooks add an event listener. This PR introduces the generic tooling as well as the handling of update events on table.
16 lines
385 B
TypeScript
16 lines
385 B
TypeScript
export const compareArraysOfObjectsByProperty = <T, K extends keyof T>(
|
|
arrayA: T[],
|
|
arrayB: T[],
|
|
property: K,
|
|
) => {
|
|
return (
|
|
arrayA.length !== arrayB.length ||
|
|
arrayA.some(
|
|
(item) => !arrayB.some((itemB) => itemB[property] === item[property]),
|
|
) ||
|
|
arrayB.some(
|
|
(item) => !arrayA.some((itemA) => itemA[property] === item[property]),
|
|
)
|
|
);
|
|
};
|