cleanup some code

This commit is contained in:
djmaze 2020-10-02 12:40:33 +02:00
parent e566494a87
commit cb2048f163
14 changed files with 32 additions and 117 deletions

View file

@ -83,23 +83,6 @@ export const Focused = {
FolderList: 'folder-list' FolderList: 'folder-list'
}; };
/**
* @enum {number}
*/
export const State = {
Empty: 10,
Login: 20,
Auth: 30
};
/**
* @enum {number}
*/
export const StateType = {
Webmail: 0,
Admin: 1
};
/** /**
* @enum {string} * @enum {string}
*/ */
@ -108,7 +91,6 @@ export const Capa = {
TwoFactorForce: 'TWO_FACTOR_FORCE', TwoFactorForce: 'TWO_FACTOR_FORCE',
OpenPGP: 'OPEN_PGP', OpenPGP: 'OPEN_PGP',
Prefetch: 'PREFETCH', Prefetch: 'PREFETCH',
Gravatar: 'GRAVATAR',
Folders: 'FOLDERS', Folders: 'FOLDERS',
Composer: 'COMPOSER', Composer: 'COMPOSER',
Contacts: 'CONTACTS', Contacts: 'CONTACTS',
@ -252,7 +234,7 @@ export const ClientSideKeyName = {
LastSignMe: 7, LastSignMe: 7,
ComposeLastIdentityID: 8, ComposeLastIdentityID: 8,
MessageHeaderFullInfo: 9, MessageHeaderFullInfo: 9,
MessageAttachmnetControls: 10 MessageAttachmentControls: 10
}; };
/** /**
@ -432,17 +414,6 @@ export const ContactPropertyType = {
Custom: 250 Custom: 250
}; };
/**
* @enum {number}
*/
export const Ports = {
Imap: 143,
ImapSsl: 993,
Smtp: 25,
SmtpSsl: 465,
SmtpStartTls: 587
};
/** /**
* @enum {number} * @enum {number}
*/ */

View file

