mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Display decryption progress in side bar
This commit is contained in:
parent
423d880b92
commit
f6ee5dd0e7
@ -218,12 +218,23 @@ class SideMenuContentComponent extends Component {
|
||||
}
|
||||
|
||||
let lines = Synchronizer.reportToLines(this.props.syncReport);
|
||||
while (lines.length < 10) lines.push(''); // Add blank lines so that height of report text is fixed and doesn't affect scrolling
|
||||
const syncReportText = lines.join("\n");
|
||||
|
||||
let decryptionReportText = '';
|
||||
if (this.props.decryptionWorker && this.props.decryptionWorker.state !== 'idle' && this.props.decryptionWorker.itemCount) {
|
||||
decryptionReportText = _('Decrypting items: %d/%d', this.props.decryptionWorker.itemIndex + 1, this.props.decryptionWorker.itemCount);
|
||||
}
|
||||
|
||||
let fullReport = [];
|
||||
if (syncReportText) fullReport.push(syncReportText);
|
||||
if (fullReport.length) fullReport.push('');
|
||||
if (decryptionReportText) fullReport.push(decryptionReportText);
|
||||
|
||||
while (fullReport.length < 12) fullReport.push(''); // Add blank lines so that height of report text is fixed and doesn't affect scrolling
|
||||
|
||||
items.push(this.synchronizeButton(this.props.syncStarted ? 'cancel' : 'sync'));
|
||||
|
||||
items.push(<Text key='sync_report' style={this.styles().syncStatus}>{syncReportText}</Text>);
|
||||
items.push(<Text key='sync_report' style={this.styles().syncStatus}>{fullReport.join('\n')}</Text>);
|
||||
|
||||
items.push(<View style={{ height: globalStyle.marginBottom }} key='bottom_padding_hack'/>);
|
||||
|
||||
@ -260,6 +271,7 @@ const SideMenuContent = connect(
|
||||
theme: state.settings.theme,
|
||||
opacity: state.sideMenuOpenPercent,
|
||||
collapsedFolderIds: state.collapsedFolderIds,
|
||||
decryptionWorker: state.decryptionWorker,
|
||||
};
|
||||
}
|
||||
)(SideMenuContentComponent)
|
||||
|
@ -31,6 +31,11 @@ const defaultState = {
|
||||
startState: 'idle',
|
||||
port: null,
|
||||
},
|
||||
decryptionWorker: {
|
||||
state: 'idle',
|
||||
itemIndex: 0,
|
||||
itemCount: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const stateUtils = {};
|
||||
@ -538,7 +543,18 @@ const reducer = (state = defaultState, action) => {
|
||||
if ('startState' in action) clipperServer.startState = action.startState;
|
||||
if ('port' in action) clipperServer.port = action.port;
|
||||
newState.clipperServer = clipperServer;
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'DECRYPTION_WORKER_SET':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
const decryptionWorker = Object.assign({}, newState.decryptionWorker);
|
||||
for (var n in action) {
|
||||
if (!action.hasOwnProperty(n) || n === 'type') continue;
|
||||
decryptionWorker[n] = action[n];
|
||||
}
|
||||
newState.decryptionWorker = decryptionWorker;
|
||||
break;
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -48,6 +48,12 @@ class DecryptionWorker {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
dispatchReport(report) {
|
||||
const action = Object.assign({}, report);
|
||||
action.type = 'DECRYPTION_WORKER_SET';
|
||||
this.dispatch(action);
|
||||
}
|
||||
|
||||
async start(options = null) {
|
||||
if (options === null) options = {};
|
||||
if (!('materKeyNotLoadedHandler' in options)) options.materKeyNotLoadedHandler = 'throw';
|
||||
@ -63,6 +69,8 @@ class DecryptionWorker {
|
||||
|
||||
let excludedIds = [];
|
||||
|
||||
this.dispatchReport({ state: 'started' });
|
||||
|
||||
try {
|
||||
const notLoadedMasterKeyDisptaches = [];
|
||||
|
||||
@ -73,13 +81,12 @@ class DecryptionWorker {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
|
||||
// Temp hack
|
||||
// if (['edf44b7a0e4f8cbf248e206cd8dfa800', '2ccb3c9af0b1adac2ec6b66a5961fbb1'].indexOf(item.id) >= 0) {
|
||||
// excludedIds.push(item.id);
|
||||
// continue;
|
||||
// }
|
||||
|
||||
const ItemClass = BaseItem.itemClass(item);
|
||||
|
||||
this.dispatchReport({
|
||||
itemIndex: i,
|
||||
itemCount: items.length,
|
||||
});
|
||||
|
||||
// Don't log in production as it results in many messages when importing many items
|
||||
// this.logger().info('DecryptionWorker: decrypting: ' + item.id + ' (' + ItemClass.tableName() + ')');
|
||||
@ -112,11 +119,14 @@ class DecryptionWorker {
|
||||
} catch (error) {
|
||||
this.logger().error('DecryptionWorker:', error);
|
||||
this.state_ = 'idle';
|
||||
this.dispatchReport({ state: 'idle' });
|
||||
throw error;
|
||||
}
|
||||
|
||||
this.logger().info('DecryptionWorker: completed decryption.');
|
||||
|
||||
this.dispatchReport({ state: 'idle' });
|
||||
|
||||
this.state_ = 'idle';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user