Skip to content

Commit

Permalink
Use SETTING_UPDATE_* instead of new INITIAL_SELECTION_SET event
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator committed May 23, 2024
1 parent a7efc80 commit ad1c336
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 0 additions & 4 deletions packages/app-desktop/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,6 @@ class Application extends BaseApplication {
});
}

this.store().dispatch({
type: 'INITIAL_SELECTION_SET',
});

this.store().dispatch({
type: 'FOLDER_SET_COLLAPSED_ALL',
ids: Setting.value('collapsedFolderIds'),
Expand Down
4 changes: 0 additions & 4 deletions packages/app-mobile/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,6 @@ async function initialize(dispatch: Function) {
});
}

dispatch({
type: 'INITIAL_SELECTION_SET',
});

await clearSharedFilesCache();
} catch (error) {
alert(`Initialization error: ${error.message}`);
Expand Down
12 changes: 6 additions & 6 deletions packages/lib/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,6 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
break;
}

case 'INITIAL_SELECTION_SET':
// To allow creating notes when opening the app with all notes and/or tags,
// we also need a "last selected folder ID".
draft.selectedFolderId ??= draft.settings.activeFolderId;
break;

case 'SMART_FILTER_SELECT':
draft.notesParentType = 'SmartFilter';
draft.selectedSmartFilterId = action.id;
Expand Down Expand Up @@ -1341,6 +1335,12 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
handleHistory(draft, action);
}

if (action.type === 'SETTING_UPDATE_ALL' || (action.type === 'SETTING_UPDATE_ONE' && action.key === 'activeFolderId')) {
// To allow creating notes when opening the app with all notes and/or tags,
// a "last selected folder ID" needs to be set.
draft.selectedFolderId ??= draft.settings.activeFolderId;
}

for (const additionalReducer of additionalReducers) {
additionalReducer.reducer(draft, action);
}
Expand Down

0 comments on commit ad1c336

Please sign in to comment.