1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Started resource fetcher service when a note has been decrypted

This commit is contained in:
Laurent Cozic
2020-04-19 10:11:46 +01:00
parent ab63316f83
commit 2b2ec2c655
4 changed files with 31 additions and 3 deletions

View File

@ -1,5 +1,6 @@
const Setting = require('lib/models/Setting');
const Tag = require('lib/models/Tag');
const BaseModel = require('lib/BaseModel');
const Note = require('lib/models/Note');
const { reg } = require('lib/registry.js');
const ResourceFetcher = require('lib/services/ResourceFetcher');
@ -18,8 +19,14 @@ const reduxSharedMiddleware = async function(store, next, action) {
reg.resetSyncTarget();
}
let mustAutoAddResources = false;
if (action.type === 'SETTING_UPDATE_ONE' && action.key === 'sync.resourceDownloadMode') {
ResourceFetcher.instance().autoAddResources();
mustAutoAddResources = true;
}
if (action.type === 'DECRYPTION_WORKER_SET' && action.state === 'idle' && action.decryptedItemCounts && !!action.decryptedItemCounts[BaseModel.TYPE_NOTE]) {
mustAutoAddResources = true;
}
// In general the DecryptionWorker is started via events, such as when an encrypted note
@ -70,6 +77,9 @@ const reduxSharedMiddleware = async function(store, next, action) {
});
}
if (mustAutoAddResources) {
ResourceFetcher.instance().autoAddResources();
}
if (refreshTags) {
store.dispatch({