mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Code refactoring
This commit is contained in:
parent
345e7c58af
commit
8cf8b94d39
103 changed files with 664 additions and 659 deletions
92
dev/Settings/User/OpenPgp.js
Normal file
92
dev/Settings/User/OpenPgp.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
Data = require('Storage/User/Data')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function OpenPgpUserSetting()
|
||||
{
|
||||
this.openpgpkeys = Data.openpgpkeys;
|
||||
this.openpgpkeysPublic = Data.openpgpkeysPublic;
|
||||
this.openpgpkeysPrivate = Data.openpgpkeysPrivate;
|
||||
|
||||
this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
|
||||
function (oPrev) {
|
||||
if (oPrev)
|
||||
{
|
||||
oPrev.deleteAccess(false);
|
||||
}
|
||||
}, function (oNext) {
|
||||
if (oNext)
|
||||
{
|
||||
oNext.deleteAccess(true);
|
||||
}
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
OpenPgpUserSetting.prototype.addOpenPgpKey = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
|
||||
};
|
||||
|
||||
OpenPgpUserSetting.prototype.generateOpenPgpKey = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
|
||||
};
|
||||
|
||||
OpenPgpUserSetting.prototype.viewOpenPgpKey = function (oOpenPgpKey)
|
||||
{
|
||||
if (oOpenPgpKey)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
|
||||
*/
|
||||
OpenPgpUserSetting.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
|
||||
{
|
||||
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
|
||||
{
|
||||
this.openPgpKeyForDeletion(null);
|
||||
|
||||
if (oOpenPgpKeyToRemove && Data.openpgpKeyring)
|
||||
{
|
||||
var oFindedItem = _.find(this.openpgpkeys(), function (oOpenPgpKey) {
|
||||
return oOpenPgpKeyToRemove === oOpenPgpKey;
|
||||
});
|
||||
|
||||
if (oFindedItem)
|
||||
{
|
||||
this.openpgpkeys.remove(oFindedItem);
|
||||
Utils.delegateRunOnDestroy(oFindedItem);
|
||||
|
||||
Data.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
|
||||
.removeForId(oFindedItem.guid);
|
||||
|
||||
Data.openpgpKeyring.store();
|
||||
}
|
||||
|
||||
require('App/User').reloadOpenPgpKeys();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = OpenPgpUserSetting;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue