You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-12 22:57:38 +02:00
@ -1,7 +1,7 @@
|
||||
const EncryptionService = require("lib/services/EncryptionService");
|
||||
const { _ } = require("lib/locale.js");
|
||||
const BaseItem = require("lib/models/BaseItem.js");
|
||||
const Setting = require("lib/models/Setting.js");
|
||||
const EncryptionService = require('lib/services/EncryptionService');
|
||||
const { _ } = require('lib/locale.js');
|
||||
const BaseItem = require('lib/models/BaseItem.js');
|
||||
const Setting = require('lib/models/Setting.js');
|
||||
|
||||
const shared = {};
|
||||
|
||||
@ -18,18 +18,15 @@ shared.constructor = function(comp) {
|
||||
comp.isMounted_ = false;
|
||||
|
||||
comp.refreshStatsIID_ = null;
|
||||
};
|
||||
}
|
||||
|
||||
shared.initState = function(comp, props) {
|
||||
comp.setState(
|
||||
{
|
||||
masterKeys: props.masterKeys,
|
||||
passwords: props.passwords ? props.passwords : {},
|
||||
},
|
||||
() => {
|
||||
comp.checkPasswords();
|
||||
}
|
||||
);
|
||||
comp.setState({
|
||||
masterKeys: props.masterKeys,
|
||||
passwords: props.passwords ? props.passwords : {},
|
||||
}, () => {
|
||||
comp.checkPasswords();
|
||||
});
|
||||
|
||||
comp.refreshStats();
|
||||
|
||||
@ -46,12 +43,12 @@ shared.initState = function(comp, props) {
|
||||
}
|
||||
comp.refreshStats();
|
||||
}, 3000);
|
||||
};
|
||||
}
|
||||
|
||||
shared.refreshStats = async function(comp) {
|
||||
const stats = await BaseItem.encryptedItemsStats();
|
||||
comp.setState({ stats: stats });
|
||||
};
|
||||
}
|
||||
|
||||
shared.checkPasswords = async function(comp) {
|
||||
const passwordChecks = Object.assign({}, comp.state.passwordChecks);
|
||||
@ -62,30 +59,30 @@ shared.checkPasswords = async function(comp) {
|
||||
passwordChecks[mk.id] = ok;
|
||||
}
|
||||
comp.setState({ passwordChecks: passwordChecks });
|
||||
};
|
||||
}
|
||||
|
||||
shared.decryptedStatText = function(comp) {
|
||||
const stats = comp.state.stats;
|
||||
const doneCount = stats.encrypted !== null ? stats.total - stats.encrypted : "-";
|
||||
const totalCount = stats.total !== null ? stats.total : "-";
|
||||
return _("Decrypted items: %s / %s", doneCount, totalCount);
|
||||
};
|
||||
const doneCount = stats.encrypted !== null ? (stats.total - stats.encrypted) : '-';
|
||||
const totalCount = stats.total !== null ? stats.total : '-';
|
||||
return _('Decrypted items: %s / %s', doneCount, totalCount);
|
||||
}
|
||||
|
||||
shared.onSavePasswordClick = function(comp, mk) {
|
||||
const password = comp.state.passwords[mk.id];
|
||||
if (!password) {
|
||||
Setting.deleteObjectKey("encryption.passwordCache", mk.id);
|
||||
Setting.deleteObjectKey('encryption.passwordCache', mk.id);
|
||||
} else {
|
||||
Setting.setObjectKey("encryption.passwordCache", mk.id, password);
|
||||
Setting.setObjectKey('encryption.passwordCache', mk.id, password);
|
||||
}
|
||||
|
||||
comp.checkPasswords();
|
||||
};
|
||||
}
|
||||
|
||||
shared.onPasswordChange = function(comp, mk, password) {
|
||||
const passwords = comp.state.passwords;
|
||||
passwords[mk.id] = password;
|
||||
comp.setState({ passwords: passwords });
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = shared;
|
||||
module.exports = shared;
|
Reference in New Issue
Block a user