@ -7,11 +7,7 @@ const
SERVER_PREFIX = './?', SERVER_PREFIX = './?',
SUB_QUERY_PREFIX = '&q[]=', SUB_QUERY_PREFIX = '&q[]=',
VERSION = Settings.app('version'), VERSION = Settings.app('version'),
WEB_PREFIX = Settings.app('webPath') || '',
VERSION_PREFIX = Settings.app('webVersionPath') || 'rainloop/v/' + VERSION + '/', VERSION_PREFIX = Settings.app('webVersionPath') || 'rainloop/v/' + VERSION + '/',
STATIC_PREFIX = VERSION_PREFIX + 'static/',
ADMIN_HOST_USE = !!Settings.app('adminHostUse'),
ADMIN_PATH = Settings.app('adminPath') || 'admin',
getHash = () => Settings.get('AuthAccountHash') || '0'; getHash = () => Settings.get('AuthAccountHash') || '0';
@ -34,7 +30,7 @@ export function root(startupUrl = '') {
* @returns {string} * @returns {string}
*/ */
export function rootAdmin() { export function rootAdmin() {
return ADMIN_HOST_USE ? ROOT : SERVER_PREFIX + ADMIN_PATH; return Settings.app('adminHostUse') ? ROOT : SERVER_PREFIX + (Settings.app('adminPath') || 'admin');
} }
/** /**
@ -238,7 +234,7 @@ export function exportContactsCsv() {
* @returns {string} * @returns {string}
*/ */
export function staticPrefix(path) { export function staticPrefix(path) {
return STATIC_PREFIX + path; return VERSION_PREFIX + 'static/' + path;
} }
/** /**
@ -292,7 +288,7 @@ export function themePreviewLink(theme) {
let prefix = VERSION_PREFIX; let prefix = VERSION_PREFIX;
if ('@custom' === theme.substr(-7)) { if ('@custom' === theme.substr(-7)) {
theme = theme.substr(0, theme.length - 7).trim(); theme = theme.substr(0, theme.length - 7).trim();
prefix = WEB_PREFIX; prefix = Settings.app('webPath') || '';
} }
return prefix + 'themes/' + encodeURI(theme) + '/images/preview.png'; return prefix + 'themes/' + encodeURI(theme) + '/images/preview.png';

View file

@ -18,9 +18,7 @@ export class AbstractModel {
regDisposables(value) { regDisposables(value) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
value.forEach((item) => { value.forEach(item => this.disposables.push(item));
this.disposables.push(item);
});
} else if (value) { } else if (value) {
this.disposables.push(value); this.disposables.push(value);
} }

View file

@ -32,7 +32,7 @@ export class AbstractScreen {
/** /**
* @returns {?Object} * @returns {?Object}
*/ */
__cross() { get __cross() {
return this.oCross; return this.oCross;
} }

View file

@ -9,7 +9,7 @@ export class AbstractViewNext {
sDefaultKeyScope = KeyState.None; sDefaultKeyScope = KeyState.None;
sCurrentKeyScope = KeyState.None; sCurrentKeyScope = KeyState.None;
viewModelVisibility = ko.observable(false); viewModelVisible = false;
modalVisibility = ko.observable(false).extend({ rateLimit: 0 }); modalVisibility = ko.observable(false).extend({ rateLimit: 0 });
viewModelName = ''; viewModelName = '';

View file

@ -249,8 +249,7 @@ export function isPopupVisible(ViewModelClassToShow) {
*/ */
function screenOnRoute(screenName, subPart) { function screenOnRoute(screenName, subPart) {
let vmScreen = null, let vmScreen = null,
isSameScreen = false, isSameScreen = false;
cross = null;
if (null == screenName || '' == screenName) { if (null == screenName || '' == screenName) {
screenName = defaultScreenName; screenName = defaultScreenName;
@ -295,7 +294,7 @@ function screenOnRoute(screenName, subPart) {
ViewType.Popup !== ViewModelClass.__vm.viewModelPosition ViewType.Popup !== ViewModelClass.__vm.viewModelPosition
) { ) {
ViewModelClass.__dom.hidden = true; ViewModelClass.__dom.hidden = true;
ViewModelClass.__vm.viewModelVisibility(false); ViewModelClass.__vm.viewModelVisible = false;
ViewModelClass.__vm.onHide && ViewModelClass.__vm.onHide(); ViewModelClass.__vm.onHide && ViewModelClass.__vm.onHide();
ViewModelClass.__vm.onHideWithDelay && setTimeout(()=>ViewModelClass.__vm.onHideWithDelay(), 500); ViewModelClass.__vm.onHideWithDelay && setTimeout(()=>ViewModelClass.__vm.onHideWithDelay(), 500);
@ -321,7 +320,7 @@ function screenOnRoute(screenName, subPart) {
ViewModelClass.__vm.onBeforeShow && ViewModelClass.__vm.onBeforeShow(); ViewModelClass.__vm.onBeforeShow && ViewModelClass.__vm.onBeforeShow();
ViewModelClass.__dom.hidden = false; ViewModelClass.__dom.hidden = false;
ViewModelClass.__vm.viewModelVisibility(true); ViewModelClass.__vm.viewModelVisible = true;
ViewModelClass.__vm.onShow && ViewModelClass.__vm.onShow(); ViewModelClass.__vm.onShow && ViewModelClass.__vm.onShow();
@ -334,10 +333,7 @@ function screenOnRoute(screenName, subPart) {
} }
// -- // --
cross = vmScreen && vmScreen.__cross ? vmScreen.__cross() : null; vmScreen && vmScreen.__cross && vmScreen.__cross.parse(subPart);
if (cross) {
cross.parse(subPart);
}
}, 1); }, 1);
} }
} }

View file

