mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 15:07:02 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {$html, bMobileDevice} from 'Common/Globals';
|
||||
import { $html, bMobileDevice } from 'Common/Globals';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class AbstractAppStore
|
||||
{
|
||||
class AbstractAppStore {
|
||||
constructor() {
|
||||
this.allowLanguagesOnSettings = ko.observable(true);
|
||||
this.allowLanguagesOnLogin = ko.observable(true);
|
||||
|
|
@ -35,4 +33,4 @@ class AbstractAppStore
|
|||
}
|
||||
}
|
||||
|
||||
export {AbstractAppStore, AbstractAppStore as default};
|
||||
export { AbstractAppStore, AbstractAppStore as default };
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
import window from 'window';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import {settingsGet} from 'Storage/Settings';
|
||||
import {AbstractAppStore} from 'Stores/AbstractApp';
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
import { AbstractAppStore } from 'Stores/AbstractApp';
|
||||
|
||||
class AppAdminStore extends AbstractAppStore
|
||||
{
|
||||
class AppAdminStore extends AbstractAppStore {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {Capa} from 'Common/Enums';
|
||||
import { Capa } from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class CapaAdminStore
|
||||
{
|
||||
class CapaAdminStore {
|
||||
constructor() {
|
||||
this.additionalAccounts = ko.observable(false);
|
||||
this.identities = ko.observable(false);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
class CoreAdminStore
|
||||
{
|
||||
class CoreAdminStore {
|
||||
constructor() {
|
||||
this.coreReal = ko.observable(true);
|
||||
this.coreChannel = ko.observable('stable');
|
||||
|
|
@ -10,8 +8,8 @@ class CoreAdminStore
|
|||
this.coreUpdatable = ko.observable(true);
|
||||
this.coreAccess = ko.observable(true);
|
||||
this.coreWarning = ko.observable(false);
|
||||
this.coreChecking = ko.observable(false).extend({throttle: 100});
|
||||
this.coreUpdating = ko.observable(false).extend({throttle: 100});
|
||||
this.coreChecking = ko.observable(false).extend({ throttle: 100 });
|
||||
this.coreUpdating = ko.observable(false).extend({ throttle: 100 });
|
||||
this.coreVersion = ko.observable('');
|
||||
this.coreRemoteVersion = ko.observable('');
|
||||
this.coreRemoteRelease = ko.observable('');
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
class DomainAdminStore
|
||||
{
|
||||
class DomainAdminStore {
|
||||
constructor() {
|
||||
this.domains = ko.observableArray([]);
|
||||
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.domains.loading = ko.observable(false).extend({ 'throttle': 100 });
|
||||
this.domainsWithoutAliases = this.domains.filter((item) => item && !item.alias);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
class LicenseAdminStore
|
||||
{
|
||||
class LicenseAdminStore {
|
||||
constructor() {
|
||||
this.licensing = ko.observable(false);
|
||||
this.licensingProcess = ko.observable(false);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
class PackageAdminStore
|
||||
{
|
||||
class PackageAdminStore {
|
||||
constructor() {
|
||||
this.packages = ko.observableArray([]);
|
||||
this.packages.loading = ko.observable(false).extend({throttle: 100});
|
||||
this.packages.loading = ko.observable(false).extend({ throttle: 100 });
|
||||
|
||||
this.packagesReal = ko.observable(true);
|
||||
this.packagesMainUpdatable = ko.observable(true);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
class PluginAdminStore
|
||||
{
|
||||
class PluginAdminStore {
|
||||
constructor() {
|
||||
this.plugins = ko.observableArray([]);
|
||||
this.plugins.loading = ko.observable(false).extend({throttle: 100});
|
||||
this.plugins.loading = ko.observable(false).extend({ throttle: 100 });
|
||||
this.plugins.error = ko.observable('');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,28 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {isArray} from 'Common/Utils';
|
||||
import { isArray } from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class LanguageStore
|
||||
{
|
||||
class LanguageStore {
|
||||
constructor() {
|
||||
this.languages = ko.observableArray([]);
|
||||
this.languagesAdmin = ko.observableArray([]);
|
||||
|
||||
this.language = ko.observable('')
|
||||
.extend({limitedList: this.languages})
|
||||
.extend({reversible: true});
|
||||
this.language = ko
|
||||
.observable('')
|
||||
.extend({ limitedList: this.languages })
|
||||
.extend({ reversible: true });
|
||||
|
||||
this.languageAdmin = ko.observable('')
|
||||
.extend({limitedList: this.languagesAdmin})
|
||||
.extend({reversible: true});
|
||||
this.languageAdmin = ko
|
||||
.observable('')
|
||||
.extend({ limitedList: this.languagesAdmin })
|
||||
.extend({ reversible: true });
|
||||
|
||||
this.userLanguage = ko.observable('');
|
||||
this.userLanguageAdmin = ko.observable('');
|
||||
}
|
||||
|
||||
populate() {
|
||||
const
|
||||
aLanguages = Settings.appSettingsGet('languages'),
|
||||
const aLanguages = Settings.appSettingsGet('languages'),
|
||||
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
|
||||
|
||||
this.languages(isArray(aLanguages) ? aLanguages : []);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
import $ from '$';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class SocialStore
|
||||
{
|
||||
class SocialStore {
|
||||
constructor() {
|
||||
this.google = {};
|
||||
this.twitter = {};
|
||||
|
|
@ -32,7 +30,8 @@ class SocialStore
|
|||
|
||||
this.google.require = {};
|
||||
this.google.require.clientSettings = ko.computed(
|
||||
() => this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive()));
|
||||
() => this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive())
|
||||
);
|
||||
|
||||
this.google.require.apiKeySettings = ko.computed(() => this.google.enabled() && this.google.capa.drive());
|
||||
|
||||
|
|
@ -85,14 +84,14 @@ class SocialStore
|
|||
}
|
||||
|
||||
appendDropbox() {
|
||||
if (!window.Dropbox && this.dropbox.enabled() && this.dropbox.apiKey())
|
||||
{
|
||||
if (!window.document.getElementById('dropboxjs'))
|
||||
{
|
||||
if (!window.Dropbox && this.dropbox.enabled() && this.dropbox.apiKey()) {
|
||||
if (!window.document.getElementById('dropboxjs')) {
|
||||
const script = window.document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = 'https://www.dropbox.com/static/api/2/dropins.js';
|
||||
$(script).attr('id', 'dropboxjs').attr('data-app-key', this.dropbox.apiKey());
|
||||
$(script)
|
||||
.attr('id', 'dropboxjs')
|
||||
.attr('data-app-key', this.dropbox.apiKey());
|
||||
|
||||
window.document.body.appendChild(script);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {isArray} from 'Common/Utils';
|
||||
import { isArray } from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class ThemeStore
|
||||
{
|
||||
class ThemeStore {
|
||||
constructor() {
|
||||
this.themes = ko.observableArray([]);
|
||||
this.themeBackgroundName = ko.observable('');
|
||||
this.themeBackgroundHash = ko.observable('');
|
||||
|
||||
this.theme = ko.observable('').extend({limitedList: this.themes});
|
||||
this.theme = ko.observable('').extend({ limitedList: this.themes });
|
||||
}
|
||||
|
||||
populate() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
import {Magics} from 'Common/Enums';
|
||||
import { Magics } from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class AccountUserStore
|
||||
{
|
||||
class AccountUserStore {
|
||||
constructor() {
|
||||
this.email = ko.observable('');
|
||||
this.parentEmail = ko.observable('');
|
||||
|
|
@ -13,14 +11,13 @@ class AccountUserStore
|
|||
this.signature = ko.observable('');
|
||||
|
||||
this.accounts = ko.observableArray([]);
|
||||
this.accounts.loading = ko.observable(false).extend({throttle: Magics.Time100ms});
|
||||
this.accounts.loading = ko.observable(false).extend({ throttle: Magics.Time100ms });
|
||||
|
||||
this.computers();
|
||||
}
|
||||
|
||||
computers() {
|
||||
this.accountsEmails = ko.computed(
|
||||
() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null))));
|
||||
this.accountsEmails = ko.computed(() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null))));
|
||||
|
||||
this.accountsUnreadCount = ko.computed(() => 0);
|
||||
// this.accountsUnreadCount = ko.computed(() => {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {Focused, KeyState} from 'Common/Enums';
|
||||
import { Focused, KeyState } from 'Common/Enums';
|
||||
|
||||
import {keyScope, leftPanelDisabled} from 'Common/Globals';
|
||||
import {isNonEmptyArray} from 'Common/Utils';
|
||||
import { keyScope, leftPanelDisabled } from 'Common/Globals';
|
||||
import { isNonEmptyArray } from 'Common/Utils';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import {AbstractAppStore} from 'Stores/AbstractApp';
|
||||
import { AbstractAppStore } from 'Stores/AbstractApp';
|
||||
|
||||
class AppUserStore extends AbstractAppStore
|
||||
{
|
||||
class AppUserStore extends AbstractAppStore {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
|
@ -21,8 +19,7 @@ class AppUserStore extends AbstractAppStore
|
|||
const isMobile = Settings.appSettingsGet('mobile');
|
||||
|
||||
this.focusedState.subscribe((value) => {
|
||||
switch (value)
|
||||
{
|
||||
switch (value) {
|
||||
case Focused.MessageList:
|
||||
keyScope(KeyState.MessageList);
|
||||
if (isMobile) {
|
||||
|
|
@ -63,7 +60,6 @@ class AppUserStore extends AbstractAppStore
|
|||
}
|
||||
|
||||
populate() {
|
||||
|
||||
super.populate();
|
||||
|
||||
this.projectHash(Settings.settingsGet('ProjectHash'));
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {Magics} from 'Common/Enums';
|
||||
import { Magics } from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class ContactUserStore
|
||||
{
|
||||
class ContactUserStore {
|
||||
constructor() {
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.contacts.importing = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.contacts.syncing = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.contacts.exportingVcf = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.contacts.exportingCsv = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.contacts.loading = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
this.contacts.importing = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
this.contacts.syncing = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
this.contacts.exportingVcf = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
this.contacts.exportingCsv = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {Magics} from 'Common/Enums';
|
||||
import { Magics } from 'Common/Enums';
|
||||
|
||||
class FilterUserStore
|
||||
{
|
||||
class FilterUserStore {
|
||||
constructor() {
|
||||
this.capa = ko.observable('');
|
||||
this.modules = ko.observable({});
|
||||
|
||||
this.filters = ko.observableArray([]);
|
||||
|
||||
this.filters.loading = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.filters.saving = ko.observable(false).extend({throttle: Magics.Time200ms});
|
||||
this.filters.loading = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
this.filters.saving = ko.observable(false).extend({ throttle: Magics.Time200ms });
|
||||
|
||||
this.raw = ko.observable('');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
import {settingsGet} from 'Storage/Settings';
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
|
||||
import {FolderType} from 'Common/Enums';
|
||||
import {UNUSED_OPTION_VALUE} from 'Common/Consts';
|
||||
import {isArray, folderListOptionsBuilder} from 'Common/Utils';
|
||||
import {getFolderInboxName, getFolderFromCacheList} from 'Common/Cache';
|
||||
import { FolderType } from 'Common/Enums';
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { isArray, folderListOptionsBuilder } from 'Common/Utils';
|
||||
import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache';
|
||||
|
||||
import {momentNowUnix} from 'Common/Momentor';
|
||||
import { momentNowUnix } from 'Common/Momentor';
|
||||
|
||||
class FolderUserStore
|
||||
{
|
||||
class FolderUserStore {
|
||||
constructor() {
|
||||
this.displaySpecSetting = ko.observable(true);
|
||||
|
||||
|
|
@ -35,7 +33,7 @@ class FolderUserStore
|
|||
|
||||
this.foldersInboxUnreadCount = ko.observable(0);
|
||||
|
||||
this.currentFolder = ko.observable(null).extend({toggleSubscribeProperty: [this, 'selected']});
|
||||
this.currentFolder = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'selected'] });
|
||||
|
||||
this.sieveAllowFileintoInbox = !!settingsGet('SieveAllowFileintoInbox');
|
||||
|
||||
|
|
@ -44,25 +42,21 @@ class FolderUserStore
|
|||
}
|
||||
|
||||
computers() {
|
||||
|
||||
this.draftFolderNotEnabled = ko.computed(
|
||||
() => ('' === this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder())
|
||||
() => '' === this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder()
|
||||
);
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = ko.computed(
|
||||
() => !_.find(this.folderList(), (folder) => (folder && !folder.isSystemFolder() && folder.visible()))
|
||||
() => !_.find(this.folderList(), (folder) => folder && !folder.isSystemFolder() && folder.visible())
|
||||
);
|
||||
|
||||
this.currentFolderFullNameRaw = ko.computed(
|
||||
() => (this.currentFolder() ? this.currentFolder().fullNameRaw : '')
|
||||
);
|
||||
this.currentFolderFullNameRaw = ko.computed(() => (this.currentFolder() ? this.currentFolder().fullNameRaw : ''));
|
||||
|
||||
this.currentFolderFullName = ko.computed(() => (this.currentFolder() ? this.currentFolder().fullName : ''));
|
||||
this.currentFolderFullNameHash = ko.computed(() => (this.currentFolder() ? this.currentFolder().fullNameHash : ''));
|
||||
|
||||
this.foldersChanging = ko.computed(() => {
|
||||
const
|
||||
loading = this.foldersLoading(),
|
||||
const loading = this.foldersLoading(),
|
||||
creating = this.foldersCreating(),
|
||||
deleting = this.foldersDeleting(),
|
||||
renaming = this.foldersRenaming();
|
||||
|
|
@ -71,9 +65,7 @@ class FolderUserStore
|
|||
});
|
||||
|
||||
this.folderListSystemNames = ko.computed(() => {
|
||||
|
||||
const
|
||||
list = [getFolderInboxName()],
|
||||
const list = [getFolderInboxName()],
|
||||
folders = this.folderList(),
|
||||
sentFolder = this.sentFolder(),
|
||||
draftFolder = this.draftFolder(),
|
||||
|
|
@ -81,26 +73,20 @@ class FolderUserStore
|
|||
trashFolder = this.trashFolder(),
|
||||
archiveFolder = this.archiveFolder();
|
||||
|
||||
if (isArray(folders) && 0 < folders.length)
|
||||
{
|
||||
if ('' !== sentFolder && UNUSED_OPTION_VALUE !== sentFolder)
|
||||
{
|
||||
if (isArray(folders) && 0 < folders.length) {
|
||||
if ('' !== sentFolder && UNUSED_OPTION_VALUE !== sentFolder) {
|
||||
list.push(sentFolder);
|
||||
}
|
||||
if ('' !== draftFolder && UNUSED_OPTION_VALUE !== draftFolder)
|
||||
{
|
||||
if ('' !== draftFolder && UNUSED_OPTION_VALUE !== draftFolder) {
|
||||
list.push(draftFolder);
|
||||
}
|
||||
if ('' !== spamFolder && UNUSED_OPTION_VALUE !== spamFolder)
|
||||
{
|
||||
if ('' !== spamFolder && UNUSED_OPTION_VALUE !== spamFolder) {
|
||||
list.push(spamFolder);
|
||||
}
|
||||
if ('' !== trashFolder && UNUSED_OPTION_VALUE !== trashFolder)
|
||||
{
|
||||
if ('' !== trashFolder && UNUSED_OPTION_VALUE !== trashFolder) {
|
||||
list.push(trashFolder);
|
||||
}
|
||||
if ('' !== archiveFolder && UNUSED_OPTION_VALUE !== archiveFolder)
|
||||
{
|
||||
if ('' !== archiveFolder && UNUSED_OPTION_VALUE !== archiveFolder) {
|
||||
list.push(archiveFolder);
|
||||
}
|
||||
}
|
||||
|
|
@ -108,40 +94,50 @@ class FolderUserStore
|
|||
return list;
|
||||
});
|
||||
|
||||
this.folderListSystem = ko.computed(
|
||||
() => _.compact(_.map(this.folderListSystemNames(), (name) => getFolderFromCacheList(name)))
|
||||
this.folderListSystem = ko.computed(() =>
|
||||
_.compact(_.map(this.folderListSystemNames(), (name) => getFolderFromCacheList(name)))
|
||||
);
|
||||
|
||||
this.folderMenuForMove = ko.computed(
|
||||
() => folderListOptionsBuilder(
|
||||
this.folderListSystem(), this.folderList(),
|
||||
[this.currentFolderFullNameRaw()], null, null, null, null, (item) => (item ? item.localName() : ''))
|
||||
this.folderMenuForMove = ko.computed(() =>
|
||||
folderListOptionsBuilder(
|
||||
this.folderListSystem(),
|
||||
this.folderList(),
|
||||
[this.currentFolderFullNameRaw()],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
(item) => (item ? item.localName() : '')
|
||||
)
|
||||
);
|
||||
|
||||
this.folderMenuForFilters = ko.computed(
|
||||
() => folderListOptionsBuilder(
|
||||
this.folderListSystem(), this.folderList(),
|
||||
[(this.sieveAllowFileintoInbox ? '' : 'INBOX')], [['', '']], null, null, null, (item) => (item ? item.localName() : ''))
|
||||
this.folderMenuForFilters = ko.computed(() =>
|
||||
folderListOptionsBuilder(
|
||||
this.folderListSystem(),
|
||||
this.folderList(),
|
||||
[this.sieveAllowFileintoInbox ? '' : 'INBOX'],
|
||||
[['', '']],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
(item) => (item ? item.localName() : '')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
subscribers() {
|
||||
const
|
||||
fRemoveSystemFolderType = (observable) => () => {
|
||||
const folder = getFolderFromCacheList(observable());
|
||||
if (folder)
|
||||
{
|
||||
folder.type(FolderType.User);
|
||||
}
|
||||
};
|
||||
const
|
||||
fSetSystemFolderType = (type) => (value) => {
|
||||
const folder = getFolderFromCacheList(value);
|
||||
if (folder)
|
||||
{
|
||||
folder.type(type);
|
||||
}
|
||||
};
|
||||
const fRemoveSystemFolderType = (observable) => () => {
|
||||
const folder = getFolderFromCacheList(observable());
|
||||
if (folder) {
|
||||
folder.type(FolderType.User);
|
||||
}
|
||||
};
|
||||
const fSetSystemFolderType = (type) => (value) => {
|
||||
const folder = getFolderFromCacheList(value);
|
||||
if (folder) {
|
||||
folder.type(type);
|
||||
}
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||
|
|
@ -160,9 +156,7 @@ class FolderUserStore
|
|||
* @returns {Array}
|
||||
*/
|
||||
getNextFolderNames() {
|
||||
|
||||
const
|
||||
result = [],
|
||||
const result = [],
|
||||
limit = 5,
|
||||
utc = momentNowUnix(),
|
||||
timeout = utc - 60 * 5,
|
||||
|
|
@ -170,16 +164,18 @@ class FolderUserStore
|
|||
inboxFolderName = getFolderInboxName(),
|
||||
fSearchFunction = (list) => {
|
||||
_.each(list, (folder) => {
|
||||
if (folder && inboxFolderName !== folder.fullNameRaw &&
|
||||
folder.selectable && folder.existen && timeout > folder.interval &&
|
||||
if (
|
||||
folder &&
|
||||
inboxFolderName !== folder.fullNameRaw &&
|
||||
folder.selectable &&
|
||||
folder.existen &&
|
||||
timeout > folder.interval &&
|
||||
(folder.isSystemFolder() || (folder.subScribed() && folder.checkable()))
|
||||
)
|
||||
{
|
||||
) {
|
||||
timeouts.push([folder.interval, folder.fullNameRaw]);
|
||||
}
|
||||
|
||||
if (folder && 0 < folder.subFolders().length)
|
||||
{
|
||||
if (folder && 0 < folder.subFolders().length) {
|
||||
fSearchFunction(folder.subFolders());
|
||||
}
|
||||
});
|
||||
|
|
@ -188,12 +184,9 @@ class FolderUserStore
|
|||
fSearchFunction(this.folderList());
|
||||
|
||||
timeouts.sort((a, b) => {
|
||||
if (a[0] < b[0])
|
||||
{
|
||||
if (a[0] < b[0]) {
|
||||
return -1;
|
||||
}
|
||||
else if (a[0] > b[0])
|
||||
{
|
||||
} else if (a[0] > b[0]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -202,8 +195,7 @@ class FolderUserStore
|
|||
|
||||
_.find(timeouts, (aItem) => {
|
||||
const folder = getFolderFromCacheList(aItem[1]);
|
||||
if (folder)
|
||||
{
|
||||
if (folder) {
|
||||
folder.interval = utc;
|
||||
result.push(aItem[1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
class IdentityUserStore
|
||||
{
|
||||
class IdentityUserStore {
|
||||
constructor() {
|
||||
this.identities = ko.observableArray([]);
|
||||
this.identities.loading = ko.observable(false).extend({throttle: 100});
|
||||
this.identities.loading = ko.observable(false).extend({ throttle: 100 });
|
||||
|
||||
this.identitiesIDS = ko.computed(
|
||||
() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
|
||||
this.identitiesIDS = ko.computed(() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
import $ from '$';
|
||||
|
||||
import {
|
||||
Magics, Layout, Focused,
|
||||
MessageSetAction,
|
||||
StorageResultType,
|
||||
Notification
|
||||
} from 'Common/Enums';
|
||||
import { Magics, Layout, Focused, MessageSetAction, StorageResultType, Notification } from 'Common/Enums';
|
||||
|
||||
import {
|
||||
trim, isNormal, isArray, inArray,
|
||||
pInt, pString, plainToHtml,
|
||||
windowResize, findEmailAndLinks,
|
||||
trim,
|
||||
isNormal,
|
||||
isArray,
|
||||
inArray,
|
||||
pInt,
|
||||
pString,
|
||||
plainToHtml,
|
||||
windowResize,
|
||||
findEmailAndLinks,
|
||||
getRealHeight
|
||||
} from 'Common/Utils';
|
||||
|
||||
|
|
@ -32,16 +32,16 @@ import {
|
|||
clearNewMessageCache
|
||||
} from 'Common/Cache';
|
||||
|
||||
import {MESSAGE_BODY_CACHE_LIMIT} from 'Common/Consts';
|
||||
import {data as GlobalsData, $div} from 'Common/Globals';
|
||||
import {mailBox, notificationMailIcon} from 'Common/Links';
|
||||
import {i18n, getNotification} from 'Common/Translator';
|
||||
import {momentNowUnix} from 'Common/Momentor';
|
||||
import { MESSAGE_BODY_CACHE_LIMIT } from 'Common/Consts';
|
||||
import { data as GlobalsData, $div } from 'Common/Globals';
|
||||
import { mailBox, notificationMailIcon } from 'Common/Links';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
import { momentNowUnix } from 'Common/Momentor';
|
||||
|
||||
import * as MessageHelper from 'Helper/Message';
|
||||
import {MessageModel} from 'Model/Message';
|
||||
import { MessageModel } from 'Model/Message';
|
||||
|
||||
import {setHash} from 'Knoin/Knoin';
|
||||
import { setHash } from 'Knoin/Knoin';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
|
|
@ -50,17 +50,15 @@ import PgpStore from 'Stores/User/Pgp';
|
|||
import SettingsStore from 'Stores/User/Settings';
|
||||
import NotificationStore from 'Stores/User/Notification';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
class MessageUserStore
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
class MessageUserStore {
|
||||
constructor() {
|
||||
this.staticMessage = new MessageModel();
|
||||
|
||||
this.messageList = ko.observableArray([]).extend({rateLimit: 0});
|
||||
this.messageList = ko.observableArray([]).extend({ rateLimit: 0 });
|
||||
|
||||
this.messageListCount = ko.observable(0);
|
||||
this.messageListSearch = ko.observable('');
|
||||
|
|
@ -76,10 +74,10 @@ class MessageUserStore
|
|||
|
||||
this.messageListLoading = ko.observable(false);
|
||||
this.messageListIsNotCompleted = ko.observable(false);
|
||||
this.messageListCompleteLoadingThrottle = ko.observable(false).extend({throttle: 200});
|
||||
this.messageListCompleteLoadingThrottleForAnimation = ko.observable(false).extend({specialThrottle: 700});
|
||||
this.messageListCompleteLoadingThrottle = ko.observable(false).extend({ throttle: 200 });
|
||||
this.messageListCompleteLoadingThrottleForAnimation = ko.observable(false).extend({ specialThrottle: 700 });
|
||||
|
||||
this.messageListDisableAutoSelect = ko.observable(false).extend({falseTimeout: 500});
|
||||
this.messageListDisableAutoSelect = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
|
||||
this.selectorMessageSelected = ko.observable(null);
|
||||
this.selectorMessageFocused = ko.observable(null);
|
||||
|
|
@ -93,7 +91,7 @@ class MessageUserStore
|
|||
|
||||
this.messageCurrentLoading = ko.observable(false);
|
||||
|
||||
this.messageLoadingThrottle = ko.observable(false).extend({throttle: Magics.Time50ms});
|
||||
this.messageLoadingThrottle = ko.observable(false).extend({ throttle: Magics.Time50ms });
|
||||
|
||||
this.messageFullScreenMode = ko.observable(false);
|
||||
|
||||
|
|
@ -109,12 +107,17 @@ class MessageUserStore
|
|||
}
|
||||
|
||||
computers() {
|
||||
|
||||
this.messageLoading = ko.computed(() => this.messageCurrentLoading());
|
||||
|
||||
this.messageListEndHash = ko.computed(
|
||||
() => this.messageListEndFolder() + '|' + this.messageListEndSearch() +
|
||||
'|' + this.messageListEndThreadUid() + '|' + this.messageListEndPage()
|
||||
() =>
|
||||
this.messageListEndFolder() +
|
||||
'|' +
|
||||
this.messageListEndSearch() +
|
||||
'|' +
|
||||
this.messageListEndThreadUid() +
|
||||
'|' +
|
||||
this.messageListEndPage()
|
||||
);
|
||||
|
||||
this.messageListPageCount = ko.computed(() => {
|
||||
|
|
@ -132,23 +135,21 @@ class MessageUserStore
|
|||
});
|
||||
|
||||
this.messageListCompleteLoading = ko.computed(() => {
|
||||
const
|
||||
one = this.messageListLoading(),
|
||||
const one = this.messageListLoading(),
|
||||
two = this.messageListIsNotCompleted();
|
||||
return one || two;
|
||||
});
|
||||
|
||||
this.isMessageSelected = ko.computed(() => null !== this.message());
|
||||
|
||||
this.messageListChecked = ko.computed(
|
||||
() => _.filter(this.messageList(), (item) => item.checked())
|
||||
).extend({rateLimit: 0});
|
||||
this.messageListChecked = ko
|
||||
.computed(() => _.filter(this.messageList(), (item) => item.checked()))
|
||||
.extend({ rateLimit: 0 });
|
||||
|
||||
this.hasCheckedMessages = ko.computed(() => 0 < this.messageListChecked().length).extend({rateLimit: 0});
|
||||
this.hasCheckedMessages = ko.computed(() => 0 < this.messageListChecked().length).extend({ rateLimit: 0 });
|
||||
|
||||
this.messageListCheckedOrSelected = ko.computed(() => {
|
||||
const
|
||||
checked = this.messageListChecked(),
|
||||
const checked = this.messageListChecked(),
|
||||
selectedMessage = this.selectorMessageSelected(),
|
||||
focusedMessage = this.selectorMessageFocused();
|
||||
|
||||
|
|
@ -164,11 +165,9 @@ class MessageUserStore
|
|||
this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(() => {
|
||||
let result = [];
|
||||
_.each(this.messageListCheckedOrSelected(), (message) => {
|
||||
if (message)
|
||||
{
|
||||
if (message) {
|
||||
result.push(message.uid);
|
||||
if (1 < message.threadsLen())
|
||||
{
|
||||
if (1 < message.threadsLen()) {
|
||||
result = _.union(result, message.threads());
|
||||
}
|
||||
}
|
||||
|
|
@ -178,39 +177,33 @@ class MessageUserStore
|
|||
}
|
||||
|
||||
subscribers() {
|
||||
|
||||
this.messageListCompleteLoading.subscribe((value) => {
|
||||
value = !!value;
|
||||
this.messageListCompleteLoadingThrottle(value);
|
||||
this.messageListCompleteLoadingThrottleForAnimation(value);
|
||||
});
|
||||
|
||||
this.messageList.subscribe(_.debounce((list) => {
|
||||
_.each(list, (item) => {
|
||||
if (item && item.newForAnimation())
|
||||
{
|
||||
item.newForAnimation(false);
|
||||
}
|
||||
});
|
||||
}, Magics.Time500ms));
|
||||
this.messageList.subscribe(
|
||||
_.debounce((list) => {
|
||||
_.each(list, (item) => {
|
||||
if (item && item.newForAnimation()) {
|
||||
item.newForAnimation(false);
|
||||
}
|
||||
});
|
||||
}, Magics.Time500ms)
|
||||
);
|
||||
|
||||
this.message.subscribe((message) => {
|
||||
|
||||
if (message)
|
||||
{
|
||||
if (Layout.NoPreview === SettingsStore.layout())
|
||||
{
|
||||
if (message) {
|
||||
if (Layout.NoPreview === SettingsStore.layout()) {
|
||||
AppStore.focusedState(Focused.MessageView);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AppStore.focusedState(Focused.MessageList);
|
||||
|
||||
this.messageFullScreenMode(false);
|
||||
this.hideMessageBodies();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.messageLoading.subscribe((value) => {
|
||||
|
|
@ -218,42 +211,35 @@ class MessageUserStore
|
|||
});
|
||||
|
||||
this.messagesBodiesDom.subscribe((dom) => {
|
||||
if (dom && !(dom instanceof $))
|
||||
{
|
||||
if (dom && !(dom instanceof $)) {
|
||||
this.messagesBodiesDom($(dom));
|
||||
}
|
||||
});
|
||||
|
||||
this.messageListEndFolder.subscribe((folder) => {
|
||||
const message = this.message();
|
||||
if (message && folder && folder !== message.folderFullNameRaw)
|
||||
{
|
||||
if (message && folder && folder !== message.folderFullNameRaw) {
|
||||
this.message(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
purgeMessageBodyCache() {
|
||||
|
||||
let count = 0;
|
||||
const end = GlobalsData.iMessageBodyCacheCount - MESSAGE_BODY_CACHE_LIMIT;
|
||||
|
||||
if (0 < end)
|
||||
{
|
||||
if (0 < end) {
|
||||
const messagesDom = this.messagesBodiesDom();
|
||||
if (messagesDom)
|
||||
{
|
||||
if (messagesDom) {
|
||||
messagesDom.find('.rl-cache-class').each(function() {
|
||||
const item = $(this); // eslint-disable-line no-invalid-this
|
||||
if (end > item.data('rl-cache-count'))
|
||||
{
|
||||
if (end > item.data('rl-cache-count')) {
|
||||
item.addClass('rl-cache-purge');
|
||||
count += 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (0 < count)
|
||||
{
|
||||
if (0 < count) {
|
||||
_.delay(() => messagesDom.find('.rl-cache-purge').remove(), Magics.Time350ms);
|
||||
}
|
||||
}
|
||||
|
|
@ -261,10 +247,8 @@ class MessageUserStore
|
|||
}
|
||||
|
||||
initUidNextAndNewMessages(folder, uidNext, newMessages) {
|
||||
if (getFolderInboxName() === folder && isNormal(uidNext) && '' !== uidNext)
|
||||
{
|
||||
if (isArray(newMessages) && 0 < newMessages.length)
|
||||
{
|
||||
if (getFolderInboxName() === folder && isNormal(uidNext) && '' !== uidNext) {
|
||||
if (isArray(newMessages) && 0 < newMessages.length) {
|
||||
_.each(newMessages, (item) => {
|
||||
addNewMessageCache(folder, item.Uid);
|
||||
});
|
||||
|
|
@ -272,25 +256,22 @@ class MessageUserStore
|
|||
NotificationStore.playSoundNotification();
|
||||
|
||||
const len = newMessages.length;
|
||||
if (3 < len)
|
||||
{
|
||||
if (3 < len) {
|
||||
NotificationStore.displayDesktopNotification(
|
||||
notificationMailIcon(),
|
||||
AccountStore.email(),
|
||||
i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', {
|
||||
'COUNT': len
|
||||
}),
|
||||
{'Folder': '', 'Uid': ''}
|
||||
{ 'Folder': '', 'Uid': '' }
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_.each(newMessages, (item) => {
|
||||
NotificationStore.displayDesktopNotification(
|
||||
notificationMailIcon(),
|
||||
MessageHelper.emailArrayToString(MessageHelper.emailArrayFromJson(item.From), false),
|
||||
item.Subject,
|
||||
{'Folder': item.Folder, 'Uid': item.Uid}
|
||||
{ 'Folder': item.Folder, 'Uid': item.Uid }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -302,8 +283,7 @@ class MessageUserStore
|
|||
|
||||
hideMessageBodies() {
|
||||
const messagesDom = this.messagesBodiesDom();
|
||||
if (messagesDom)
|
||||
{
|
||||
if (messagesDom) {
|
||||
messagesDom.find('.b-text-part').hide();
|
||||
}
|
||||
}
|
||||
|
|
@ -315,73 +295,63 @@ class MessageUserStore
|
|||
* @param {boolean=} copy = false
|
||||
*/
|
||||
removeMessagesFromList(fromFolderFullNameRaw, uidForRemove, toFolderFullNameRaw = '', copy = false) {
|
||||
|
||||
uidForRemove = _.map(uidForRemove, (mValue) => pInt(mValue));
|
||||
|
||||
let
|
||||
unseenCount = 0,
|
||||
let unseenCount = 0,
|
||||
messageList = this.messageList(),
|
||||
currentMessage = this.message();
|
||||
|
||||
const
|
||||
trashFolder = FolderStore.trashFolder(),
|
||||
const trashFolder = FolderStore.trashFolder(),
|
||||
spamFolder = FolderStore.spamFolder(),
|
||||
fromFolder = getFolderFromCacheList(fromFolderFullNameRaw),
|
||||
toFolder = '' === toFolderFullNameRaw ? null : getFolderFromCacheList(toFolderFullNameRaw || ''),
|
||||
currentFolderFullNameRaw = FolderStore.currentFolderFullNameRaw(),
|
||||
messages = currentFolderFullNameRaw === fromFolderFullNameRaw ?
|
||||
_.filter(messageList, (item) => (item && -1 < inArray(pInt(item.uid), uidForRemove))) : [];
|
||||
messages =
|
||||
currentFolderFullNameRaw === fromFolderFullNameRaw
|
||||
? _.filter(messageList, (item) => item && -1 < inArray(pInt(item.uid), uidForRemove))
|
||||
: [];
|
||||
|
||||
_.each(messages, (item) => {
|
||||
if (item && item.unseen())
|
||||
{
|
||||
if (item && item.unseen()) {
|
||||
unseenCount += 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (fromFolder && !copy)
|
||||
{
|
||||
fromFolder.messageCountAll(0 <= fromFolder.messageCountAll() - uidForRemove.length ?
|
||||
fromFolder.messageCountAll() - uidForRemove.length : 0);
|
||||
if (fromFolder && !copy) {
|
||||
fromFolder.messageCountAll(
|
||||
0 <= fromFolder.messageCountAll() - uidForRemove.length ? fromFolder.messageCountAll() - uidForRemove.length : 0
|
||||
);
|
||||
|
||||
if (0 < unseenCount)
|
||||
{
|
||||
fromFolder.messageCountUnread(0 <= fromFolder.messageCountUnread() - unseenCount ?
|
||||
fromFolder.messageCountUnread() - unseenCount : 0);
|
||||
if (0 < unseenCount) {
|
||||
fromFolder.messageCountUnread(
|
||||
0 <= fromFolder.messageCountUnread() - unseenCount ? fromFolder.messageCountUnread() - unseenCount : 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (toFolder)
|
||||
{
|
||||
if (trashFolder === toFolder.fullNameRaw || spamFolder === toFolder.fullNameRaw)
|
||||
{
|
||||
if (toFolder) {
|
||||
if (trashFolder === toFolder.fullNameRaw || spamFolder === toFolder.fullNameRaw) {
|
||||
unseenCount = 0;
|
||||
}
|
||||
|
||||
toFolder.messageCountAll(toFolder.messageCountAll() + uidForRemove.length);
|
||||
if (0 < unseenCount)
|
||||
{
|
||||
if (0 < unseenCount) {
|
||||
toFolder.messageCountUnread(toFolder.messageCountUnread() + unseenCount);
|
||||
}
|
||||
|
||||
toFolder.actionBlink(true);
|
||||
}
|
||||
|
||||
if (0 < messages.length)
|
||||
{
|
||||
if (copy)
|
||||
{
|
||||
if (0 < messages.length) {
|
||||
if (copy) {
|
||||
_.each(messages, (item) => {
|
||||
item.checked(false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.messageListIsNotCompleted(true);
|
||||
|
||||
_.each(messages, (item) => {
|
||||
if (currentMessage && currentMessage.hash === item.hash)
|
||||
{
|
||||
if (currentMessage && currentMessage.hash === item.hash) {
|
||||
currentMessage = null;
|
||||
this.message(null);
|
||||
}
|
||||
|
|
@ -397,57 +367,62 @@ class MessageUserStore
|
|||
}
|
||||
}
|
||||
|
||||
if ('' !== fromFolderFullNameRaw)
|
||||
{
|
||||
if ('' !== fromFolderFullNameRaw) {
|
||||
setFolderHash(fromFolderFullNameRaw, '');
|
||||
}
|
||||
|
||||
if ('' !== toFolderFullNameRaw)
|
||||
{
|
||||
if ('' !== toFolderFullNameRaw) {
|
||||
setFolderHash(toFolderFullNameRaw, '');
|
||||
}
|
||||
|
||||
if ('' !== this.messageListThreadUid())
|
||||
{
|
||||
if ('' !== this.messageListThreadUid()) {
|
||||
messageList = this.messageList();
|
||||
|
||||
if (messageList && 0 < messageList.length &&
|
||||
!!_.find(messageList, (item) => !!(item && item.deleted() && item.uid === this.messageListThreadUid())))
|
||||
{
|
||||
if (
|
||||
messageList &&
|
||||
0 < messageList.length &&
|
||||
!!_.find(messageList, (item) => !!(item && item.deleted() && item.uid === this.messageListThreadUid()))
|
||||
) {
|
||||
const message = _.find(messageList, (item) => item && !item.deleted());
|
||||
if (message && this.messageListThreadUid() !== pString(message.uid))
|
||||
{
|
||||
if (message && this.messageListThreadUid() !== pString(message.uid)) {
|
||||
this.messageListThreadUid(pString(message.uid));
|
||||
|
||||
setHash(mailBox(
|
||||
FolderStore.currentFolderFullNameHash(),
|
||||
this.messageListPage(),
|
||||
this.messageListSearch(),
|
||||
this.messageListThreadUid()
|
||||
), true, true);
|
||||
}
|
||||
else if (!message)
|
||||
{
|
||||
if (1 < this.messageListPage())
|
||||
{
|
||||
this.messageListPage(this.messageListPage() - 1);
|
||||
|
||||
setHash(mailBox(
|
||||
setHash(
|
||||
mailBox(
|
||||
FolderStore.currentFolderFullNameHash(),
|
||||
this.messageListPage(),
|
||||
this.messageListSearch(),
|
||||
this.messageListThreadUid()
|
||||
), true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
),
|
||||
true,
|
||||
true
|
||||
);
|
||||
} else if (!message) {
|
||||
if (1 < this.messageListPage()) {
|
||||
this.messageListPage(this.messageListPage() - 1);
|
||||
|
||||
setHash(
|
||||
mailBox(
|
||||
FolderStore.currentFolderFullNameHash(),
|
||||
this.messageListPage(),
|
||||
this.messageListSearch(),
|
||||
this.messageListThreadUid()
|
||||
),
|
||||
true,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
this.messageListThreadUid('');
|
||||
|
||||
setHash(mailBox(
|
||||
FolderStore.currentFolderFullNameHash(),
|
||||
this.messageListPageBeforeThread(),
|
||||
this.messageListSearch()
|
||||
), true, true);
|
||||
setHash(
|
||||
mailBox(
|
||||
FolderStore.currentFolderFullNameHash(),
|
||||
this.messageListPageBeforeThread(),
|
||||
this.messageListSearch()
|
||||
),
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -458,25 +433,26 @@ class MessageUserStore
|
|||
* @param {Object} messageTextBody
|
||||
*/
|
||||
initBlockquoteSwitcher(messageTextBody) {
|
||||
if (messageTextBody)
|
||||
{
|
||||
if (messageTextBody) {
|
||||
const $oList = $('blockquote:not(.rl-bq-switcher)', messageTextBody).filter(function() {
|
||||
return 0 === $(this).parent().closest('blockquote', messageTextBody).length; // eslint-disable-line no-invalid-this
|
||||
return (
|
||||
0 ===
|
||||
$(this)
|
||||
.parent()
|
||||
.closest('blockquote', messageTextBody).length
|
||||
); // eslint-disable-line no-invalid-this
|
||||
});
|
||||
|
||||
if ($oList && 0 < $oList.length)
|
||||
{
|
||||
if ($oList && 0 < $oList.length) {
|
||||
$oList.each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
let h = $this.height();
|
||||
if (0 === h)
|
||||
{
|
||||
if (0 === h) {
|
||||
h = getRealHeight($this);
|
||||
}
|
||||
|
||||
if ('' !== trim($this.text()) && (0 === h || 100 < h))
|
||||
{
|
||||
if ('' !== trim($this.text()) && (0 === h || 100 < h)) {
|
||||
$this.addClass('rl-bq-switcher hidden-bq');
|
||||
$('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>')
|
||||
.insertBefore($this)
|
||||
|
|
@ -497,8 +473,7 @@ class MessageUserStore
|
|||
* @param {Object} message
|
||||
*/
|
||||
initOpenPgpControls(messageTextBody, message) {
|
||||
if (messageTextBody && messageTextBody.find)
|
||||
{
|
||||
if (messageTextBody && messageTextBody.find) {
|
||||
messageTextBody.find('.b-plain-openpgp:not(.inited)').each(function() {
|
||||
PgpStore.initMessageBodyControls($(this), message); // eslint-disable-line no-invalid-this
|
||||
});
|
||||
|
|
@ -506,9 +481,7 @@ class MessageUserStore
|
|||
}
|
||||
|
||||
setMessage(data, cached) {
|
||||
|
||||
let
|
||||
isNew = false,
|
||||
let isNew = false,
|
||||
body = null,
|
||||
id = '',
|
||||
plain = '',
|
||||
|
|
@ -518,15 +491,17 @@ class MessageUserStore
|
|||
selectedMessage = this.selectorMessageSelected(),
|
||||
message = this.message();
|
||||
|
||||
if (data && message && data.Result && 'Object/Message' === data.Result['@Object'] &&
|
||||
message.folderFullNameRaw === data.Result.Folder)
|
||||
{
|
||||
if (
|
||||
data &&
|
||||
message &&
|
||||
data.Result &&
|
||||
'Object/Message' === data.Result['@Object'] &&
|
||||
message.folderFullNameRaw === data.Result.Folder
|
||||
) {
|
||||
const threads = message.threads();
|
||||
if (message.uid !== data.Result.Uid && 1 < threads.length && -1 < inArray(data.Result.Uid, threads))
|
||||
{
|
||||
if (message.uid !== data.Result.Uid && 1 < threads.length && -1 < inArray(data.Result.Uid, threads)) {
|
||||
message = MessageModel.newInstanceFromJson(data.Result);
|
||||
if (message)
|
||||
{
|
||||
if (message) {
|
||||
message.threads(threads);
|
||||
initMessageFlagsFromCache(message);
|
||||
|
||||
|
|
@ -537,63 +512,45 @@ class MessageUserStore
|
|||
}
|
||||
}
|
||||
|
||||
if (message && message.uid === data.Result.Uid)
|
||||
{
|
||||
if (message && message.uid === data.Result.Uid) {
|
||||
this.messageError('');
|
||||
|
||||
message.initUpdateByMessageJson(data.Result);
|
||||
addRequestedMessage(message.folderFullNameRaw, message.uid);
|
||||
|
||||
if (!cached)
|
||||
{
|
||||
if (!cached) {
|
||||
message.initFlagsByJson(data.Result);
|
||||
}
|
||||
|
||||
messagesDom = messagesDom && messagesDom[0] ? messagesDom : null;
|
||||
if (messagesDom)
|
||||
{
|
||||
if (messagesDom) {
|
||||
id = 'rl-mgs-' + message.hash.replace(/[^a-zA-Z0-9]/g, '');
|
||||
|
||||
const textBody = messagesDom.find('#' + id);
|
||||
if (!textBody || !textBody[0])
|
||||
{
|
||||
if (!textBody || !textBody[0]) {
|
||||
let isHtml = false;
|
||||
if (isNormal(data.Result.Html) && '' !== data.Result.Html)
|
||||
{
|
||||
if (isNormal(data.Result.Html) && '' !== data.Result.Html) {
|
||||
isHtml = true;
|
||||
resultHtml = data.Result.Html.toString();
|
||||
}
|
||||
else if (isNormal(data.Result.Plain) && '' !== data.Result.Plain)
|
||||
{
|
||||
} else if (isNormal(data.Result.Plain) && '' !== data.Result.Plain) {
|
||||
isHtml = false;
|
||||
resultHtml = plainToHtml(data.Result.Plain.toString(), false);
|
||||
|
||||
if ((message.isPgpSigned() || message.isPgpEncrypted()) && PgpStore.capaOpenPGP())
|
||||
{
|
||||
if ((message.isPgpSigned() || message.isPgpEncrypted()) && PgpStore.capaOpenPGP()) {
|
||||
plain = pString(data.Result.Plain);
|
||||
|
||||
const isPgpEncrypted = (/---BEGIN PGP MESSAGE---/).test(plain);
|
||||
if (!isPgpEncrypted)
|
||||
{
|
||||
pgpSigned = (/-----BEGIN PGP SIGNED MESSAGE-----/).test(plain) &&
|
||||
(/-----BEGIN PGP SIGNATURE-----/).test(plain);
|
||||
const isPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(plain);
|
||||
if (!isPgpEncrypted) {
|
||||
pgpSigned =
|
||||
/-----BEGIN PGP SIGNED MESSAGE-----/.test(plain) && /-----BEGIN PGP SIGNATURE-----/.test(plain);
|
||||
}
|
||||
|
||||
$div.empty();
|
||||
if (pgpSigned && message.isPgpSigned())
|
||||
{
|
||||
resultHtml = $div.append(
|
||||
$('<pre class="b-plain-openpgp signed"></pre>').text(plain)
|
||||
).html();
|
||||
}
|
||||
else if (isPgpEncrypted && message.isPgpEncrypted())
|
||||
{
|
||||
resultHtml = $div.append(
|
||||
$('<pre class="b-plain-openpgp encrypted"></pre>').text(plain)
|
||||
).html();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pgpSigned && message.isPgpSigned()) {
|
||||
resultHtml = $div.append($('<pre class="b-plain-openpgp signed"></pre>').text(plain)).html();
|
||||
} else if (isPgpEncrypted && message.isPgpEncrypted()) {
|
||||
resultHtml = $div.append($('<pre class="b-plain-openpgp encrypted"></pre>').text(plain)).html();
|
||||
} else {
|
||||
resultHtml = '<pre>' + resultHtml + '</pre>';
|
||||
}
|
||||
|
||||
|
|
@ -601,55 +558,45 @@ class MessageUserStore
|
|||
|
||||
message.isPgpSigned(pgpSigned);
|
||||
message.isPgpEncrypted(isPgpEncrypted);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
resultHtml = '<pre>' + resultHtml + '</pre>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
isHtml = false;
|
||||
resultHtml = '<pre>' + resultHtml + '</pre>';
|
||||
}
|
||||
|
||||
GlobalsData.iMessageBodyCacheCount += 1;
|
||||
|
||||
body = $('<div id="' + id + '" ></div>').hide().addClass('rl-cache-class');
|
||||
body = $('<div id="' + id + '" ></div>')
|
||||
.hide()
|
||||
.addClass('rl-cache-class');
|
||||
body.data('rl-cache-count', GlobalsData.iMessageBodyCacheCount);
|
||||
|
||||
body
|
||||
.html(findEmailAndLinks(resultHtml))
|
||||
.addClass('b-text-part ' + (isHtml ? 'html' : 'plain'));
|
||||
body.html(findEmailAndLinks(resultHtml)).addClass('b-text-part ' + (isHtml ? 'html' : 'plain'));
|
||||
|
||||
message.isHtml(!!isHtml);
|
||||
message.hasImages(!!data.Result.HasExternals);
|
||||
|
||||
message.body = body;
|
||||
if (message.body)
|
||||
{
|
||||
if (message.body) {
|
||||
messagesDom.append(message.body);
|
||||
}
|
||||
|
||||
message.storeDataInDom();
|
||||
|
||||
if (data.Result.HasInternals)
|
||||
{
|
||||
if (data.Result.HasInternals) {
|
||||
message.showInternalImages(true);
|
||||
}
|
||||
|
||||
if (message.hasImages() && SettingsStore.showImages())
|
||||
{
|
||||
if (message.hasImages() && SettingsStore.showImages()) {
|
||||
message.showExternalImages(true);
|
||||
}
|
||||
|
||||
this.purgeMessageBodyCacheThrottle();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
message.body = textBody;
|
||||
if (message.body)
|
||||
{
|
||||
if (message.body) {
|
||||
GlobalsData.iMessageBodyCacheCount += 1;
|
||||
message.body.data('rl-cache-count', GlobalsData.iMessageBodyCacheCount);
|
||||
message.fetchDataFromDom();
|
||||
|
|
@ -660,8 +607,7 @@ class MessageUserStore
|
|||
|
||||
this.hideMessageBodies();
|
||||
|
||||
if (body)
|
||||
{
|
||||
if (body) {
|
||||
this.initOpenPgpControls(body, message);
|
||||
|
||||
this.initBlockquoteSwitcher(body);
|
||||
|
|
@ -671,42 +617,36 @@ class MessageUserStore
|
|||
}
|
||||
|
||||
initMessageFlagsFromCache(message);
|
||||
if (message.unseen() || message.hasUnseenSubMessage())
|
||||
{
|
||||
getApp().messageListAction(
|
||||
message.folderFullNameRaw, MessageSetAction.SetSeen, [message]);
|
||||
if (message.unseen() || message.hasUnseenSubMessage()) {
|
||||
getApp().messageListAction(message.folderFullNameRaw, MessageSetAction.SetSeen, [message]);
|
||||
}
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
if (isNew) {
|
||||
message = this.message();
|
||||
|
||||
if (selectedMessage && message && (
|
||||
message.folderFullNameRaw !== selectedMessage.folderFullNameRaw ||
|
||||
message.uid !== selectedMessage.uid
|
||||
))
|
||||
{
|
||||
if (
|
||||
selectedMessage &&
|
||||
message &&
|
||||
(message.folderFullNameRaw !== selectedMessage.folderFullNameRaw || message.uid !== selectedMessage.uid)
|
||||
) {
|
||||
this.selectorMessageSelected(null);
|
||||
if (1 === this.messageList().length)
|
||||
{
|
||||
if (1 === this.messageList().length) {
|
||||
this.selectorMessageFocused(null);
|
||||
}
|
||||
}
|
||||
else if (!selectedMessage && message)
|
||||
{
|
||||
selectedMessage = _.find(this.messageList(),
|
||||
(subMessage) => subMessage &&
|
||||
} else if (!selectedMessage && message) {
|
||||
selectedMessage = _.find(
|
||||
this.messageList(),
|
||||
(subMessage) =>
|
||||
subMessage &&
|
||||
subMessage.folderFullNameRaw === message.folderFullNameRaw &&
|
||||
subMessage.uid === message.uid
|
||||
);
|
||||
|
||||
if (selectedMessage)
|
||||
{
|
||||
if (selectedMessage) {
|
||||
this.selectorMessageSelected(selectedMessage);
|
||||
this.selectorMessageFocused(selectedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
windowResize();
|
||||
|
|
@ -715,37 +655,29 @@ class MessageUserStore
|
|||
}
|
||||
|
||||
selectMessage(oMessage) {
|
||||
if (oMessage)
|
||||
{
|
||||
if (oMessage) {
|
||||
this.message(this.staticMessage.populateByMessageListItem(oMessage));
|
||||
this.populateMessageBody(this.message());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.message(null);
|
||||
}
|
||||
}
|
||||
|
||||
selectMessageByFolderAndUid(sFolder, sUid) {
|
||||
if (sFolder && sUid)
|
||||
{
|
||||
if (sFolder && sUid) {
|
||||
this.message(this.staticMessage.populateByMessageListItem(null));
|
||||
this.message().folderFullNameRaw = sFolder;
|
||||
this.message().uid = sUid;
|
||||
|
||||
this.populateMessageBody(this.message());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.message(null);
|
||||
}
|
||||
}
|
||||
|
||||
populateMessageBody(oMessage) {
|
||||
if (oMessage)
|
||||
{
|
||||
if (Remote.message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid))
|
||||
{
|
||||
if (oMessage) {
|
||||
if (Remote.message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid)) {
|
||||
this.messageCurrentLoading(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -757,25 +689,20 @@ class MessageUserStore
|
|||
* @param {boolean} bCached
|
||||
*/
|
||||
onMessageResponse(sResult, oData, bCached) {
|
||||
|
||||
this.hideMessageBodies();
|
||||
|
||||
this.messageCurrentLoading(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
this.setMessage(oData, bCached);
|
||||
}
|
||||
else if (StorageResultType.Unload === sResult)
|
||||
{
|
||||
} else if (StorageResultType.Unload === sResult) {
|
||||
this.message(null);
|
||||
this.messageError('');
|
||||
}
|
||||
else if (StorageResultType.Abort !== sResult)
|
||||
{
|
||||
} else if (StorageResultType.Abort !== sResult) {
|
||||
this.message(null);
|
||||
this.messageError((oData && oData.ErrorCode ?
|
||||
getNotification(oData.ErrorCode) : getNotification(Notification.UnknownError)));
|
||||
this.messageError(
|
||||
oData && oData.ErrorCode ? getNotification(oData.ErrorCode) : getNotification(Notification.UnknownError)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -784,40 +711,40 @@ class MessageUserStore
|
|||
* @returns {string}
|
||||
*/
|
||||
calculateMessageListHash(list) {
|
||||
return _.map(list, (message) => '' + message.hash + '_' + message.threadsLen() + '_' + message.flagHash()).join('|');
|
||||
return _.map(list, (message) => '' + message.hash + '_' + message.threadsLen() + '_' + message.flagHash()).join(
|
||||
'|'
|
||||
);
|
||||
}
|
||||
|
||||
setMessageList(data, cached) {
|
||||
if (data && data.Result && 'Collection/MessageCollection' === data.Result['@Object'] &&
|
||||
data.Result['@Collection'] && isArray(data.Result['@Collection']))
|
||||
{
|
||||
let
|
||||
newCount = 0,
|
||||
if (
|
||||
data &&
|
||||
data.Result &&
|
||||
'Collection/MessageCollection' === data.Result['@Object'] &&
|
||||
data.Result['@Collection'] &&
|
||||
isArray(data.Result['@Collection'])
|
||||
) {
|
||||
let newCount = 0,
|
||||
unreadCountChange = false;
|
||||
|
||||
const
|
||||
list = [],
|
||||
const list = [],
|
||||
utc = momentNowUnix(),
|
||||
iCount = pInt(data.Result.MessageResultCount),
|
||||
iOffset = pInt(data.Result.Offset);
|
||||
|
||||
const folder = getFolderFromCacheList(isNormal(data.Result.Folder) ? data.Result.Folder : '');
|
||||
|
||||
if (folder && !cached)
|
||||
{
|
||||
if (folder && !cached) {
|
||||
folder.interval = utc;
|
||||
|
||||
setFolderHash(data.Result.Folder, data.Result.FolderHash);
|
||||
|
||||
if (isNormal(data.Result.MessageCount))
|
||||
{
|
||||
if (isNormal(data.Result.MessageCount)) {
|
||||
folder.messageCountAll(data.Result.MessageCount);
|
||||
}
|
||||
|
||||
if (isNormal(data.Result.MessageUnseenCount))
|
||||
{
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(data.Result.MessageUnseenCount))
|
||||
{
|
||||
if (isNormal(data.Result.MessageUnseenCount)) {
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(data.Result.MessageUnseenCount)) {
|
||||
unreadCountChange = true;
|
||||
}
|
||||
|
||||
|
|
@ -827,31 +754,24 @@ class MessageUserStore
|
|||
this.initUidNextAndNewMessages(folder.fullNameRaw, data.Result.UidNext, data.Result.NewMessages);
|
||||
}
|
||||
|
||||
if (unreadCountChange && folder)
|
||||
{
|
||||
if (unreadCountChange && folder) {
|
||||
clearMessageFlagsFromCacheByFolder(folder.fullNameRaw);
|
||||
}
|
||||
|
||||
_.each(data.Result['@Collection'], (jsonMessage) => {
|
||||
if (jsonMessage && 'Object/Message' === jsonMessage['@Object'])
|
||||
{
|
||||
if (jsonMessage && 'Object/Message' === jsonMessage['@Object']) {
|
||||
const message = MessageModel.newInstanceFromJson(jsonMessage);
|
||||
if (message)
|
||||
{
|
||||
if (hasNewMessageAndRemoveFromCache(message.folderFullNameRaw, message.uid) && 5 >= newCount)
|
||||
{
|
||||
if (message) {
|
||||
if (hasNewMessageAndRemoveFromCache(message.folderFullNameRaw, message.uid) && 5 >= newCount) {
|
||||
newCount += 1;
|
||||
message.newForAnimation(true);
|
||||
}
|
||||
|
||||
message.deleted(false);
|
||||
|
||||
if (cached)
|
||||
{
|
||||
if (cached) {
|
||||
initMessageFlagsFromCache(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
storeMessageFlagsToCache(message);
|
||||
}
|
||||
|
||||
|
|
@ -862,7 +782,7 @@ class MessageUserStore
|
|||
|
||||
this.messageListCount(iCount);
|
||||
this.messageListSearch(isNormal(data.Result.Search) ? data.Result.Search : '');
|
||||
this.messageListPage(window.Math.ceil((iOffset / SettingsStore.messagesPerPage()) + 1));
|
||||
this.messageListPage(window.Math.ceil(iOffset / SettingsStore.messagesPerPage() + 1));
|
||||
this.messageListThreadUid(isNormal(data.Result.ThreadUid) ? pString(data.Result.ThreadUid) : '');
|
||||
|
||||
this.messageListEndFolder(isNormal(data.Result.Folder) ? data.Result.Folder : '');
|
||||
|
|
@ -877,18 +797,13 @@ class MessageUserStore
|
|||
|
||||
clearNewMessageCache();
|
||||
|
||||
if (folder && (cached || unreadCountChange || SettingsStore.useThreads()))
|
||||
{
|
||||
if (folder && (cached || unreadCountChange || SettingsStore.useThreads())) {
|
||||
getApp().folderInformation(folder.fullNameRaw, list);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.messageListCount(0);
|
||||
this.messageList([]);
|
||||
this.messageListError(getNotification(
|
||||
data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList
|
||||
));
|
||||
this.messageListError(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,110 +1,87 @@
|
|||
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
import {DesktopNotification, Magics} from 'Common/Enums';
|
||||
import { DesktopNotification, Magics } from 'Common/Enums';
|
||||
import * as Events from 'Common/Events';
|
||||
import Audio from 'Common/Audio';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class NotificationUserStore
|
||||
{
|
||||
class NotificationUserStore {
|
||||
constructor() {
|
||||
this.enableSoundNotification = ko.observable(false);
|
||||
this.soundNotificationIsSupported = ko.observable(false);
|
||||
|
||||
this.allowDesktopNotification = ko.observable(false);
|
||||
|
||||
this.desktopNotificationPermissions = ko.computed(() => {
|
||||
this.desktopNotificationPermissions = ko
|
||||
.computed(() => {
|
||||
this.allowDesktopNotification();
|
||||
|
||||
this.allowDesktopNotification();
|
||||
let result = DesktopNotification.NotSupported;
|
||||
|
||||
let result = DesktopNotification.NotSupported;
|
||||
|
||||
const NotificationClass = this.notificationClass();
|
||||
if (NotificationClass && NotificationClass.permission)
|
||||
{
|
||||
switch (NotificationClass.permission.toLowerCase())
|
||||
{
|
||||
case 'granted':
|
||||
result = DesktopNotification.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
result = DesktopNotification.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
result = DesktopNotification.NotAllowed;
|
||||
break;
|
||||
// no default
|
||||
const NotificationClass = this.notificationClass();
|
||||
if (NotificationClass && NotificationClass.permission) {
|
||||
switch (NotificationClass.permission.toLowerCase()) {
|
||||
case 'granted':
|
||||
result = DesktopNotification.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
result = DesktopNotification.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
result = DesktopNotification.NotAllowed;
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
} else if (window.webkitNotifications && window.webkitNotifications.checkPermission) {
|
||||
result = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
}
|
||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||
{
|
||||
result = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
})
|
||||
.extend({ notify: 'always' });
|
||||
|
||||
}).extend({notify: 'always'});
|
||||
this.enableDesktopNotification = ko
|
||||
.computed({
|
||||
read: () =>
|
||||
this.allowDesktopNotification() && DesktopNotification.Allowed === this.desktopNotificationPermissions(),
|
||||
write: (value) => {
|
||||
if (value) {
|
||||
const NotificationClass = this.notificationClass(),
|
||||
permission = this.desktopNotificationPermissions();
|
||||
|
||||
this.enableDesktopNotification = ko.computed({
|
||||
read: () => this.allowDesktopNotification() && DesktopNotification.Allowed === this.desktopNotificationPermissions(),
|
||||
write: (value) => {
|
||||
if (value)
|
||||
{
|
||||
const
|
||||
NotificationClass = this.notificationClass(),
|
||||
permission = this.desktopNotificationPermissions();
|
||||
if (NotificationClass && DesktopNotification.Allowed === permission) {
|
||||
this.allowDesktopNotification(true);
|
||||
} else if (NotificationClass && DesktopNotification.NotAllowed === permission) {
|
||||
NotificationClass.requestPermission(() => {
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
|
||||
if (NotificationClass && DesktopNotification.Allowed === permission)
|
||||
{
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
else if (NotificationClass && DesktopNotification.NotAllowed === permission)
|
||||
{
|
||||
NotificationClass.requestPermission(() => {
|
||||
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
|
||||
if (DesktopNotification.Allowed === this.desktopNotificationPermissions())
|
||||
{
|
||||
if (this.allowDesktopNotification())
|
||||
{
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
if (DesktopNotification.Allowed === this.desktopNotificationPermissions()) {
|
||||
if (this.allowDesktopNotification()) {
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
} else {
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
} else {
|
||||
if (this.allowDesktopNotification()) {
|
||||
this.allowDesktopNotification(false);
|
||||
} else {
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.allowDesktopNotification())
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
});
|
||||
} else {
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
} else {
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
}).extend({notify: 'always'});
|
||||
})
|
||||
.extend({ notify: 'always' });
|
||||
|
||||
if (!this.enableDesktopNotification.valueHasMutated)
|
||||
{
|
||||
if (!this.enableDesktopNotification.valueHasMutated) {
|
||||
this.enableDesktopNotification.valueHasMutated = () => {
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
};
|
||||
|
|
@ -121,72 +98,64 @@ class NotificationUserStore
|
|||
);
|
||||
|
||||
this.isDesktopNotificationDenied = ko.computed(
|
||||
() => DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||
() =>
|
||||
DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||
DesktopNotification.Denied === this.desktopNotificationPermissions()
|
||||
);
|
||||
}
|
||||
|
||||
initNotificationPlayer() {
|
||||
if (Audio && Audio.supportedNotification)
|
||||
{
|
||||
if (Audio && Audio.supportedNotification) {
|
||||
this.soundNotificationIsSupported(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.enableSoundNotification(false);
|
||||
this.soundNotificationIsSupported(false);
|
||||
}
|
||||
}
|
||||
|
||||
playSoundNotification(skipSetting) {
|
||||
if (Audio && Audio.supportedNotification && (skipSetting ? true : this.enableSoundNotification()))
|
||||
{
|
||||
if (Audio && Audio.supportedNotification && (skipSetting ? true : this.enableSoundNotification())) {
|
||||
Audio.playNotification();
|
||||
}
|
||||
}
|
||||
|
||||
displayDesktopNotification(imageSrc, title, text, nessageData) {
|
||||
if (this.enableDesktopNotification())
|
||||
{
|
||||
const
|
||||
NotificationClass = this.notificationClass(),
|
||||
notification = NotificationClass ? new NotificationClass(title, {
|
||||
body: text,
|
||||
icon: imageSrc
|
||||
}) : null;
|
||||
if (this.enableDesktopNotification()) {
|
||||
const NotificationClass = this.notificationClass(),
|
||||
notification = NotificationClass
|
||||
? new NotificationClass(title, {
|
||||
body: text,
|
||||
icon: imageSrc
|
||||
})
|
||||
: null;
|
||||
|
||||
if (notification)
|
||||
{
|
||||
if (notification.show)
|
||||
{
|
||||
if (notification) {
|
||||
if (notification.show) {
|
||||
notification.show();
|
||||
}
|
||||
|
||||
if (nessageData)
|
||||
{
|
||||
if (nessageData) {
|
||||
notification.onclick = () => {
|
||||
|
||||
window.focus();
|
||||
|
||||
if (nessageData.Folder && nessageData.Uid)
|
||||
{
|
||||
if (nessageData.Folder && nessageData.Uid) {
|
||||
Events.pub('mailbox.message.show', [nessageData.Folder, nessageData.Uid]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
window.setTimeout((function(localNotifications) {
|
||||
return () => {
|
||||
if (localNotifications.cancel)
|
||||
{
|
||||
localNotifications.cancel();
|
||||
}
|
||||
else if (localNotifications.close)
|
||||
{
|
||||
localNotifications.close();
|
||||
}
|
||||
};
|
||||
}(notification)), Magics.Time7s);
|
||||
window.setTimeout(
|
||||
(function(localNotifications) {
|
||||
return () => {
|
||||
if (localNotifications.cancel) {
|
||||
localNotifications.cancel();
|
||||
} else if (localNotifications.close) {
|
||||
localNotifications.close();
|
||||
}
|
||||
};
|
||||
})(notification),
|
||||
Magics.Time7s
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
|
||||
import {i18n} from 'Common/Translator';
|
||||
import {log, isArray, isNonEmptyArray, pString, isUnd, trim} from 'Common/Utils';
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { log, isArray, isNonEmptyArray, pString, isUnd, trim } from 'Common/Utils';
|
||||
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
class PgpUserStore
|
||||
{
|
||||
class PgpUserStore {
|
||||
constructor() {
|
||||
this.capaOpenPGP = ko.observable(false);
|
||||
|
||||
|
|
@ -32,7 +30,7 @@ class PgpUserStore
|
|||
}
|
||||
|
||||
findKeyByHex(keys, hash) {
|
||||
return _.find(keys, (item) => (hash && item && (hash === item.id || -1 < item.ids.indexOf(hash))));
|
||||
return _.find(keys, (item) => hash && item && (hash === item.id || -1 < item.ids.indexOf(hash)));
|
||||
}
|
||||
|
||||
findPublicKeyByHex(hash) {
|
||||
|
|
@ -44,32 +42,59 @@ class PgpUserStore
|
|||
}
|
||||
|
||||
findPublicKeysByEmail(email) {
|
||||
return _.compact(_.flatten(_.map(this.openpgpkeysPublic(), (item) => {
|
||||
const key = item && -1 < item.emails.indexOf(email) ? item : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}), true));
|
||||
return _.compact(
|
||||
_.flatten(
|
||||
_.map(this.openpgpkeysPublic(), (item) => {
|
||||
const key = item && -1 < item.emails.indexOf(email) ? item : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
findPublicKeysBySigningKeyIds(signingKeyIds) {
|
||||
return _.compact(_.flatten(_.map(signingKeyIds, (id) => {
|
||||
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}), true));
|
||||
return _.compact(
|
||||
_.flatten(
|
||||
_.map(signingKeyIds, (id) => {
|
||||
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
findPrivateKeysByEncryptionKeyIds(encryptionKeyIds, recipients, returnWrapKeys) {
|
||||
let
|
||||
result = isArray(encryptionKeyIds) ? _.compact(_.flatten(_.map(encryptionKeyIds, (id) => {
|
||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
let result = isArray(encryptionKeyIds)
|
||||
? _.compact(
|
||||
_.flatten(
|
||||
_.map(encryptionKeyIds, (id) => {
|
||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
)
|
||||
: [];
|
||||
|
||||
if (0 === result.length && isNonEmptyArray(recipients))
|
||||
{
|
||||
result = _.uniq(_.compact(_.flatten(_.map(recipients, (sEmail) => {
|
||||
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return keys ? (returnWrapKeys ? keys : _.flatten(_.map(keys, (key) => key.getNativeKeys()), true)) : [null];
|
||||
}), true)), (key) => key.id);
|
||||
if (0 === result.length && isNonEmptyArray(recipients)) {
|
||||
result = _.uniq(
|
||||
_.compact(
|
||||
_.flatten(
|
||||
_.map(recipients, (sEmail) => {
|
||||
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return keys
|
||||
? returnWrapKeys
|
||||
? keys
|
||||
: _.flatten(_.map(keys, (key) => key.getNativeKeys()), true)
|
||||
: [null];
|
||||
}),
|
||||
true
|
||||
)
|
||||
),
|
||||
(key) => key.id
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -80,7 +105,7 @@ class PgpUserStore
|
|||
* @returns {?}
|
||||
*/
|
||||
findPublicKeyByEmailNotNative(email) {
|
||||
return _.find(this.openpgpkeysPublic(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
return _.find(this.openpgpkeysPublic(), (item) => item && -1 < item.emails.indexOf(email)) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +113,7 @@ class PgpUserStore
|
|||
* @returns {?}
|
||||
*/
|
||||
findPrivateKeyByEmailNotNative(email) {
|
||||
return _.find(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
return _.find(this.openpgpkeysPrivate(), (item) => item && -1 < item.emails.indexOf(email)) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,7 +121,7 @@ class PgpUserStore
|
|||
* @returns {?}
|
||||
*/
|
||||
findAllPublicKeysByEmailNotNative(email) {
|
||||
return _.filter(this.openpgpkeysPublic(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
return _.filter(this.openpgpkeysPublic(), (item) => item && -1 < item.emails.indexOf(email)) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -104,7 +129,7 @@ class PgpUserStore
|
|||
* @returns {?}
|
||||
*/
|
||||
findAllPrivateKeysByEmailNotNative(email) {
|
||||
return _.filter(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
return _.filter(this.openpgpkeysPrivate(), (item) => item && -1 < item.emails.indexOf(email)) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,22 +138,16 @@ class PgpUserStore
|
|||
* @returns {?}
|
||||
*/
|
||||
findPrivateKeyByEmail(email, password) {
|
||||
|
||||
let privateKey = null;
|
||||
const key = _.find(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email)));
|
||||
const key = _.find(this.openpgpkeysPrivate(), (item) => item && -1 < item.emails.indexOf(email));
|
||||
|
||||
if (key)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (key) {
|
||||
try {
|
||||
privateKey = key.getNativeKeys()[0] || null;
|
||||
if (privateKey)
|
||||
{
|
||||
if (privateKey) {
|
||||
privateKey.decrypt(pString(password));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
privateKey = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -145,46 +164,38 @@ class PgpUserStore
|
|||
}
|
||||
|
||||
decryptMessage(message, recipients, fCallback) {
|
||||
if (message && message.getEncryptionKeyIds)
|
||||
{
|
||||
if (message && message.getEncryptionKeyIds) {
|
||||
const privateKeys = this.findPrivateKeysByEncryptionKeyIds(message.getEncryptionKeyIds(), recipients, true);
|
||||
if (privateKeys && 0 < privateKeys.length)
|
||||
{
|
||||
showScreenPopup(require('View/Popup/MessageOpenPgp'), [(decryptedKey) => {
|
||||
|
||||
if (decryptedKey)
|
||||
{
|
||||
message.decrypt(decryptedKey).then((decryptedMessage) => {
|
||||
let privateKey = null;
|
||||
if (decryptedMessage)
|
||||
{
|
||||
privateKey = this.findPrivateKeyByHex(decryptedKey.primaryKey.keyid.toHex());
|
||||
if (privateKey)
|
||||
{
|
||||
this.verifyMessage(decryptedMessage, (oValidKey, aSigningKeyIds) => {
|
||||
fCallback(privateKey, decryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||
});
|
||||
if (privateKeys && 0 < privateKeys.length) {
|
||||
showScreenPopup(require('View/Popup/MessageOpenPgp'), [
|
||||
(decryptedKey) => {
|
||||
if (decryptedKey) {
|
||||
message.decrypt(decryptedKey).then(
|
||||
(decryptedMessage) => {
|
||||
let privateKey = null;
|
||||
if (decryptedMessage) {
|
||||
privateKey = this.findPrivateKeyByHex(decryptedKey.primaryKey.keyid.toHex());
|
||||
if (privateKey) {
|
||||
this.verifyMessage(decryptedMessage, (oValidKey, aSigningKeyIds) => {
|
||||
fCallback(privateKey, decryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||
});
|
||||
} else {
|
||||
fCallback(privateKey, decryptedMessage);
|
||||
}
|
||||
} else {
|
||||
fCallback(privateKey, decryptedMessage);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
fCallback(null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(privateKey, decryptedMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(privateKey, decryptedMessage);
|
||||
}
|
||||
|
||||
}, () => {
|
||||
);
|
||||
} else {
|
||||
fCallback(null, null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(null, null);
|
||||
}
|
||||
|
||||
}, privateKeys]);
|
||||
}
|
||||
},
|
||||
privateKeys
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -196,28 +207,20 @@ class PgpUserStore
|
|||
}
|
||||
|
||||
verifyMessage(message, fCallback) {
|
||||
if (message && message.getSigningKeyIds)
|
||||
{
|
||||
if (message && message.getSigningKeyIds) {
|
||||
const signingKeyIds = message.getSigningKeyIds();
|
||||
if (signingKeyIds && 0 < signingKeyIds.length)
|
||||
{
|
||||
if (signingKeyIds && 0 < signingKeyIds.length) {
|
||||
const publicKeys = this.findPublicKeysBySigningKeyIds(signingKeyIds);
|
||||
if (publicKeys && 0 < publicKeys.length)
|
||||
{
|
||||
try
|
||||
{
|
||||
const
|
||||
result = message.verify(publicKeys),
|
||||
valid = _.find(_.isArray(result) ? result : [], (item) => (item && item.valid && item.keyid));
|
||||
if (publicKeys && 0 < publicKeys.length) {
|
||||
try {
|
||||
const result = message.verify(publicKeys),
|
||||
valid = _.find(_.isArray(result) ? result : [], (item) => item && item.valid && item.keyid);
|
||||
|
||||
if (valid && valid.keyid && valid.keyid && valid.keyid.toHex)
|
||||
{
|
||||
if (valid && valid.keyid && valid.keyid && valid.keyid.toHex) {
|
||||
fCallback(this.findPublicKeyByHex(valid.keyid.toHex()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -232,75 +235,83 @@ class PgpUserStore
|
|||
}
|
||||
|
||||
controlsHelper(dom, verControl, success, title, text) {
|
||||
if (success)
|
||||
{
|
||||
dom.removeClass('error').addClass('success').attr('title', title);
|
||||
verControl.removeClass('error').addClass('success').attr('title', title);
|
||||
}
|
||||
else
|
||||
{
|
||||
dom.removeClass('success').addClass('error').attr('title', title);
|
||||
verControl.removeClass('success').addClass('error').attr('title', title);
|
||||
if (success) {
|
||||
dom
|
||||
.removeClass('error')
|
||||
.addClass('success')
|
||||
.attr('title', title);
|
||||
verControl
|
||||
.removeClass('error')
|
||||
.addClass('success')
|
||||
.attr('title', title);
|
||||
} else {
|
||||
dom
|
||||
.removeClass('success')
|
||||
.addClass('error')
|
||||
.attr('title', title);
|
||||
verControl
|
||||
.removeClass('success')
|
||||
.addClass('error')
|
||||
.attr('title', title);
|
||||
}
|
||||
|
||||
if (!isUnd(text))
|
||||
{
|
||||
if (!isUnd(text)) {
|
||||
dom.text(trim(text));
|
||||
}
|
||||
}
|
||||
|
||||
static domControlEncryptedClickHelper(store, dom, armoredMessage, recipients) {
|
||||
|
||||
return function() {
|
||||
|
||||
let message = null;
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
if ($this.hasClass('success'))
|
||||
{
|
||||
if ($this.hasClass('success')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
message = store.openpgp.message.readArmored(armoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
|
||||
if (message && message.getText && message.verify && message.decrypt)
|
||||
{
|
||||
store.decryptMessage(message, recipients, (validPrivateKey, decryptedMessage, validPublicKey, signingKeyIds) => {
|
||||
if (decryptedMessage)
|
||||
{
|
||||
if (validPublicKey)
|
||||
{
|
||||
store.controlsHelper(dom, $this, true, i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': validPublicKey.user + ' (' + validPublicKey.id + ')'
|
||||
}), decryptedMessage.getText());
|
||||
}
|
||||
else if (validPrivateKey)
|
||||
{
|
||||
const
|
||||
keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds ? _.compact(_.map(keyIds,
|
||||
(item) => (item && item.toHex ? item.toHex() : null))).join(', ') : '';
|
||||
if (message && message.getText && message.verify && message.decrypt) {
|
||||
store.decryptMessage(
|
||||
message,
|
||||
recipients,
|
||||
(validPrivateKey, decryptedMessage, validPublicKey, signingKeyIds) => {
|
||||
if (decryptedMessage) {
|
||||
if (validPublicKey) {
|
||||
store.controlsHelper(
|
||||
dom,
|
||||
$this,
|
||||
true,
|
||||
i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': validPublicKey.user + ' (' + validPublicKey.id + ')'
|
||||
}),
|
||||
decryptedMessage.getText()
|
||||
);
|
||||
} else if (validPrivateKey) {
|
||||
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds
|
||||
? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ')
|
||||
: '';
|
||||
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(additional ? ' (' + additional + ')' : ''), decryptedMessage.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(
|
||||
dom,
|
||||
$this,
|
||||
false,
|
||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : ''),
|
||||
decryptedMessage.getText()
|
||||
);
|
||||
} else {
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
} else {
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -311,43 +322,44 @@ class PgpUserStore
|
|||
}
|
||||
|
||||
static domControlSignedClickHelper(store, dom, armoredMessage) {
|
||||
|
||||
return function() {
|
||||
|
||||
let message = null;
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||
{
|
||||
if ($this.hasClass('success') || $this.hasClass('error')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
message = store.openpgp.cleartext.readArmored(armoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
|
||||
if (message && message.getText && message.verify)
|
||||
{
|
||||
if (message && message.getText && message.verify) {
|
||||
store.verifyMessage(message, (validKey, signingKeyIds) => {
|
||||
if (validKey)
|
||||
{
|
||||
store.controlsHelper(dom, $this, true, i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': validKey.user + ' (' + validKey.id + ')'
|
||||
}), message.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
const
|
||||
keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds ? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ') : '';
|
||||
if (validKey) {
|
||||
store.controlsHelper(
|
||||
dom,
|
||||
$this,
|
||||
true,
|
||||
i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': validKey.user + ' (' + validKey.id + ')'
|
||||
}),
|
||||
message.getText()
|
||||
);
|
||||
} else {
|
||||
const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds
|
||||
? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ')
|
||||
: '';
|
||||
|
||||
store.controlsHelper(dom, $this, false,
|
||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : ''));
|
||||
store.controlsHelper(
|
||||
dom,
|
||||
$this,
|
||||
false,
|
||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : '')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -364,37 +376,30 @@ class PgpUserStore
|
|||
* @param {MessageModel} rainLoopMessage
|
||||
*/
|
||||
initMessageBodyControls(dom, rainLoopMessage) {
|
||||
if (dom && !dom.hasClass('inited'))
|
||||
{
|
||||
if (dom && !dom.hasClass('inited')) {
|
||||
dom.addClass('inited');
|
||||
|
||||
const
|
||||
encrypted = dom.hasClass('encrypted'),
|
||||
const encrypted = dom.hasClass('encrypted'),
|
||||
signed = dom.hasClass('signed'),
|
||||
recipients = rainLoopMessage ? rainLoopMessage.getEmails(['from', 'to', 'cc']) : [];
|
||||
|
||||
let verControl = null;
|
||||
|
||||
if (encrypted || signed)
|
||||
{
|
||||
if (encrypted || signed) {
|
||||
const domText = dom.text();
|
||||
dom.data('openpgp-original', domText);
|
||||
|
||||
if (encrypted)
|
||||
{
|
||||
if (encrypted) {
|
||||
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, dom, domText, recipients));
|
||||
}
|
||||
else if (signed)
|
||||
{
|
||||
} else if (signed) {
|
||||
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlSignedClickHelper(this, dom, domText));
|
||||
}
|
||||
|
||||
if (verControl)
|
||||
{
|
||||
if (verControl) {
|
||||
dom.before(verControl).before('<div></div>');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,18 @@
|
|||
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
import {Magics} from 'Common/Enums';
|
||||
import { Magics } from 'Common/Enums';
|
||||
|
||||
class QuotaUserStore
|
||||
{
|
||||
class QuotaUserStore {
|
||||
constructor() {
|
||||
this.quota = ko.observable(0);
|
||||
this.usage = ko.observable(0);
|
||||
|
||||
this.percentage = ko.computed(() => {
|
||||
|
||||
const
|
||||
quota = this.quota(),
|
||||
const quota = this.quota(),
|
||||
usage = this.usage();
|
||||
|
||||
return 0 < quota ? window.Math.ceil((usage / quota) * 100) : 0;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
import {MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
|
||||
import {Layout, EditorDefaultType, Magics} from 'Common/Enums';
|
||||
import {$html} from 'Common/Globals';
|
||||
import {pInt} from 'Common/Utils';
|
||||
import { MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES } from 'Common/Consts';
|
||||
import { Layout, EditorDefaultType, Magics } from 'Common/Enums';
|
||||
import { $html } from 'Common/Globals';
|
||||
import { pInt } from 'Common/Utils';
|
||||
import * as Events from 'Common/Events';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
class SettingsUserStore
|
||||
{
|
||||
class SettingsUserStore {
|
||||
constructor() {
|
||||
|
||||
this.iAutoLogoutTimer = 0;
|
||||
|
||||
this.layout = ko.observable(Layout.SidePreview)
|
||||
.extend({limitedList: [Layout.SidePreview, Layout.BottomPreview, Layout.NoPreview]});
|
||||
this.layout = ko
|
||||
.observable(Layout.SidePreview)
|
||||
.extend({ limitedList: [Layout.SidePreview, Layout.BottomPreview, Layout.NoPreview] });
|
||||
|
||||
this.editorDefaultType = ko.observable(EditorDefaultType.Html)
|
||||
.extend({limitedList: [
|
||||
EditorDefaultType.Html, EditorDefaultType.Plain,
|
||||
EditorDefaultType.HtmlForced, EditorDefaultType.PlainForced
|
||||
]});
|
||||
this.editorDefaultType = ko.observable(EditorDefaultType.Html).extend({
|
||||
limitedList: [
|
||||
EditorDefaultType.Html,
|
||||
EditorDefaultType.Plain,
|
||||
EditorDefaultType.HtmlForced,
|
||||
EditorDefaultType.PlainForced
|
||||
]
|
||||
});
|
||||
|
||||
this.messagesPerPage = ko.observable(MESSAGES_PER_PAGE)
|
||||
.extend({limitedList: MESSAGES_PER_PAGE_VALUES});
|
||||
this.messagesPerPage = ko.observable(MESSAGES_PER_PAGE).extend({ limitedList: MESSAGES_PER_PAGE_VALUES });
|
||||
|
||||
this.showImages = ko.observable(false);
|
||||
this.useCheckboxesInList = ko.observable(true);
|
||||
|
|
@ -68,8 +68,7 @@ class SettingsUserStore
|
|||
|
||||
Events.sub('rl.auto-logout-refresh', () => {
|
||||
window.clearTimeout(this.iAutoLogoutTimer);
|
||||
if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
||||
{
|
||||
if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe')) {
|
||||
this.iAutoLogoutTimer = window.setTimeout(() => {
|
||||
Events.pub('rl.auto-logout');
|
||||
}, this.autoLogout() * Magics.Time1m);
|
||||
|
|
|
|||
|
|
@ -1,23 +1,20 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
// import Remote from 'Remote/User/Ajax';
|
||||
|
||||
class TemplateUserStore
|
||||
{
|
||||
class TemplateUserStore {
|
||||
constructor() {
|
||||
this.templates = ko.observableArray([]);
|
||||
this.templates.loading = ko.observable(false).extend({throttle: 100});
|
||||
this.templates.loading = ko.observable(false).extend({ throttle: 100 });
|
||||
|
||||
this.templatesNames = ko.observableArray([]).extend({throttle: 1000});
|
||||
this.templatesNames = ko.observableArray([]).extend({ throttle: 1000 });
|
||||
this.templatesNames.skipFirst = true;
|
||||
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
subscribers() {
|
||||
|
||||
this.templates.subscribe((list) => {
|
||||
this.templatesNames(_.compact(_.map(list, (item) => (item ? item.name : null))));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue