this.addObservables() to addObservablesTo()

This commit is contained in:
the-djmaze 2022-10-30 22:19:52 +01:00
parent 839ebfb350
commit 7fac6ca9dd
30 changed files with 78 additions and 58 deletions

View file

@ -1,5 +1,6 @@
import { fireEvent } from 'Common/Globals';
import { getNotification } from 'Common/Translator';
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
import Remote from 'Remote/Admin/Fetch';
@ -10,7 +11,7 @@ export class AdminLoginView extends AbstractViewLogin {
constructor() {
super('AdminLogin');
this.addObservables({
addObservablesTo(this, {
login: '',
password: '',
totp: '',
@ -22,7 +23,7 @@ export class AdminLoginView extends AbstractViewLogin {
submitError: ''
});
this.addSubscribables({
addSubscribablesTo(this, {
login: () => this.loginError(false),
password: () => this.passwordError(false)
});

View file

@ -1,3 +1,4 @@
import { addObservablesTo } from 'External/ko';
import { getNotification } from 'Common/Translator';
import Remote from 'Remote/User/Fetch';
@ -8,7 +9,7 @@ export class AccountPopupView extends AbstractViewPopup {
constructor() {
super('Account');
this.addObservables({
addObservablesTo(this, {
isNew: true,
email: '',

View file

@ -1,3 +1,4 @@
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { i18n, translateTrigger } from 'Common/Translator';
import { pString } from 'Common/Utils';
@ -10,7 +11,7 @@ export class AdvancedSearchPopupView extends AbstractViewPopup {
constructor() {
super('AdvancedSearch');
this.addObservables({
addObservablesTo(this, {
from: '',
to: '',
subject: '',
@ -25,7 +26,7 @@ export class AdvancedSearchPopupView extends AbstractViewPopup {
unseen: false
});
this.addComputables({
addComputablesTo(this, {
showMultisearch: () => FolderUserStore.hasCapability('MULTISEARCH'),
// Almost the same as MessageModel.tagOptions

View file

@ -1,13 +1,13 @@
import { i18n } from 'Common/Translator';
import { isFunction } from 'Common/Utils';
import { addObservablesTo } from 'External/ko';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
export class AskPopupView extends AbstractViewPopup {
constructor() {
super('Ask');
this.addObservables({
addObservablesTo(this, {
askDesc: '',
yesButton: '',
noButton: '',

View file

@ -13,7 +13,7 @@ import {
import { pInt, isArray, arrayLength, forEachObjectEntry } from 'Common/Utils';
import { encodeHtml, HtmlEditor, htmlToPlain } from 'Common/Html';
import { koArrayWithDestroy } from 'External/ko';
import { koArrayWithDestroy, addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { folderInformation, messagesDeleteHelper } from 'Common/Folders';
@ -215,7 +215,7 @@ export class ComposePopupView extends AbstractViewPopup {
this.allowContacts = AppUserStore.allowContacts();
this.allowIdentities = SettingsCapa('Identities');
this.addObservables({
addObservablesTo(this, {
identitiesDropdownTrigger: false,
from: '',
@ -304,7 +304,7 @@ export class ComposePopupView extends AbstractViewPopup {
this.iTimer = 0;
this.addComputables({
addComputablesTo(this, {
sendButtonSuccess: () => !this.sendError() && !this.sendSuccessButSaveError(),
savedTimeText: () =>
@ -344,7 +344,7 @@ export class ComposePopupView extends AbstractViewPopup {
canBeSentOrSaved: () => !this.sending() && !this.saving()
});
this.addSubscribables({
addSubscribablesTo(this, {
sendError: value => !value && this.sendErrorDesc(''),
savedError: value => !value && this.savedErrorDesc(''),

View file

@ -1,3 +1,4 @@
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { ComposeType } from 'Common/EnumsUser';
import { registerShortcut } from 'Common/Globals';
import { arrayLength, pInt } from 'Common/Utils';
@ -32,7 +33,7 @@ export class ContactsPopupView extends AbstractViewPopup {
constructor() {
super('Contacts');
this.addObservables({
addObservablesTo(this, {
search: '',
contactsCount: 0,
@ -64,7 +65,7 @@ export class ContactsPopupView extends AbstractViewPopup {
this.selector.on('ItemGetUid', contact => contact ? contact.generateUid() : '');
this.addComputables({
addComputablesTo(this, {
contactsPaginator: computedPaginatorHelper(
this.contactsPage,
() => Math.max(1, Math.ceil(this.contactsCount() / CONTACTS_PER_PAGE))

View file

@ -1,3 +1,5 @@
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
import { pInt, forEachObjectEntry } from 'Common/Utils';
import { i18n, getNotification } from 'Common/Translator';
@ -33,8 +35,8 @@ export class DomainPopupView extends AbstractViewPopup {
constructor() {
super('Domain');
this.addObservables(this.getDefaults());
this.addObservables({
addObservablesTo(this, this.getDefaults());
addObservablesTo(this, {
edit: false,
saving: false,
@ -53,7 +55,7 @@ export class DomainPopupView extends AbstractViewPopup {
smtpHostFocus: false,
});
this.addComputables({
addComputablesTo(this, {
headerText: () => {
const name = this.name(),
aliasName = this.aliasName();
@ -96,7 +98,7 @@ export class DomainPopupView extends AbstractViewPopup {
canBeSaved: () => !this.saving() && this.domainIsComputed()
});
this.addSubscribables({
addSubscribablesTo(this, {
testingImapError: value => value || this.testingImapErrorDesc(''),
testingSieveError: value => value || this.testingSieveErrorDesc(''),
testingSmtpError: value => value || this.testingSmtpErrorDesc(''),

View file

@ -1,4 +1,5 @@
import { getNotification } from 'Common/Translator';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { DomainAdminStore } from 'Stores/Admin/Domain';
@ -11,7 +12,7 @@ export class DomainAliasPopupView extends AbstractViewPopup {
constructor() {
super('DomainAlias');
this.addObservables({
addObservablesTo(this, {
saving: false,
savingError: '',
@ -20,7 +21,7 @@ export class DomainAliasPopupView extends AbstractViewPopup {
alias: ''
});
this.addComputables({
addComputablesTo(this, {
domains: () => DomainAdminStore.filter(item => item && !item.alias),
domainsOptions: () => this.domains().map(item => ({ optValue: item.name, optText: item.name })),

View file

@ -1,3 +1,4 @@
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { i18n, getNotification } from 'Common/Translator';
import { MessageUserStore } from 'Stores/User/Message';
@ -12,12 +13,12 @@ export class FolderClearPopupView extends AbstractViewPopup {
constructor() {
super('FolderClear');
this.addObservables({
addObservablesTo(this, {
folder: null,
clearing: false
});
this.addComputables({
addComputablesTo(this, {
dangerDescHtml: () => {
// const folder = this.folder();
// return i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { FOLDER: folder.fullName.replace(folder.delimiter, ' / ') });

View file

@ -1,4 +1,4 @@
import { koComputable } from 'External/ko';
import { koComputable, addObservablesTo } from 'External/ko';
import { Notification } from 'Common/Enums';
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
@ -20,7 +20,7 @@ export class FolderCreatePopupView extends AbstractViewPopup {
constructor() {
super('FolderCreate');
this.addObservables({
addObservablesTo(this, {
folderName: '',
folderSubscribe: SettingsUserStore.hideUnsubscribed(),

View file

@ -1,3 +1,5 @@
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
import { getNotification } from 'Common/Translator';
import Remote from 'Remote/User/Fetch';
@ -9,7 +11,7 @@ export class IdentityPopupView extends AbstractViewPopup {
super('Identity');
this.id = '';
this.addObservables({
addObservablesTo(this, {
edit: false,
owner: false,
@ -35,7 +37,7 @@ export class IdentityPopupView extends AbstractViewPopup {
submitError: ''
});
this.addSubscribables({
addSubscribablesTo(this, {
replyTo: value => {
if (false === this.showReplyTo() && value.length) {
this.showReplyTo(true);

View file

@ -1,3 +1,4 @@
import { addObservablesTo } from 'External/ko';
//import { pInt } from 'Common/Utils';
import { GnuPGUserStore } from 'Stores/User/GnuPG';
@ -15,7 +16,7 @@ export class OpenPgpGeneratePopupView extends AbstractViewPopup {
this.identities = IdentityUserStore;
this.addObservables({
addObservablesTo(this, {
email: '',
emailError: false,

View file

@ -1,3 +1,4 @@
import { addObservablesTo } from 'External/ko';
import { GnuPGUserStore } from 'Stores/User/GnuPG';
import { OpenPGPUserStore } from 'Stores/User/OpenPGP';
@ -7,7 +8,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
constructor() {
super('OpenPgpImport');
this.addObservables({
addObservablesTo(this, {
key: '',
keyError: false,
keyErrorMessage: '',

View file

@ -1,3 +1,4 @@
import { addObservablesTo } from 'External/ko';
import { doc, addShortcut } from 'Common/Globals';
import { AbstractViewPopup } from 'Knoin/AbstractViews';
@ -5,7 +6,7 @@ export class OpenPgpKeyPopupView extends AbstractViewPopup {
constructor() {
super('OpenPgpKey');
this.addObservables({
addObservablesTo(this, {
key: '',
keyDom: null
});

View file

@ -1,4 +1,5 @@
import ko from 'ko';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { getNotification, i18n } from 'Common/Translator';
import { arrayLength } from 'Common/Utils';
@ -13,7 +14,7 @@ export class PluginPopupView extends AbstractViewPopup {
constructor() {
super('Plugin');
this.addObservables({
addObservablesTo(this, {
saveError: '',
id: '',
name: '',
@ -22,7 +23,7 @@ export class PluginPopupView extends AbstractViewPopup {
this.config = ko.observableArray();
this.addComputables({
addComputablesTo(this, {
hasReadme: () => !!this.readme(),
hasConfiguration: () => 0 < this.config().length
});

View file

@ -2,6 +2,7 @@ import { Notification } from 'Common/Enums';
import { ClientSideKeyNameLastSignMe } from 'Common/EnumsUser';
import { SettingsGet, fireEvent } from 'Common/Globals';
import { getNotification, translatorReload, convertLangName } from 'Common/Translator';
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
import { LanguageStore } from 'Stores/Language';
@ -24,7 +25,7 @@ export class LoginUserView extends AbstractViewLogin {
constructor() {
super();
this.addObservables({
addObservablesTo(this, {
loadingDesc: SettingsGet('LoadingDescription'),
email: SettingsGet('DevEmail'),
@ -50,14 +51,14 @@ export class LoginUserView extends AbstractViewLogin {
this.bSendLanguage = false;
this.addComputables({
addComputablesTo(this, {
languageFullName: () => convertLangName(this.language()),
signMeVisibility: () => SignMeUnused !== this.signMeType()
});
this.addSubscribables({
addSubscribablesTo(this, {
email: () => this.emailError(false),
password: () => this.passwordError(false),

View file

@ -1,4 +1,5 @@
import ko from 'ko';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { Scope } from 'Common/Enums';
@ -89,7 +90,7 @@ export class MailMessageList extends AbstractViewRight {
this.userUsageProc = FolderUserStore.quotaPercentage;
this.addObservables({
addObservablesTo(this, {
moreDropdownTrigger: false,
sortDropdownTrigger: false,
@ -100,7 +101,7 @@ export class MailMessageList extends AbstractViewRight {
this.dragOver = ko.observable(false).extend({ throttle: 1 });
this.dragOverEnter = ko.observable(false).extend({ throttle: 1 });
this.addComputables({
addComputablesTo(this, {
sortSupported: () =>
FolderUserStore.hasCapability('SORT') | FolderUserStore.hasCapability('ESORT'),

View file

@ -1,4 +1,5 @@
import ko from 'ko';
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
import { Scope } from 'Common/Enums';
@ -92,7 +93,7 @@ export class MailMessageView extends AbstractViewRight {
this.msgDefaultAction = SettingsUserStore.msgDefaultAction;
this.addObservables({
addObservablesTo(this, {
showAttachmentControls: !!Local.get(ClientSideKeyNameMessageAttachmentControls),
downloadAsZipLoading: false,
showFullInfo: '1' === Local.get(ClientSideKeyNameMessageHeaderFullInfo),
@ -132,7 +133,7 @@ export class MailMessageView extends AbstractViewRight {
// viewer
this.viewHash = '';
this.addComputables({
addComputablesTo(this, {
allowAttachmentControls: () => arrayLength(attachmentsActions) && SettingsCapa('AttachmentsActions'),
downloadAsZipAllowed: () => this.attachmentsActions.includes('zip')
@ -174,7 +175,7 @@ export class MailMessageView extends AbstractViewRight {
() => MessagelistUserStore.isLoading() | MessageUserStore.loading()
});
this.addSubscribables({
addSubscribablesTo(this, {
message: message => {
if (message) {
if (this.viewHash !== message.hash) {

View file

@ -20,6 +20,7 @@ import Remote from 'Remote/User/Fetch';
import { getNotification } from 'Common/Translator';
//import { clearCache } from 'Common/Cache';
//import { koComputable } from 'External/ko';
import { addObservablesTo } from 'External/ko';
export class SystemDropDownUserView extends AbstractViewRight {
constructor() {
@ -36,7 +37,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
this.accountsUnreadCount = : koComputable(() => AccountUserStore.accounts().reduce((result, item) => result + item.count(), 0));
*/
this.addObservables({
addObservablesTo(this, {
currentAudio: '',
accountMenuDropdownTrigger: false
});