diff --git a/app/db/src/app/services/app-state-actions.ts b/app/db/src/app/services/app-state-actions.ts index 4a7bc4d3..4b35274f 100644 --- a/app/db/src/app/services/app-state-actions.ts +++ b/app/db/src/app/services/app-state-actions.ts @@ -7,48 +7,48 @@ import { CardItem } from '../models/card-state'; import { Overlap } from '../common/bible-reference'; export class AppActionFactory { - static newGetSavedPage(pageId: string) { + static newGetSavedPage(pageId: string): AppAction { return { type: 'GET_SAVED_PAGE', pageId, } as AppAction; } - static newSavePage(title: string) { + static newSavePage(title: string): AppAction { return { type: 'SAVE_PAGE', title, } as AppAction; } - static newUpdateCurrentPage() { + static newUpdateCurrentPage(): AppAction { return { type: 'UPDATE_CURRENT_PAGE', } as AppAction; } - static newUpdateSavedPages(savedPages: IStorable) { + static newUpdateSavedPages(savedPages: IStorable): AppAction { return { type: 'UPDATE_SAVED_PAGES', savedPages, } as AppAction; } - static newUpdateSavedPage(savedPage: SavedPage) { + static newUpdateSavedPage(savedPage: SavedPage): AppAction { return { type: 'UPDATE_SAVED_PAGE', savedPage, } as AppAction; } - static newRemoveSavedPage(savedPage: SavedPage) { + static newRemoveSavedPage(savedPage: SavedPage): AppAction { return { type: 'REMOVE_SAVED_PAGE', savedPage, } as AppAction; } - static newAddCardToSavedPage(card: CardItem, pageId: string) { + static newAddCardToSavedPage(card: CardItem, pageId: string): AppAction { return { type: 'ADD_CARD_TO_SAVED_PAGE', card, @@ -56,7 +56,7 @@ export class AppActionFactory { } as AppAction; } - static newAddCard(card: CardItem, nextToItem: CardItem) { + static newAddCard(card: CardItem, nextToItem: CardItem): AppAction { return { type: 'ADD_CARD', card, @@ -64,7 +64,7 @@ export class AppActionFactory { } as AppAction; } - static newUpdateCard(newCard: CardItem, oldCard: CardItem) { + static newUpdateCard(newCard: CardItem, oldCard: CardItem): AppAction { return { type: 'UPDATE_CARD', newCard, @@ -72,14 +72,14 @@ export class AppActionFactory { } as AppAction; } - static newRemoveCard(card: CardItem) { + static newRemoveCard(card: CardItem): AppAction { return { type: 'REMOVE_CARD', card, } as AppAction; } - static newMoveCard(card: CardItem, direction: MoveDirection) { + static newMoveCard(card: CardItem, direction: MoveDirection): AppAction { return { type: 'MOVE_CARD', card, @@ -87,48 +87,55 @@ export class AppActionFactory { } as AppAction; } - static newUpdateError(error: Error) { + static newUpdateError(error: Error): AppAction { return { type: 'UPDATE_ERROR', error, } as AppAction; } - static newUpdateCardFontSize(cardFontSize: number) { + static newUpdateCardMergeStrategy(strategy: Overlap): AppAction { + return { + type: 'UPDATE_CARD_MERGE_STRATEGY', + cardMergeStrategy: strategy, + }; + } + + static newUpdateCardFontSize(cardFontSize: number): AppAction { return { type: 'UPDATE_CARD_FONT_SIZE', cardFontSize, } as AppAction; } - static newUpdateCardFontFamily(cardFontFamily: string) { + static newUpdateCardFontFamily(cardFontFamily: string): AppAction { return { type: 'UPDATE_CARD_FONT_FAMILY', cardFontFamily, } as AppAction; } - static newUpdateAutocomplete(words: string[]) { + static newUpdateAutocomplete(words: string[]): AppAction { return { type: 'UPDATE_AUTOCOMPLETE', words, } as AppAction; } - static newUpdateDisplaySettings(settings: IStorable) { + static newUpdateDisplaySettings(settings: IStorable): AppAction { return { type: 'UPDATE_DISPLAY_SETTINGS', settings, } as AppAction; } - static newUser(user: User) { + static newUser(user: User): AppAction { return { type: 'SET_USER', user, } as AppAction; } - static newFindNotes(qry: string, nextToItem: CardItem) { + static newFindNotes(qry: string, nextToItem: CardItem): AppAction { return { type: 'FIND_NOTES', qry, @@ -136,7 +143,7 @@ export class AppActionFactory { } as AppAction; } - static newGetNote(noteId: string, nextToItem: CardItem) { + static newGetNote(noteId: string, nextToItem: CardItem): AppAction { return { type: 'GET_NOTE', noteId, @@ -144,21 +151,21 @@ export class AppActionFactory { } as AppAction; } - static newUpdateNotes(notes: IStorable) { + static newUpdateNotes(notes: IStorable): AppAction { return { type: 'UPDATE_NOTES', notes, } as AppAction; } - static newSaveNote(note: NoteItem) { + static newSaveNote(note: NoteItem): AppAction { return { type: 'SAVE_NOTE', note, } as AppAction; } - static newDeleteNote(note: NoteItem) { + static newDeleteNote(note: NoteItem): AppAction { return { type: 'DELETE_NOTE', note, diff --git a/app/db/src/app/services/app-state-reducer.spec.ts b/app/db/src/app/services/app-state-reducer.spec.ts index 2eee5178..8e836271 100644 --- a/app/db/src/app/services/app-state-reducer.spec.ts +++ b/app/db/src/app/services/app-state-reducer.spec.ts @@ -59,6 +59,14 @@ describe('AppService Reducer', () => { TestBed.configureTestingModule({}); }); + it('UPDATE_CARD_MERGE_STRATEGY', () => { + for (const strategy of [Overlap.None, Overlap.Equal, Overlap.Subset, Overlap.Intersect]) { + const action = AppActionFactory.newUpdateCardMergeStrategy(strategy); + const testState = reducer(preState, action); + expect(testState.pageSettings.value.mergeStrategy).toEqual(strategy); + } + }); + it('UPDATE_CARD_FONT_SIZE', () => { const action = AppActionFactory.newUpdateCardFontSize(32); const testState = reducer(preState, action);