@@ -8,8 +8,13 @@ import { AppDataVisibility } from '@graasp/sdk';
88
99import { List } from 'immutable' ;
1010
11- import { IdeaAppData } from '@/config/appDataTypes' ;
11+ import {
12+ AppDataTypes ,
13+ IdeaAppData ,
14+ RatingsAppData ,
15+ } from '@/config/appDataTypes' ;
1216import { REFRESH_INTERVAL_MS } from '@/config/constants' ;
17+ import { NoveltyRelevanceRatings } from '@/interfaces/ratings' ;
1318import { anonymizeIdeas } from '@/utils/ideas' ;
1419
1520import { useAppDataContext } from '../context/AppDataContext' ;
@@ -43,7 +48,18 @@ const Synchronizer: FC<SynchronizerProps> = ({ sync }) => {
4348 ) ;
4449
4550 const ideas = useMemo (
46- ( ) => appData . filter ( ( { type } ) => type === 'idea' ) as List < IdeaAppData > ,
51+ ( ) =>
52+ appData . filter (
53+ ( { type } ) => type === AppDataTypes . Idea ,
54+ ) as List < IdeaAppData > ,
55+ [ appData ] ,
56+ ) ;
57+
58+ const ratings = useMemo (
59+ ( ) =>
60+ appData . filter ( ( { type } ) => type === AppDataTypes . Ratings ) as List <
61+ RatingsAppData < NoveltyRelevanceRatings >
62+ > ,
4763 [ appData ] ,
4864 ) ;
4965
@@ -53,7 +69,7 @@ const Synchronizer: FC<SynchronizerProps> = ({ sync }) => {
5369 const newIdeasIds = ideas . map ( ( { id } ) => id ) . sort ( ) ;
5470 if ( ideas && ! ideasIds . equals ( newIdeasIds ) ) {
5571 setIdeasIds ( newIdeasIds ) ;
56- const anonymousIdeas = anonymizeIdeas ( ideas ) ;
72+ const anonymousIdeas = anonymizeIdeas ( ideas , ratings ) ;
5773 if ( setId ) {
5874 patchAppData ( {
5975 id : setId ,
@@ -72,7 +88,7 @@ const Synchronizer: FC<SynchronizerProps> = ({ sync }) => {
7288 }
7389 }
7490 }
75- } , [ ideas , ideasIds , patchAppData , postAppData , setId , sync ] ) ;
91+ } , [ ideas , ideasIds , patchAppData , postAppData , ratings , setId , sync ] ) ;
7692
7793 return (
7894 < Stack width = "100%" direction = "row" spacing = { 1 } >
0 commit comments