mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
All: Fixes #10189: After deleting the last note from the conflicts folder, the application state is invalid
This commit is contained in:
parent
10978781cd
commit
a5f118bc26
@ -452,7 +452,7 @@ class Application extends BaseApplication {
|
|||||||
Setting.dispatchUpdateAll();
|
Setting.dispatchUpdateAll();
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
await refreshFolders((action: any) => this.store().dispatch(action));
|
await refreshFolders((action: any) => this.store().dispatch(action), '');
|
||||||
|
|
||||||
const tags = await Tag.allWithNotes();
|
const tags = await Tag.allWithNotes();
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ class Application extends BaseApplication {
|
|||||||
Setting.dispatchUpdateAll();
|
Setting.dispatchUpdateAll();
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
await refreshFolders((action: any) => this.dispatch(action));
|
await refreshFolders((action: any) => this.dispatch(action), '');
|
||||||
|
|
||||||
const tags = await Tag.allWithNotes();
|
const tags = await Tag.allWithNotes();
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ const generalMiddleware = (store: any) => (next: any) => async (action: any) =>
|
|||||||
|
|
||||||
if (doRefreshFolders) {
|
if (doRefreshFolders) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
await scheduleRefreshFolders((action: any) => storeDispatch(action));
|
await scheduleRefreshFolders((action: any) => storeDispatch(action), newState.selectedFolderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -670,7 +670,7 @@ async function initialize(dispatch: Function) {
|
|||||||
reg.logger().info('Loading folders...');
|
reg.logger().info('Loading folders...');
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
await refreshFolders((action: any) => dispatch(action));
|
await refreshFolders((action: any) => dispatch(action), '');
|
||||||
|
|
||||||
const tags = await Tag.allWithNotes();
|
const tags = await Tag.allWithNotes();
|
||||||
|
|
||||||
@ -1053,7 +1053,7 @@ class AppComponent extends React.Component {
|
|||||||
public UNSAFE_componentWillReceiveProps(newProps: any) {
|
public UNSAFE_componentWillReceiveProps(newProps: any) {
|
||||||
if (newProps.syncStarted !== this.lastSyncStarted_) {
|
if (newProps.syncStarted !== this.lastSyncStarted_) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
if (!newProps.syncStarted) void refreshFolders((action: any) => this.props.dispatch(action));
|
if (!newProps.syncStarted) void refreshFolders((action: any) => this.props.dispatch(action), this.props.selectedFolderId);
|
||||||
this.lastSyncStarted_ = newProps.syncStarted;
|
this.lastSyncStarted_ = newProps.syncStarted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,10 +575,10 @@ export default class BaseApplication {
|
|||||||
if (doRefreshFolders) {
|
if (doRefreshFolders) {
|
||||||
if (doRefreshFolders === 'now') {
|
if (doRefreshFolders === 'now') {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
await refreshFolders((action: any) => this.dispatch(action));
|
await refreshFolders((action: any) => this.dispatch(action), newState.selectedFolderId);
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||||
await scheduleRefreshFolders((action: any) => this.dispatch(action));
|
await scheduleRefreshFolders((action: any) => this.dispatch(action), newState.selectedFolderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -36,7 +36,9 @@ export const allForDisplay = async (options: FolderLoadOptions = {}) => {
|
|||||||
return folders;
|
return folders;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const refreshFolders = async (dispatch: Dispatch) => {
|
// `selectedFolderId` should be the currently selected folder. Set it to an empty string if that
|
||||||
|
// information is not available in the current context.
|
||||||
|
export const refreshFolders = async (dispatch: Dispatch, selectedFolderId: string) => {
|
||||||
refreshCalls_.push(true);
|
refreshCalls_.push(true);
|
||||||
try {
|
try {
|
||||||
const folders = await allForDisplay({
|
const folders = await allForDisplay({
|
||||||
@ -48,16 +50,27 @@ export const refreshFolders = async (dispatch: Dispatch) => {
|
|||||||
type: 'FOLDER_UPDATE_ALL',
|
type: 'FOLDER_UPDATE_ALL',
|
||||||
items: folders,
|
items: folders,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If the currently selected folder no longer exist, select a default folder
|
||||||
|
if (selectedFolderId && !folders.find(f => f.id === selectedFolderId)) {
|
||||||
|
const defaultFolder = await Folder.defaultFolder();
|
||||||
|
if (defaultFolder) {
|
||||||
|
dispatch({
|
||||||
|
type: 'FOLDER_SELECT',
|
||||||
|
id: defaultFolder.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
refreshCalls_.pop();
|
refreshCalls_.pop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const scheduleRefreshFolders = async (dispatch: Dispatch) => {
|
export const scheduleRefreshFolders = async (dispatch: Dispatch, selectedFolderId: string) => {
|
||||||
if (scheduleRefreshFoldersIID_) shim.clearTimeout(scheduleRefreshFoldersIID_);
|
if (scheduleRefreshFoldersIID_) shim.clearTimeout(scheduleRefreshFoldersIID_);
|
||||||
scheduleRefreshFoldersIID_ = shim.setTimeout(() => {
|
scheduleRefreshFoldersIID_ = shim.setTimeout(() => {
|
||||||
scheduleRefreshFoldersIID_ = null;
|
scheduleRefreshFoldersIID_ = null;
|
||||||
void refreshFolders(dispatch);
|
void refreshFolders(dispatch, selectedFolderId);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user