Skip to content

Commit 379c207

Browse files
committed
fix(plugins-sdk): compare generic content items by their id
Currently, the diff function is comparing all the object to decide when to add/remove new generic content items, this has problems when the same generic content (same id) is set by a plugin, causing it to be added and removed wrongly. This fixes it by comparing the items by their id to decide when to add/remove.
1 parent a49489c commit 379c207

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • bigbluebutton-html5/imports/ui/components/generic-content

bigbluebutton-html5/imports/ui/components/generic-content/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { difference } from 'ramda';
1+
import { differenceWith } from 'ramda';
22

3-
const getDifferenceBetweenLists = <T>(previousState: T[], currentState: T[]): T[][] => {
4-
const added = difference(currentState, previousState);
5-
const removed = difference(previousState, currentState);
3+
const cmp = (x: { id: string; }, y: { id: string; }) => x.id === y.id;
4+
5+
const getDifferenceBetweenLists = <T extends { id: string; }>(previousState: T[], currentState: T[]): T[][] => {
6+
const added = differenceWith(cmp, currentState, previousState);
7+
const removed = differenceWith(cmp, previousState, currentState);
68
return [added, removed];
79
};
810

0 commit comments

Comments
 (0)