@ -1,6 +1,6 @@
import ko from 'ko'; import ko from 'ko';
import { StorageResultType, ServerSecure, Ports, Notification } from 'Common/Enums'; import { StorageResultType, ServerSecure, Notification } from 'Common/Enums';
import { pInt, pString } from 'Common/Utils'; import { pInt, pString } from 'Common/Utils';
import { i18n } from 'Common/Translator'; import { i18n } from 'Common/Translator';
@ -125,19 +125,19 @@ class DomainPopupView extends AbstractViewNext {
value && this.imapServer() && !this.smtpServer() && this.smtpServer(this.imapServer().replace(/imap/gi, 'smtp')) value && this.imapServer() && !this.smtpServer() && this.smtpServer(this.imapServer().replace(/imap/gi, 'smtp'))
); );
this.imapSecure.subscribe((value) => { this.imapSecure.subscribe(value => {
if (this.enableSmartPorts()) { if (this.enableSmartPorts()) {
const port = pInt(this.imapPort()); const port = pInt(this.imapPort());
switch (pString(value)) { switch (pString(value)) {
case '0': case '0':
case '2': case '2':
if (Ports.ImapSsl === port) { if (993 === port) {
this.imapPort(pString(Ports.Imap)); this.imapPort('143');
} }
break; break;
case '1': case '1':
if (Ports.Imap === port) { if (143 === port) {
this.imapPort(pString(Ports.ImapSsl)); this.imapPort('993');
} }
break; break;
// no default // no default
@ -145,23 +145,23 @@ class DomainPopupView extends AbstractViewNext {
} }
}); });
this.smtpSecure.subscribe((value) => { this.smtpSecure.subscribe(value => {
if (this.enableSmartPorts()) { if (this.enableSmartPorts()) {
const port = pInt(this.smtpPort()); const port = pInt(this.smtpPort());
switch (pString(value)) { switch (pString(value)) {
case '0': case '0':
if (Ports.SmtpSsl === port || Ports.SmtpStartTls === port) { if (465 === port || 587 === port) {
this.smtpPort(pString(Ports.Smtp)); this.smtpPort('25');
} }
break; break;
case '1': case '1':
if (Ports.Smtp === port || Ports.SmtpStartTls === port) { if (25 === port || 587 === port) {
this.smtpPort(pString(Ports.SmtpSsl)); this.smtpPort('465');
} }
break; break;
case '2': case '2':
if (Ports.Smtp === port || Ports.SmtpSsl === port) { if (25 === port || 465 === port) {
this.smtpPort(pString(Ports.SmtpStartTls)); this.smtpPort('587');
} }
break; break;
// no default // no default

View file

@ -82,7 +82,7 @@ class AbstractSystemDropDownUserView extends AbstractViewNext {
onBuild() { onBuild() {
shortcuts.add('`', '', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => { shortcuts.add('`', '', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
if (this.viewModelVisibility()) { if (this.viewModelVisible) {
MessageStore.messageFullScreenMode(false); MessageStore.messageFullScreenMode(false);
this.accountMenuDropdownTrigger(true); this.accountMenuDropdownTrigger(true);
} }
@ -90,7 +90,7 @@ class AbstractSystemDropDownUserView extends AbstractViewNext {
// shortcuts help // shortcuts help
shortcuts.add('/', 'shift', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => { shortcuts.add('/', 'shift', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
if (this.viewModelVisibility()) { if (this.viewModelVisible) {
showScreenPopup(require('View/Popup/KeyboardShortcutsHelp')); showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
return false; return false;
} }

View file

@ -872,7 +872,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
} }
prefetchNextTick() { prefetchNextTick() {
if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisibility()) { if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisible) {
const message = this.messageList().find( const message = this.messageList().find(
item => item && !hasRequestedMessage(item.folderFullNameRaw, item.uid) item => item && !hasRequestedMessage(item.folderFullNameRaw, item.uid)
); );

View file

@ -109,7 +109,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
this.showAttachmnetControls = ko.observable(false); this.showAttachmnetControls = ko.observable(false);
this.showAttachmnetControlsState = v => Local.set(ClientSideKeyName.MessageAttachmnetControls, !!v); this.showAttachmnetControlsState = v => Local.set(ClientSideKeyName.MessageAttachmentControls, !!v);
this.allowAttachmnetControls = ko.computed( this.allowAttachmnetControls = ko.computed(
() => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions) () => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions)
@ -220,7 +220,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
if (message) { if (message) {
this.showAttachmnetControls(false); this.showAttachmnetControls(false);
if (Local.get(ClientSideKeyName.MessageAttachmnetControls)) { if (Local.get(ClientSideKeyName.MessageAttachmentControls)) {
setTimeout(() => { setTimeout(() => {
this.showAttachmnetControls(true); this.showAttachmnetControls(true);
}, 50); }, 50);
@ -509,7 +509,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
* @returns {boolean} * @returns {boolean}
*/ */
escShortcuts() { escShortcuts() {
if (this.viewModelVisibility() && this.message()) { if (this.viewModelVisible && this.message()) {
const preview = Layout.NoPreview !== this.layout(); const preview = Layout.NoPreview !== this.layout();
if (this.fullScreenMode()) { if (this.fullScreenMode()) {
this.fullScreenMode(false); this.fullScreenMode(false);

2
vendors/jua/jua.js vendored
View file

@ -494,7 +494,7 @@
while (iLen--) while (iLen--)
fakeMd5 += '0123456789abcdefghijklmnopqrstuvwxyz'.substr(Math.round(Math.random() * 36), 1); fakeMd5 += '0123456789abcdefghijklmnopqrstuvwxyz'.substr(Math.round(Math.random() * 36), 1);
this.addFile('jua-uid-' + fakeMd5 + '-' + (new Date()).getTime().toString(), oFileInfo); this.addFile('jua-uid-' + fakeMd5 + '-' + (Date.now().toString()), oFileInfo);
} }
/** /**

File diff suppressed because one or more lines are too long

View file

@ -2341,7 +2341,6 @@ ko.exportSymbol('jsonExpressionRewriting.insertPropertyAccessorsIntoJson', ko.ex
var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/; var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
var endCommentRegex = /^\s*\/ko\s*$/; var endCommentRegex = /^\s*\/ko\s*$/;
var htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };
function isStartComment(node) { function isStartComment(node) {
return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue); return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue);
@ -2389,28 +2388,6 @@ ko.exportSymbol('jsonExpressionRewriting.insertPropertyAccessorsIntoJson', ko.ex
return null; // Must have no matching end comment, and allowUnbalanced is true return null; // Must have no matching end comment, and allowUnbalanced is true
} }
function getUnbalancedChildTags(node) {
// e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>
// from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->
var childNode = node.firstChild, captureRemaining = null;
if (childNode) {
do {
if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes
captureRemaining.push(childNode);
else if (isStartComment(childNode)) {
var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true);
if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set
childNode = matchingEndComment;
else
captureRemaining = [childNode]; // It's unbalanced, so start capturing from this point
} else if (isEndComment(childNode)) {
captureRemaining = [childNode]; // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing
}
} while (childNode = childNode.nextSibling);
}
return captureRemaining;
}
ko.virtualElements = { ko.virtualElements = {
allowedBindings: {}, allowedBindings: {},

View file

@ -9,7 +9,6 @@
var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/; var startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/;
var endCommentRegex = /^\s*\/ko\s*$/; var endCommentRegex = /^\s*\/ko\s*$/;
var htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };
function isStartComment(node) { function isStartComment(node) {
return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue); return (node.nodeType == 8) && startCommentRegex.test(node.nodeValue);
@ -57,28 +56,6 @@
return null; // Must have no matching end comment, and allowUnbalanced is true return null; // Must have no matching end comment, and allowUnbalanced is true
} }
function getUnbalancedChildTags(node) {
// e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>
// from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->
var childNode = node.firstChild, captureRemaining = null;
if (childNode) {
do {
if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes
captureRemaining.push(childNode);
else if (isStartComment(childNode)) {
var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true);
if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set
childNode = matchingEndComment;
else
captureRemaining = [childNode]; // It's unbalanced, so start capturing from this point
} else if (isEndComment(childNode)) {
captureRemaining = [childNode]; // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing
}
} while (childNode = childNode.nextSibling);
}
return captureRemaining;
}
ko.virtualElements = { ko.virtualElements = {
allowedBindings: {}, allowedBindings: {},