mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03:00
Code refactoring (4) (es5 -> es2015)
This commit is contained in:
parent
e8df1cdb57
commit
d7ab67a460
30 changed files with 164 additions and 173 deletions
76
dev/Settings/User/OpenPgp.jsx
Normal file
76
dev/Settings/User/OpenPgp.jsx
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
window = require('window'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
PgpStore = require('Stores/User/Pgp');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function OpenPgpUserSettings()
|
||||
{
|
||||
this.openpgpkeys = PgpStore.openpgpkeys;
|
||||
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
|
||||
this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate;
|
||||
|
||||
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
||||
this.isHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
|
||||
}
|
||||
|
||||
OpenPgpUserSettings.prototype.addOpenPgpKey = function()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
|
||||
};
|
||||
|
||||
OpenPgpUserSettings.prototype.generateOpenPgpKey = function()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
|
||||
};
|
||||
|
||||
OpenPgpUserSettings.prototype.viewOpenPgpKey = function(oOpenPgpKey)
|
||||
{
|
||||
if (oOpenPgpKey)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
|
||||
*/
|
||||
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
|
||||
{
|
||||
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
|
||||
{
|
||||
this.openPgpKeyForDeletion(null);
|
||||
|
||||
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
|
||||
{
|
||||
var oFindedItem = _.find(PgpStore.openpgpkeys(), function(oOpenPgpKey) {
|
||||
return oOpenPgpKeyToRemove === oOpenPgpKey;
|
||||
});
|
||||
|
||||
if (oFindedItem)
|
||||
{
|
||||
PgpStore.openpgpkeys.remove(oFindedItem);
|
||||
Utils.delegateRunOnDestroy(oFindedItem);
|
||||
|
||||
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
|
||||
.removeForId(oFindedItem.guid);
|
||||
|
||||
PgpStore.openpgpKeyring.store();
|
||||
}
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export {OpenPgpUserSettings, OpenPgpUserSettings as default};
|
||||
Loading…
Add table
Add a link
Reference in a new issue