1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Apply tag duplication fix to mobile too

This commit is contained in:
Laurent Cozic 2019-02-24 18:02:50 +00:00
parent 081e1c5b62
commit 998011ff43
3 changed files with 28 additions and 15 deletions

View File

@ -299,10 +299,10 @@ class BaseApplication {
const result = next(action);
const newState = store.getState();
let refreshNotes = false;
let refreshTags = false;
// let refreshTags = false;
let refreshNotesUseSelectedNoteId = false;
reduxSharedMiddleware(store, next, action);
await reduxSharedMiddleware(store, next, action);
if (this.hasGui() && ["NOTE_UPDATE_ONE", "NOTE_DELETE", "FOLDER_UPDATE_ONE", "FOLDER_DELETE"].indexOf(action.type) >= 0) {
if (!await reg.syncTarget().syncStarted()) reg.scheduleSync(30 * 1000, { syncSteps: ["update_remote", "delete_remote"] });
@ -337,20 +337,20 @@ class BaseApplication {
refreshNotes = true;
}
if (action.type == 'NOTE_DELETE') {
refreshTags = true;
}
// if (action.type == 'NOTE_DELETE') {
// refreshTags = true;
// }
if (refreshNotes) {
await this.refreshNotes(newState, refreshNotesUseSelectedNoteId);
}
if (refreshTags) {
this.dispatch({
type: 'TAG_UPDATE_ALL',
items: await Tag.allWithNotes(),
});
}
// if (refreshTags) {
// this.dispatch({
// type: 'TAG_UPDATE_ALL',
// items: await Tag.allWithNotes(),
// });
// }
if ((action.type == 'SETTING_UPDATE_ONE' && (action.key == 'dateFormat' || action.key == 'timeFormat')) || (action.type == 'SETTING_UPDATE_ALL')) {
time.setDateFormat(Setting.value('dateFormat'));

View File

@ -1,9 +1,12 @@
const Setting = require('lib/models/Setting');
const Tag = require('lib/models/Tag');
const { reg } = require('lib/registry.js');
const reduxSharedMiddleware = function(store, next, action) {
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);
}
@ -11,7 +14,17 @@ const reduxSharedMiddleware = function(store, next, action) {
if (action.type === 'SETTING_UPDATE_ONE' && !!action.key.match(/^sync\.\d+\.path$/)) {
reg.resetSyncTarget();
}
if (action.type == 'NOTE_DELETE') {
refreshTags = true;
}
if (refreshTags) {
store.dispatch({
type: 'TAG_UPDATE_ALL',
items: await Tag.allWithNotes(),
});
}
}
module.exports = reduxSharedMiddleware;

View File

@ -92,7 +92,7 @@ const generalMiddleware = store => next => async (action) => {
const result = next(action);
const newState = store.getState();
reduxSharedMiddleware(store, next, action);
await reduxSharedMiddleware(store, next, action);
if (action.type == "NAV_GO") Keyboard.dismiss();
@ -453,7 +453,7 @@ async function initialize(dispatch) {
await FoldersScreenUtils.refreshFolders();
const tags = await Tag.all();
const tags = await Tag.allWithNotes();
dispatch({
type: 'TAG_UPDATE_ALL',