diff --git a/src/actions.ts b/src/actions.ts index 2995c35c..7b9a5d78 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -99,6 +99,7 @@ export const RANDOMIZE_SALT = 'RANDOMIZE_SALT'; export const SELECT_CARDS = 'SELECT_CARDS'; export const UNSELECT_CARDS = 'UNSELECT_CARDS'; export const CLEAR_SELECTED_CARDS = 'CLEAR_SELECTED_CARDS'; +export const INCREMENT_COLLECTION_WORD_CLOUD_VERSION = 'INCREMENT_COLLECTION_WORD_CLOUD_VERSION'; //Comments export const COMMENTS_UPDATE_THREADS = 'COMMENTS_UPDATE_THREADS'; export const COMMENTS_UPDATE_MESSAGES = 'COMMENTS_UPDATE_MESSAGES'; @@ -432,6 +433,10 @@ type ActionClearSelectedCards = { type: typeof CLEAR_SELECTED_CARDS }; +type ActionIncrementCollectionWordCloudVersion = { + type: typeof INCREMENT_COLLECTION_WORD_CLOUD_VERSION +}; + type ActionCommentsUpdateThreads = { type: typeof COMMENTS_UPDATE_THREADS, threads: CommentThreads @@ -1045,6 +1050,7 @@ export type SomeAction = ActionAIRequestStarted | ActionSelectCards | ActionUnselectCards | ActionClearSelectedCards + | ActionIncrementCollectionWordCloudVersion | ActionCommentsUpdateThreads | ActionCommentsUpdateMessages | ActionUpdateCards diff --git a/src/actions/collection.ts b/src/actions/collection.ts index 5e63a79d..c7b787ce 100644 --- a/src/actions/collection.ts +++ b/src/actions/collection.ts @@ -74,6 +74,7 @@ import { import { CLEAR_SELECTED_CARDS, + INCREMENT_COLLECTION_WORD_CLOUD_VERSION, RANDOMIZE_SALT, SELECT_CARDS, SHOW_CARD, @@ -528,4 +529,10 @@ export const clearSelectedCards = () : SomeAction => { return { type: CLEAR_SELECTED_CARDS }; +}; + +export const incrementCollectionWordCloud = () : SomeAction => { + return { + type: INCREMENT_COLLECTION_WORD_CLOUD_VERSION + }; }; \ No newline at end of file diff --git a/src/filters.ts b/src/filters.ts index 4948449a..c9c42c10 100644 --- a/src/filters.ts +++ b/src/filters.ts @@ -2084,5 +2084,6 @@ export const INITIAL_STATE : CollectionState = { activeCardID: '', randomSalt: randomString(16), activeRenderOffset: 0, - selectedCards: {} + selectedCards: {}, + collectionWordCloudVersion: 0 }; \ No newline at end of file diff --git a/src/reducers/collection.ts b/src/reducers/collection.ts index 618fada0..9b660057 100644 --- a/src/reducers/collection.ts +++ b/src/reducers/collection.ts @@ -15,6 +15,7 @@ import { SELECT_CARDS, UNSELECT_CARDS, CLEAR_SELECTED_CARDS, + INCREMENT_COLLECTION_WORD_CLOUD_VERSION, } from '../actions.js'; import { @@ -132,6 +133,11 @@ const app = (state : CollectionState = INITIAL_STATE, action : SomeAction) : Col ...state, selectedCards: {} }; + case INCREMENT_COLLECTION_WORD_CLOUD_VERSION: + return { + ...state, + collectionWordCloudVersion: state.collectionWordCloudVersion + 1 + }; default: return state; } diff --git a/src/selectors.ts b/src/selectors.ts index aba4cc06..cff0cbc7 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -180,6 +180,7 @@ export const selectFetchedCard = (state : State) => state.app.fetchedCard; export const selectCardBeingFetched = (state : State) => state.app.cardBeingFetched; export const selectCardsDrawerInfoExpanded = (state : State) => state.app.cardsDrawerInfoExpanded; export const selectConfigureCollectionDialogOpen = (state : State) => state.app ? state.app.configureCollectionDialogOpen : false; +export const selectCollectionWordCloudVersion = (state : State) => state.collection ? state.collection.collectionWordCloudVersion : 0; export const selectSuggestMissingConceptsEnabled = (state : State) => state.app.suggestMissingConceptsEnabled; export const selectComposeOpen = (state : State) => state.prompt ? state.prompt.composeOpen : false; diff --git a/src/types.ts b/src/types.ts index e1d112e1..c5394d84 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1245,7 +1245,9 @@ export type CollectionState = { activeRenderOffset: number, //This is the set of cards that are currently selected. Selection state is //ephemeral and not persisted. - selectedCards: FilterMap + selectedCards: FilterMap, + //It's very expensive to update the collectionWordCloud, so we only update it when this is incremented. + collectionWordCloudVersion: number } export type CommentsState = {