mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Improved knockout observables management to prevent memory leaks
This commit is contained in:
parent
b165a1de4f
commit
3eb6ab1ef7
46 changed files with 1020 additions and 1013 deletions
|
|
@ -37,17 +37,31 @@ class LoginUserView extends AbstractViewNext {
|
|||
|
||||
this.hideSubmitButton = Settings.app('hideSubmitButton');
|
||||
|
||||
this.welcome = ko.observable(!!Settings.get('UseLoginWelcomePage'));
|
||||
this.addObservables({
|
||||
welcome: !!Settings.get('UseLoginWelcomePage'),
|
||||
email: '',
|
||||
password: '',
|
||||
signMe: false,
|
||||
additionalCode: '',
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.signMe = ko.observable(false);
|
||||
emailError: false,
|
||||
passwordError: false,
|
||||
|
||||
this.additionalCode = ko.observable('');
|
||||
this.additionalCode.error = ko.observable(false);
|
||||
this.additionalCode.errorAnimation = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
this.additionalCode.visibility = ko.observable(false);
|
||||
this.additionalCodeSignMe = ko.observable(false);
|
||||
formHidden: false,
|
||||
|
||||
submitRequest: false,
|
||||
submitError: '',
|
||||
submitErrorAddidional: '',
|
||||
|
||||
langRequest: false,
|
||||
|
||||
additionalCodeError: false,
|
||||
additionalCodeSignMe: false,
|
||||
additionalCodeVisibility: false,
|
||||
signMeType: LoginSignMeType.Unused
|
||||
});
|
||||
|
||||
this.additionalCodeErrorAnimation = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
|
||||
this.logoImg = (Settings.get('LoginLogo')||'').trim();
|
||||
this.loginDescription = (Settings.get('LoginDescription')||'').trim();
|
||||
|
|
@ -58,61 +72,50 @@ class LoginUserView extends AbstractViewNext {
|
|||
this.forgotPasswordLinkUrl = Settings.app('forgotPasswordLinkUrl');
|
||||
this.registrationLinkUrl = Settings.app('registrationLinkUrl');
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.emailErrorAnimation = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
|
||||
this.formHidden = ko.observable(false);
|
||||
this.addComputables({
|
||||
formError:
|
||||
() =>
|
||||
this.emailErrorAnimation() ||
|
||||
this.passwordErrorAnimation() ||
|
||||
(this.additionalCodeVisibility() && this.additionalCodeErrorAnimation()),
|
||||
|
||||
this.formError = ko.computed(
|
||||
() =>
|
||||
this.emailErrorAnimation() ||
|
||||
this.passwordErrorAnimation() ||
|
||||
(this.additionalCode.visibility() && this.additionalCode.errorAnimation())
|
||||
);
|
||||
languageFullName: () => convertLangName(this.language()),
|
||||
|
||||
this.email.subscribe(() => {
|
||||
this.emailError(false);
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(false);
|
||||
signMeVisibility: () => LoginSignMeType.Unused !== this.signMeType()
|
||||
});
|
||||
|
||||
this.password.subscribe(() => this.passwordError(false));
|
||||
this.addSubscribables({
|
||||
email: () => {
|
||||
this.emailError(false);
|
||||
this.additionalCode('');
|
||||
this.additionalCodeVisibility(false);
|
||||
},
|
||||
|
||||
this.additionalCode.subscribe(() => this.additionalCode.error(false));
|
||||
password: () => this.passwordError(false),
|
||||
|
||||
this.additionalCode.visibility.subscribe(() => this.additionalCode.error(false));
|
||||
additionalCode: () => this.additionalCodeError(false),
|
||||
additionalCodeError: bV => this.additionalCodeErrorAnimation(!!bV),
|
||||
additionalCodeVisibility: () => this.additionalCodeError(false),
|
||||
|
||||
this.emailError.subscribe(bV => this.emailErrorAnimation(!!bV));
|
||||
emailError: bV => this.emailErrorAnimation(!!bV),
|
||||
|
||||
this.passwordError.subscribe(bV => this.passwordErrorAnimation(!!bV));
|
||||
passwordError: bV => this.passwordErrorAnimation(!!bV),
|
||||
|
||||
this.additionalCode.error.subscribe(bV => this.additionalCode.errorAnimation(!!bV));
|
||||
submitError: value => value || this.submitErrorAddidional(''),
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAddidional = ko.observable('');
|
||||
|
||||
this.submitError.subscribe(value => value || this.submitErrorAddidional(''));
|
||||
signMeType: iValue => this.signMe(LoginSignMeType.DefaultOn === iValue)
|
||||
});
|
||||
|
||||
this.allowLanguagesOnLogin = !!Settings.get('AllowLanguagesOnLogin');
|
||||
|
||||
this.langRequest = ko.observable(false);
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
|
||||
this.bSendLanguage = false;
|
||||
|
||||
this.languageFullName = ko.computed(() => convertLangName(this.language()));
|
||||
|
||||
this.signMeType = ko.observable(LoginSignMeType.Unused);
|
||||
|
||||
this.signMeType.subscribe(iValue => this.signMe(LoginSignMeType.DefaultOn === iValue));
|
||||
|
||||
this.signMeVisibility = ko.computed(() => LoginSignMeType.Unused !== this.signMeType());
|
||||
|
||||
if (Settings.get('AdditionalLoginError') && !this.submitError()) {
|
||||
this.submitError(Settings.get('AdditionalLoginError'));
|
||||
}
|
||||
|
|
@ -128,10 +131,10 @@ class LoginUserView extends AbstractViewNext {
|
|||
this.passwordError(false);
|
||||
|
||||
let error;
|
||||
if (this.additionalCode.visibility()) {
|
||||
this.additionalCode.error(false);
|
||||
if (this.additionalCodeVisibility()) {
|
||||
this.additionalCodeError(false);
|
||||
if (!this.additionalCode().trim()) {
|
||||
this.additionalCode.error(true);
|
||||
this.additionalCodeError(true);
|
||||
error = '.inputAdditionalCode';
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +160,7 @@ class LoginUserView extends AbstractViewNext {
|
|||
if (oData.Result) {
|
||||
if (oData.TwoFactorAuth) {
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(true);
|
||||
this.additionalCodeVisibility(true);
|
||||
this.submitRequest(false);
|
||||
|
||||
setTimeout(() => this.querySelector('.inputAdditionalCode').focus(), 100);
|
||||
|
|
@ -192,8 +195,8 @@ class LoginUserView extends AbstractViewNext {
|
|||
sLoginPassword,
|
||||
!!this.signMe(),
|
||||
this.bSendLanguage ? this.language() : '',
|
||||
this.additionalCode.visibility() ? this.additionalCode() : '',
|
||||
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
||||
this.additionalCodeVisibility() ? this.additionalCode() : '',
|
||||
this.additionalCodeVisibility() ? !!this.additionalCodeSignMe() : false
|
||||
);
|
||||
|
||||
Local.set(ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-');
|
||||
|
|
|
|||
|
|
@ -108,97 +108,87 @@ class MessageListMailBoxUserView extends AbstractViewNext {
|
|||
this.userUsageSize = QuotaStore.usage;
|
||||
this.userUsageProc = QuotaStore.percentage;
|
||||
|
||||
this.moveDropdownTrigger = ko.observable(false);
|
||||
this.moreDropdownTrigger = ko.observable(false);
|
||||
this.addObservables({
|
||||
moveDropdownTrigger: false,
|
||||
moreDropdownTrigger: false,
|
||||
|
||||
dragOverArea: null,
|
||||
dragOverBodyArea: null,
|
||||
|
||||
inputMessageListSearchFocus: false
|
||||
});
|
||||
|
||||
// append drag and drop
|
||||
this.dragOver = ko.observable(false).extend({ 'throttle': 1 });
|
||||
this.dragOverEnter = ko.observable(false).extend({ 'throttle': 1 });
|
||||
this.dragOverArea = ko.observable(null);
|
||||
this.dragOverBodyArea = ko.observable(null);
|
||||
|
||||
this.messageListItemTemplate = ko.computed(() =>
|
||||
this.mobile || Layout.SidePreview === SettingsStore.layout()
|
||||
? 'MailMessageListItem'
|
||||
: 'MailMessageListItemNoPreviewPane'
|
||||
);
|
||||
|
||||
this.messageListSearchDesc = ko.computed(() => {
|
||||
const value = MessageStore.messageListEndSearch();
|
||||
return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : '';
|
||||
});
|
||||
|
||||
this.messageListPaginator = ko.computed(
|
||||
computedPaginatorHelper(MessageStore.messageListPage, MessageStore.messageListPageCount)
|
||||
);
|
||||
|
||||
this.checkAll = ko.computed({
|
||||
read: () => 0 < MessageStore.messageListChecked().length,
|
||||
write: (value) => {
|
||||
value = !!value;
|
||||
MessageStore.messageList().forEach(message => message.checked(value));
|
||||
}
|
||||
});
|
||||
|
||||
this.inputMessageListSearchFocus = ko.observable(false);
|
||||
|
||||
this.sLastSearchValue = '';
|
||||
this.inputProxyMessageListSearch = ko.computed({
|
||||
read: this.mainMessageListSearch,
|
||||
write: value => this.sLastSearchValue = value
|
||||
|
||||
this.addComputables({
|
||||
messageListItemTemplate: () =>
|
||||
this.mobile || Layout.SidePreview === SettingsStore.layout()
|
||||
? 'MailMessageListItem'
|
||||
: 'MailMessageListItemNoPreviewPane',
|
||||
|
||||
messageListSearchDesc: () => {
|
||||
const value = MessageStore.messageListEndSearch();
|
||||
return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : ''
|
||||
},
|
||||
|
||||
messageListPaginator: computedPaginatorHelper(MessageStore.messageListPage, MessageStore.messageListPageCount),
|
||||
|
||||
checkAll: {
|
||||
read: () => 0 < MessageStore.messageListChecked().length,
|
||||
write: (value) => {
|
||||
value = !!value;
|
||||
MessageStore.messageList().forEach(message => message.checked(value));
|
||||
}
|
||||
},
|
||||
|
||||
inputProxyMessageListSearch: {
|
||||
read: this.mainMessageListSearch,
|
||||
write: value => this.sLastSearchValue = value
|
||||
},
|
||||
|
||||
isIncompleteChecked: () => {
|
||||
const c = MessageStore.messageListChecked().length;
|
||||
return c && MessageStore.messageList().length > c;
|
||||
},
|
||||
|
||||
hasMessages: () => 0 < this.messageList().length,
|
||||
|
||||
hasCheckedOrSelectedLines: () => 0 < this.messageListCheckedOrSelected().length,
|
||||
|
||||
isSpamFolder: () => FolderStore.spamFolder() === this.messageListEndFolder() && FolderStore.spamFolder(),
|
||||
|
||||
isSpamDisabled: () => UNUSED_OPTION_VALUE === FolderStore.spamFolder(),
|
||||
|
||||
isTrashFolder: () => FolderStore.trashFolder() === this.messageListEndFolder() && FolderStore.trashFolder(),
|
||||
|
||||
isDraftFolder: () => FolderStore.draftFolder() === this.messageListEndFolder() && FolderStore.draftFolder(),
|
||||
|
||||
isSentFolder: () => FolderStore.sentFolder() === this.messageListEndFolder() && FolderStore.sentFolder(),
|
||||
|
||||
isArchiveFolder: () => FolderStore.archiveFolder() === this.messageListEndFolder() && FolderStore.archiveFolder(),
|
||||
|
||||
isArchiveDisabled: () => UNUSED_OPTION_VALUE === FolderStore.archiveFolder(),
|
||||
|
||||
isArchiveVisible: () => !this.isArchiveFolder() && !this.isArchiveDisabled() && !this.isDraftFolder(),
|
||||
|
||||
isSpamVisible: () =>
|
||||
!this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder(),
|
||||
|
||||
isUnSpamVisible: () =>
|
||||
this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder(),
|
||||
|
||||
mobileCheckedStateShow: () => this.mobile ? 0 < MessageStore.messageListChecked().length : true,
|
||||
|
||||
mobileCheckedStateHide: () => this.mobile ? !MessageStore.messageListChecked().length : true,
|
||||
|
||||
messageListFocused: () => Focused.MessageList === AppStore.focusedState()
|
||||
});
|
||||
|
||||
this.isIncompleteChecked = ko.computed(() => {
|
||||
const c = MessageStore.messageListChecked().length;
|
||||
return c && MessageStore.messageList().length > c;
|
||||
});
|
||||
|
||||
this.hasMessages = ko.computed(() => 0 < this.messageList().length);
|
||||
|
||||
this.hasCheckedOrSelectedLines = ko.computed(() => 0 < this.messageListCheckedOrSelected().length);
|
||||
|
||||
this.isSpamFolder = ko.computed(
|
||||
() => FolderStore.spamFolder() === this.messageListEndFolder() && FolderStore.spamFolder()
|
||||
);
|
||||
|
||||
this.isSpamDisabled = ko.computed(() => UNUSED_OPTION_VALUE === FolderStore.spamFolder());
|
||||
|
||||
this.isTrashFolder = ko.computed(
|
||||
() => FolderStore.trashFolder() === this.messageListEndFolder() && FolderStore.trashFolder()
|
||||
);
|
||||
|
||||
this.isDraftFolder = ko.computed(
|
||||
() => FolderStore.draftFolder() === this.messageListEndFolder() && FolderStore.draftFolder()
|
||||
);
|
||||
|
||||
this.isSentFolder = ko.computed(
|
||||
() => FolderStore.sentFolder() === this.messageListEndFolder() && FolderStore.sentFolder()
|
||||
);
|
||||
|
||||
this.isArchiveFolder = ko.computed(
|
||||
() => FolderStore.archiveFolder() === this.messageListEndFolder() && FolderStore.archiveFolder()
|
||||
);
|
||||
|
||||
this.isArchiveDisabled = ko.computed(() => UNUSED_OPTION_VALUE === FolderStore.archiveFolder());
|
||||
|
||||
this.isArchiveVisible = ko.computed(
|
||||
() => !this.isArchiveFolder() && !this.isArchiveDisabled() && !this.isDraftFolder()
|
||||
);
|
||||
|
||||
this.isSpamVisible = ko.computed(
|
||||
() => !this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder()
|
||||
);
|
||||
|
||||
this.isUnSpamVisible = ko.computed(
|
||||
() => this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder()
|
||||
);
|
||||
|
||||
// this.messageListChecked = MessageStore.messageListChecked;
|
||||
this.mobileCheckedStateShow = ko.computed(() => this.mobile ? 0 < MessageStore.messageListChecked().length : true);
|
||||
|
||||
this.mobileCheckedStateHide = ko.computed(() => this.mobile ? !MessageStore.messageListChecked().length : true);
|
||||
|
||||
this.messageListFocused = ko.computed(() => Focused.MessageList === AppStore.focusedState());
|
||||
|
||||
this.canBeMoved = this.hasCheckedOrSelectedLines;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
import { $htmlCL, leftPanelDisabled, keyScopeReal, moveAction } from 'Common/Globals';
|
||||
|
||||
import { inFocus } from 'Common/Utils';
|
||||
import { mailToHelper, isTransparent } from 'Common/UtilsUser';
|
||||
import { mailToHelper } from 'Common/UtilsUser';
|
||||
|
||||
import Audio from 'Common/Audio';
|
||||
|
||||
|
|
@ -40,6 +40,10 @@ import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
|||
|
||||
const Settings = rl.settings;
|
||||
|
||||
function isTransparent(color) {
|
||||
return 'rgba(0, 0, 0, 0)' === color || 'transparent' === color;
|
||||
}
|
||||
|
||||
@view({
|
||||
name: 'View/User/MailBox/MessageView',
|
||||
type: ViewType.Right,
|
||||
|
|
@ -67,7 +71,14 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
this.oHeaderDom = null;
|
||||
this.oMessageScrollerDom = null;
|
||||
|
||||
this.bodyBackgroundColor = ko.observable('');
|
||||
this.addObservables({
|
||||
bodyBackgroundColor: '',
|
||||
showAttachmnetControls: false,
|
||||
downloadAsZipLoading: false,
|
||||
lastReplyAction_: '',
|
||||
showFullInfo: '1' === Local.get(ClientSideKeyName.MessageHeaderFullInfo),
|
||||
moreDropdownTrigger: false
|
||||
});
|
||||
|
||||
this.pswp = null;
|
||||
|
||||
|
|
@ -103,50 +114,12 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
this.messageListOfThreadsLoading = ko.observable(false).extend({ rateLimit: 1 });
|
||||
this.highlightUnselectedAttachments = ko.observable(false).extend({ falseTimeout: 2000 });
|
||||
|
||||
this.showAttachmnetControls = ko.observable(false);
|
||||
|
||||
this.showAttachmnetControlsState = v => Local.set(ClientSideKeyName.MessageAttachmentControls, !!v);
|
||||
|
||||
this.allowAttachmnetControls = ko.computed(
|
||||
() => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions)
|
||||
);
|
||||
|
||||
this.downloadAsZipAllowed = ko.computed(
|
||||
() => this.attachmentsActions().includes('zip') && this.allowAttachmnetControls()
|
||||
);
|
||||
|
||||
this.downloadAsZipLoading = ko.observable(false);
|
||||
this.downloadAsZipError = ko.observable(false).extend({ falseTimeout: 7000 });
|
||||
|
||||
this.showAttachmnetControls.subscribe(v => this.message()
|
||||
&& this.message().attachments().forEach(item => item && item.checked(!!v))
|
||||
);
|
||||
|
||||
this.lastReplyAction_ = ko.observable('');
|
||||
this.lastReplyAction = ko.computed({
|
||||
read: this.lastReplyAction_,
|
||||
write: value => this.lastReplyAction_(
|
||||
[ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward].includes(value)
|
||||
? ComposeType.Reply
|
||||
: value
|
||||
)
|
||||
});
|
||||
|
||||
this.lastReplyAction(Local.get(ClientSideKeyName.LastReplyAction) || ComposeType.Reply);
|
||||
|
||||
this.lastReplyAction_.subscribe(value => Local.set(ClientSideKeyName.LastReplyAction, value));
|
||||
|
||||
this.showFullInfo = ko.observable('1' === Local.get(ClientSideKeyName.MessageHeaderFullInfo));
|
||||
|
||||
this.moreDropdownTrigger = ko.observable(false);
|
||||
this.messageDomFocused = ko.observable(false).extend({ rateLimit: 0 });
|
||||
|
||||
this.messageVisibility = ko.computed(() => !this.messageLoadingThrottle() && !!this.message());
|
||||
|
||||
this.message.subscribe(message => (!message) && MessageStore.selectorMessageSelected(null));
|
||||
|
||||
this.canBeRepliedOrForwarded = ko.computed(() => !this.isDraftFolder() && this.messageVisibility());
|
||||
|
||||
// commands
|
||||
this.replyCommand = createCommandReplyHelper(ComposeType.Reply);
|
||||
this.replyAllCommand = createCommandReplyHelper(ComposeType.ReplyAll);
|
||||
|
|
@ -162,97 +135,85 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
|
||||
// viewer
|
||||
|
||||
this.viewBodyTopValue = ko.observable(0);
|
||||
|
||||
this.viewFolder = '';
|
||||
this.viewUid = '';
|
||||
this.viewHash = '';
|
||||
this.viewSubject = ko.observable('');
|
||||
this.viewFromShort = ko.observable('');
|
||||
this.viewFromDkimData = ko.observable(['none', '']);
|
||||
this.viewToShort = ko.observable('');
|
||||
this.viewFrom = ko.observable('');
|
||||
this.viewTo = ko.observable('');
|
||||
this.viewCc = ko.observable('');
|
||||
this.viewBcc = ko.observable('');
|
||||
this.viewReplyTo = ko.observable('');
|
||||
this.viewTimeStamp = ko.observable(0);
|
||||
this.viewSize = ko.observable('');
|
||||
this.viewLineAsCss = ko.observable('');
|
||||
this.viewViewLink = ko.observable('');
|
||||
this.viewUnsubscribeLink = ko.observable('');
|
||||
this.viewDownloadLink = ko.observable('');
|
||||
this.viewIsImportant = ko.observable(false);
|
||||
this.viewIsFlagged = ko.observable(false);
|
||||
|
||||
this.viewFromDkimVisibility = ko.computed(() => 'none' !== this.viewFromDkimData()[0]);
|
||||
|
||||
this.viewFromDkimStatusIconClass = ko.computed(() => {
|
||||
switch (this.viewFromDkimData()[0]) {
|
||||
case 'none':
|
||||
return 'icon-none iconcolor-display-none';
|
||||
case 'pass':
|
||||
return 'icon-ok iconcolor-green';
|
||||
default:
|
||||
return 'icon-warning-alt iconcolor-red';
|
||||
}
|
||||
this.addObservables({
|
||||
viewBodyTopValue: 0,
|
||||
viewSubject: '',
|
||||
viewFromShort: '',
|
||||
viewFromDkimData: ['none', ''],
|
||||
viewToShort: '',
|
||||
viewFrom: '',
|
||||
viewTo: '',
|
||||
viewCc: '',
|
||||
viewBcc: '',
|
||||
viewReplyTo: '',
|
||||
viewTimeStamp: 0,
|
||||
viewSize: '',
|
||||
viewLineAsCss: '',
|
||||
viewViewLink: '',
|
||||
viewUnsubscribeLink: '',
|
||||
viewDownloadLink: '',
|
||||
viewIsImportant: false,
|
||||
viewIsFlagged: false
|
||||
});
|
||||
|
||||
this.viewFromDkimStatusTitle = ko.computed(() => {
|
||||
const status = this.viewFromDkimData();
|
||||
if (Array.isNotEmpty(status)) {
|
||||
if (status[0]) {
|
||||
return status[1] || 'DKIM: ' + status[0];
|
||||
}
|
||||
}
|
||||
this.addSubscribables({
|
||||
showAttachmnetControls: v => this.message()
|
||||
&& this.message().attachments().forEach(item => item && item.checked(!!v)),
|
||||
|
||||
return '';
|
||||
});
|
||||
lastReplyAction_: value => Local.set(ClientSideKeyName.LastReplyAction, value),
|
||||
|
||||
this.messageActiveDom.subscribe(dom => this.bodyBackgroundColor(this.detectDomBackgroundColor(dom)), this);
|
||||
messageActiveDom: dom => this.bodyBackgroundColor(this.detectDomBackgroundColor(dom)),
|
||||
|
||||
this.message.subscribe((message) => {
|
||||
this.messageActiveDom(null);
|
||||
message: message => {
|
||||
this.messageActiveDom(null);
|
||||
|
||||
if (message) {
|
||||
this.showAttachmnetControls(false);
|
||||
if (Local.get(ClientSideKeyName.MessageAttachmentControls)) {
|
||||
setTimeout(() => {
|
||||
this.showAttachmnetControls(true);
|
||||
}, 50);
|
||||
}
|
||||
if (message) {
|
||||
this.showAttachmnetControls(false);
|
||||
if (Local.get(ClientSideKeyName.MessageAttachmentControls)) {
|
||||
setTimeout(() => {
|
||||
this.showAttachmnetControls(true);
|
||||
}, 50);
|
||||
}
|
||||
|
||||
if (this.viewHash !== message.hash) {
|
||||
this.scrollMessageToTop();
|
||||
}
|
||||
|
||||
this.viewFolder = message.folder;
|
||||
this.viewUid = message.uid;
|
||||
this.viewHash = message.hash;
|
||||
this.viewSubject(message.subject());
|
||||
this.viewFromShort(message.fromToLine(true, true));
|
||||
this.viewFromDkimData(message.fromDkimData());
|
||||
this.viewToShort(message.toToLine(true, true));
|
||||
this.viewFrom(message.fromToLine(false));
|
||||
this.viewTo(message.toToLine(false));
|
||||
this.viewCc(message.ccToLine(false));
|
||||
this.viewBcc(message.bccToLine(false));
|
||||
this.viewReplyTo(message.replyToToLine(false));
|
||||
this.viewTimeStamp(message.dateTimeStampInUTC());
|
||||
this.viewSize(message.friendlySize());
|
||||
this.viewLineAsCss(message.lineAsCss());
|
||||
this.viewViewLink(message.viewLink());
|
||||
this.viewUnsubscribeLink(message.getFirstUnsubsribeLink());
|
||||
this.viewDownloadLink(message.downloadLink());
|
||||
this.viewIsImportant(message.isImportant());
|
||||
this.viewIsFlagged(message.isFlagged());
|
||||
} else {
|
||||
MessageStore.selectorMessageSelected(null);
|
||||
|
||||
this.viewFolder = '';
|
||||
this.viewUid = '';
|
||||
this.viewHash = '';
|
||||
|
||||
if (this.viewHash !== message.hash) {
|
||||
this.scrollMessageToTop();
|
||||
}
|
||||
},
|
||||
|
||||
this.viewFolder = message.folder;
|
||||
this.viewUid = message.uid;
|
||||
this.viewHash = message.hash;
|
||||
this.viewSubject(message.subject());
|
||||
this.viewFromShort(message.fromToLine(true, true));
|
||||
this.viewFromDkimData(message.fromDkimData());
|
||||
this.viewToShort(message.toToLine(true, true));
|
||||
this.viewFrom(message.fromToLine(false));
|
||||
this.viewTo(message.toToLine(false));
|
||||
this.viewCc(message.ccToLine(false));
|
||||
this.viewBcc(message.bccToLine(false));
|
||||
this.viewReplyTo(message.replyToToLine(false));
|
||||
this.viewTimeStamp(message.dateTimeStampInUTC());
|
||||
this.viewSize(message.friendlySize());
|
||||
this.viewLineAsCss(message.lineAsCss());
|
||||
this.viewViewLink(message.viewLink());
|
||||
this.viewUnsubscribeLink(message.getFirstUnsubsribeLink());
|
||||
this.viewDownloadLink(message.downloadLink());
|
||||
this.viewIsImportant(message.isImportant());
|
||||
this.viewIsFlagged(message.isFlagged());
|
||||
} else {
|
||||
this.viewFolder = '';
|
||||
this.viewUid = '';
|
||||
this.viewHash = '';
|
||||
|
||||
this.scrollMessageToTop();
|
||||
}
|
||||
fullScreenMode: value => $htmlCL.toggle('rl-message-fullscreen', value)
|
||||
});
|
||||
|
||||
this.message.viewTrigger.subscribe(() => {
|
||||
|
|
@ -260,13 +221,55 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
|
|||
message ? this.viewIsFlagged(message.isFlagged()) : this.viewIsFlagged(false);
|
||||
});
|
||||
|
||||
this.fullScreenMode.subscribe(value => $htmlCL.toggle('rl-message-fullscreen', value));
|
||||
this.addComputables({
|
||||
allowAttachmnetControls: () => this.attachmentsActions().length && Settings.capa(Capa.AttachmentsActions),
|
||||
|
||||
this.messageFocused = ko.computed(() => Focused.MessageView === AppStore.focusedState());
|
||||
downloadAsZipAllowed: () => this.attachmentsActions().includes('zip') && this.allowAttachmnetControls(),
|
||||
|
||||
this.messageListAndMessageViewLoading = ko.computed(
|
||||
() => MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle()
|
||||
);
|
||||
lastReplyAction: {
|
||||
read: this.lastReplyAction_,
|
||||
write: value => this.lastReplyAction_(
|
||||
[ComposeType.Reply, ComposeType.ReplyAll, ComposeType.Forward].includes(value)
|
||||
? ComposeType.Reply
|
||||
: value
|
||||
)
|
||||
},
|
||||
|
||||
messageVisibility: () => !this.messageLoadingThrottle() && !!this.message(),
|
||||
|
||||
canBeRepliedOrForwarded: () => !this.isDraftFolder() && this.messageVisibility(),
|
||||
|
||||
viewFromDkimVisibility: () => 'none' !== this.viewFromDkimData()[0],
|
||||
|
||||
viewFromDkimStatusIconClass:() => {
|
||||
switch (this.viewFromDkimData()[0]) {
|
||||
case 'none':
|
||||
return 'icon-none iconcolor-display-none';
|
||||
case 'pass':
|
||||
return 'icon-ok iconcolor-green';
|
||||
default:
|
||||
return 'icon-warning-alt iconcolor-red';
|
||||
}
|
||||
},
|
||||
|
||||
viewFromDkimStatusTitle:() => {
|
||||
const status = this.viewFromDkimData();
|
||||
if (Array.isNotEmpty(status)) {
|
||||
if (status[0]) {
|
||||
return status[1] || 'DKIM: ' + status[0];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
messageFocused: () => Focused.MessageView === AppStore.focusedState(),
|
||||
|
||||
messageListAndMessageViewLoading:
|
||||
() => MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle()
|
||||
});
|
||||
|
||||
this.lastReplyAction(Local.get(ClientSideKeyName.LastReplyAction) || ComposeType.Reply);
|
||||
|
||||
addEventListener('mailbox.message-view.toggle-full-screen', () => this.toggleFullScreen());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue