mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-15 09:04:04 +02:00
9c98fb5312
* Adding node counts for folders and tags * Add unit tests * Fix count update when the tag list for a note is updated * Right align note counts and remove from the settings screen * Folder note count calculation update to include descendants * Update Setting.js * Change count style and fix click on counts * Fix tag/folder count update on delete/add note * Review updates
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
const Setting = require('lib/models/Setting');
|
|
const Tag = require('lib/models/Tag');
|
|
const { reg } = require('lib/registry.js');
|
|
const ResourceFetcher = require('lib/services/ResourceFetcher');
|
|
|
|
const reduxSharedMiddleware = async function(store, next, action) {
|
|
const newState = store.getState();
|
|
|
|
let refreshTags = false;
|
|
|
|
if (action.type == 'FOLDER_SET_COLLAPSED' || action.type == 'FOLDER_TOGGLE') {
|
|
Setting.setValue('collapsedFolderIds', newState.collapsedFolderIds);
|
|
}
|
|
|
|
if (action.type === 'SETTING_UPDATE_ONE' && !!action.key.match(/^sync\.\d+\.path$/)) {
|
|
reg.resetSyncTarget();
|
|
}
|
|
|
|
if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'sync.resourceDownloadMode') {
|
|
ResourceFetcher.instance().autoAddResources();
|
|
}
|
|
|
|
if (action.type == 'NOTE_DELETE' ||
|
|
action.type == 'NOTE_UPDATE_ONE' ||
|
|
action.type == 'NOTE_UPDATE_ALL' ||
|
|
action.type == 'NOTE_TAG_REMOVE' ||
|
|
action.type == 'TAG_UPDATE_ONE') {
|
|
refreshTags = true;
|
|
}
|
|
|
|
if (refreshTags) {
|
|
store.dispatch({
|
|
type: 'TAG_UPDATE_ALL',
|
|
items: await Tag.allWithNotes(),
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = reduxSharedMiddleware;
|