mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-20 20:55:18 +02:00
All: Started resource fetcher service when a note has been decrypted
This commit is contained in:
parent
ab63316f83
commit
2b2ec2c655
ReactNativeClient
@ -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({
|
||||
|
@ -45,6 +45,7 @@ const defaultState = {
|
||||
state: 'idle',
|
||||
itemIndex: 0,
|
||||
itemCount: 0,
|
||||
decryptedItemCounts: {},
|
||||
},
|
||||
selectedNoteTags: [],
|
||||
resourceFetcher: {
|
||||
@ -415,6 +416,8 @@ function removeItemFromArray(array, property, value) {
|
||||
}
|
||||
|
||||
const reducer = (state = defaultState, action) => {
|
||||
// if (!['SIDE_MENU_OPEN_PERCENT'].includes(action.type)) console.info('Action', action.type);
|
||||
|
||||
let newState = state;
|
||||
|
||||
try {
|
||||
|
@ -137,6 +137,7 @@ class DecryptionWorker {
|
||||
this.state_ = 'started';
|
||||
|
||||
const excludedIds = [];
|
||||
const decryptedItemCounts = {};
|
||||
|
||||
this.dispatch({ type: 'ENCRYPTION_HAS_DISABLED_ITEMS', value: false });
|
||||
this.dispatchReport({ state: 'started' });
|
||||
@ -179,6 +180,10 @@ class DecryptionWorker {
|
||||
|
||||
await clearDecryptionCounter();
|
||||
|
||||
if (!decryptedItemCounts[decryptedItem.type_]) decryptedItemCounts[decryptedItem.type_] = 0;
|
||||
|
||||
decryptedItemCounts[decryptedItem.type_]++;
|
||||
|
||||
if (decryptedItem.type_ === Resource.modelType() && !!decryptedItem.encryption_blob_encrypted) {
|
||||
// itemsThatNeedDecryption() will return the resource again if the blob has not been decrypted,
|
||||
// but that will result in an infinite loop if the blob simply has not been downloaded yet.
|
||||
@ -240,7 +245,10 @@ class DecryptionWorker {
|
||||
|
||||
this.state_ = 'idle';
|
||||
|
||||
this.dispatchReport({ state: 'idle' });
|
||||
this.dispatchReport({
|
||||
state: 'idle',
|
||||
decryptedItemCounts: decryptedItemCounts,
|
||||
});
|
||||
|
||||
if (downloadedButEncryptedBlobCount) {
|
||||
this.logger().info(`DecryptionWorker: Some resources have been downloaded but are not decrypted yet. Scheduling another decryption. Resource count: ${downloadedButEncryptedBlobCount}`);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
// console.disableYellowBox = true
|
||||
|
||||
import { YellowBox, AppRegistry } from 'react-native';
|
||||
import { YellowBox, AppRegistry, NativeModules } from 'react-native';
|
||||
YellowBox.ignoreWarnings([
|
||||
'Require cycle: node_modules/react-native-',
|
||||
'Require cycle: node_modules/rn-fetch-blob',
|
||||
@ -18,6 +18,13 @@ YellowBox.ignoreWarnings([
|
||||
]);
|
||||
const { Root } = require('./root.js');
|
||||
|
||||
// Disable buggy Fast Refresh
|
||||
if (__DEV__) {
|
||||
const { DevSettings } = NativeModules;
|
||||
DevSettings.setHotLoadingEnabled(false);
|
||||
DevSettings.setLiveReloadEnabled(false);
|
||||
}
|
||||
|
||||
function main() {
|
||||
AppRegistry.registerComponent('Joplin', () => Root);
|
||||
console.ignoredYellowBox = ['Remote debugger'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user