Small code cleanups and fix translations

This commit is contained in:
djmaze 2021-01-27 00:26:31 +01:00
parent b31bf3d7f5
commit 7ccc44616d
54 changed files with 288 additions and 426 deletions

View file

@ -14,17 +14,16 @@ import {
SetSystemFoldersNotification
} from 'Common/EnumsUser';
import { inFocus, pInt } from 'Common/Utils';
import { inFocus, pInt, isArray, isNonEmptyArray } from 'Common/Utils';
import { delegateRunOnDestroy } from 'Common/UtilsUser';
import { encodeHtml } from 'Common/Html';
import { encodeHtml, HtmlEditor } from 'Common/Html';
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { upload } from 'Common/Links';
import { i18n, getNotification, getUploadErrorDescByCode } from 'Common/Translator';
import { format as momentorFormat } from 'Common/Momentor';
import { timestampToString } from 'Common/Momentor';
import { MessageFlagsCache, setFolderHash } from 'Common/Cache';
import { HtmlEditor } from 'Common/Html';
import { Settings } from 'Common/Globals';
import AppStore from 'Stores/User/App';
import SettingsStore from 'Stores/User/Settings';
@ -46,7 +45,7 @@ import { AskPopupView } from 'View/Popup/Ask';
import { ContactsPopupView } from 'View/Popup/Contacts';
import { ComposeOpenPgpPopupView } from 'View/Popup/ComposeOpenPgp';
const Settings = rl.settings,
const
/**
* @param {string} prefix
* @param {string} subject
@ -324,7 +323,7 @@ class ComposePopupView extends AbstractViewPopup {
},
attachmentsInProcess: value => {
if (this.attachmentsInProcessError() && Array.isNotEmpty(value)) {
if (this.attachmentsInProcessError() && isNonEmptyArray(value)) {
this.attachmentsInProcessError(false);
}
}
@ -395,7 +394,7 @@ class ComposePopupView extends AbstractViewPopup {
if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) {
if (SettingsStore.replySameFolder()) {
if (
Array.isArray(this.aDraftInfo) &&
isArray(this.aDraftInfo) &&
3 === this.aDraftInfo.length &&
null != this.aDraftInfo[2] &&
this.aDraftInfo[2].length
@ -414,7 +413,7 @@ class ComposePopupView extends AbstractViewPopup {
this.sendError(false);
this.sending(true);
if (Array.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) {
if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) {
const flagsCache = MessageFlagsCache.getFor(this.aDraftInfo[2], this.aDraftInfo[1]);
if (flagsCache) {
if ('forward' === this.aDraftInfo[0]) {
@ -820,7 +819,7 @@ class ComposePopupView extends AbstractViewPopup {
* @param {Array} emails
*/
addEmailsTo(fKoValue, emails) {
if (Array.isNotEmpty(emails)) {
if (isNonEmptyArray(emails)) {
const value = fKoValue().trim(),
values = emails.map(item => item ? item.toLine(false) : null)
.validUnique();
@ -870,9 +869,9 @@ class ComposePopupView extends AbstractViewPopup {
oMessageOrArray = oMessageOrArray || null;
if (oMessageOrArray) {
message =
Array.isArray(oMessageOrArray) && 1 === oMessageOrArray.length
isArray(oMessageOrArray) && 1 === oMessageOrArray.length
? oMessageOrArray[0]
: !Array.isArray(oMessageOrArray)
: !isArray(oMessageOrArray)
? oMessageOrArray
: null;
}
@ -890,20 +889,20 @@ class ComposePopupView extends AbstractViewPopup {
excludeEmail[identity.email()] = true;
}
if (Array.isNotEmpty(aToEmails)) {
if (isNonEmptyArray(aToEmails)) {
this.to(this.emailArrayToStringLineHelper(aToEmails));
}
if (Array.isNotEmpty(aCcEmails)) {
if (isNonEmptyArray(aCcEmails)) {
this.cc(this.emailArrayToStringLineHelper(aCcEmails));
}
if (Array.isNotEmpty(aBccEmails)) {
if (isNonEmptyArray(aBccEmails)) {
this.bcc(this.emailArrayToStringLineHelper(aBccEmails));
}
if (lineComposeType && message) {
sDate = momentorFormat(message.dateTimeStampInUTC(), 'FULL');
sDate = timestampToString(message.dateTimeStampInUTC(), 'FULL');
sSubject = message.subject();
aDraftInfo = message.aDraftInfo;
sText = message.bodyAsHTML();
@ -963,7 +962,7 @@ class ComposePopupView extends AbstractViewPopup {
this.subject(sSubject);
this.prepareMessageAttachments(message, lineComposeType);
this.aDraftInfo = Array.isNotEmpty(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null;
this.aDraftInfo = isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null;
this.sInReplyTo = message.sInReplyTo;
this.sReferences = message.sReferences;
break;
@ -977,7 +976,7 @@ class ComposePopupView extends AbstractViewPopup {
this.subject(sSubject);
this.prepareMessageAttachments(message, lineComposeType);
this.aDraftInfo = Array.isNotEmpty(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null;
this.aDraftInfo = isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null;
this.sInReplyTo = message.sInReplyTo;
this.sReferences = message.sReferences;
break;
@ -1070,7 +1069,7 @@ class ComposePopupView extends AbstractViewPopup {
this.setFocusInPopup();
});
} else if (Array.isNotEmpty(oMessageOrArray)) {
} else if (isNonEmptyArray(oMessageOrArray)) {
oMessageOrArray.forEach(item => {
this.addMessageAsAttachment(item);
});
@ -1096,7 +1095,7 @@ class ComposePopupView extends AbstractViewPopup {
}
const downloads = this.getAttachmentsDownloadsForUpload();
if (Array.isNotEmpty(downloads)) {
if (isNonEmptyArray(downloads)) {
Remote.messageUploadAttachments((sResult, oData) => {
if (StorageResultType.Success === sResult && oData && oData.Result) {
Object.entries(oData.Result).forEach(([tempName, id]) => {

View file

@ -1,5 +1,5 @@
import { KeyState } from 'Common/Enums';
import { doc } from 'Common/Globals';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
class ViewOpenPgpKeyPopupView extends AbstractViewPopup {
@ -22,7 +22,7 @@ class ViewOpenPgpKeyPopupView extends AbstractViewPopup {
const el = this.keyDom();
if (el) {
let sel = getSelection(),
range = document.createRange();
range = doc.createRange();
sel.removeAllRanges();
range.selectNodeContents(el);
sel.addRange(range);

View file

@ -11,7 +11,7 @@ import { AbstractViewRight } from 'Knoin/AbstractViews';
import { KeyboardShortcutsHelpPopupView } from 'View/Popup/KeyboardShortcutsHelp';
import { AccountPopupView } from 'View/Popup/Account';
const Settings = rl.settings;
import { Settings } from 'Common/Globals';
export class AbstractSystemDropDownUserView extends AbstractViewRight {
constructor(name) {

View file

@ -19,12 +19,12 @@ import Remote from 'Remote/User/Fetch';
import { command, showScreenPopup } from 'Knoin/Knoin';
import { AbstractViewCenter } from 'Knoin/AbstractViews';
import { Settings } from 'Common/Globals';
import { rootAdmin } from 'Common/Links';
import { LanguagesPopupView } from 'View/Popup/Languages';
const Settings = rl.settings,
const
LoginSignMeType = {
DefaultOff: 0,
DefaultOn: 1,

View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { Capa, KeyState } from 'Common/Enums';
import { Focused, Layout } from 'Common/EnumsUser';
import { leftPanelDisabled, moveAction } from 'Common/Globals';
import { leftPanelDisabled, moveAction, Settings } from 'Common/Globals';
import { mailBox, settings } from 'Common/Links';
import { setFolderHash } from 'Common/Cache';
@ -18,8 +18,6 @@ import { ComposePopupView } from 'View/Popup/Compose';
import { FolderCreatePopupView } from 'View/Popup/FolderCreate';
import { ContactsPopupView } from 'View/Popup/Contacts';
const Settings = rl.settings;
class FolderListMailBoxUserView extends AbstractViewLeft {
constructor() {
super('User/MailBox/FolderList', 'MailFolderList');

View file

@ -16,7 +16,7 @@ import {
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { leftPanelDisabled, moveAction } from 'Common/Globals';
import { doc, leftPanelDisabled, moveAction, Settings } from 'Common/Globals';
import { computedPaginatorHelper } from 'Common/UtilsUser';
import { File } from 'Common/File';
@ -49,7 +49,6 @@ import { ComposePopupView } from 'View/Popup/Compose';
import { AdvancedSearchPopupView } from 'View/Popup/AdvancedSearch';
const
Settings = rl.settings,
canBeMovedHelper = (self) => self.canBeMoved(),
ifvisible = window.ifvisible;
@ -456,7 +455,7 @@ class MessageListMailBoxUserView extends AbstractViewRight {
}
getDragData(event) {
const item = ko.dataFor(document.elementFromPoint(event.clientX, event.clientY));
const item = ko.dataFor(doc.elementFromPoint(event.clientX, event.clientY));
item && item.checked && item.checked(true);
const uids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails();
item && !uids.includes(item.uid) && uids.push(item.uid);

View file

@ -16,7 +16,7 @@ import {
MessageSetAction
} from 'Common/EnumsUser';
import { $htmlCL, leftPanelDisabled, keyScopeReal, moveAction } from 'Common/Globals';
import { $htmlCL, leftPanelDisabled, keyScopeReal, moveAction, Settings } from 'Common/Globals';
import { inFocus } from 'Common/Utils';
import { mailToHelper } from 'Common/UtilsUser';
@ -43,8 +43,6 @@ import { AbstractViewRight } from 'Knoin/AbstractViews';
import { ComposePopupView } from 'View/Popup/Compose';
const Settings = rl.settings;
function isTransparent(color) {
return 'rgba(0, 0, 0, 0)' === color || 'transparent' === color;
}