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,6 +1,5 @@
import { SaveSettingStatus } from 'Common/Enums';
import { koComputable } from 'External/ko';
import { dispose } from 'External/ko';
import { dispose, koComputable } from 'External/ko';
import { defaultOptionsAfterRender } from 'Common/Utils';
export class SelectComponent {

View File

@@ -1,4 +1,5 @@
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo } from 'External/ko';
export class AccountModel extends AbstractModel {
/**
@@ -11,7 +12,7 @@ export class AccountModel extends AbstractModel {
this.email = email;
this.addObservables({
addObservablesTo(this, {
// count: count || 0,
askDelete: false,
isAdditional: isAdditional

View File

@@ -7,6 +7,7 @@ import {
} from 'Common/Links';
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo } from 'External/ko';
import { SMAudio } from 'Common/Audio';
@@ -30,7 +31,7 @@ export class AttachmentModel extends AbstractModel {
this.mimeIndex = '';
this.estimatedSize = 0;
this.addObservables({
addObservablesTo(this, {
isInline: false,
isLinked: false
});

View File

@@ -1,6 +1,7 @@
import { FileInfo } from 'Common/File';
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo, addComputablesTo } from 'External/ko';
export class ComposeAttachmentModel extends AbstractModel {
/**
@@ -22,7 +23,7 @@ export class ComposeAttachmentModel extends AbstractModel {
this.contentLocation = contentLocation;
this.fromMessage = false;
this.addObservables({
addObservablesTo(this, {
fileName: fileName,
size: size,
tempName: '',
@@ -35,7 +36,7 @@ export class ComposeAttachmentModel extends AbstractModel {
complete: false
});
this.addComputables({
addComputablesTo(this, {
progressText: () => {
const p = this.progress();
return 1 > p ? '' : (100 < p ? 100 : p) + '%';

View File

@@ -1,4 +1,5 @@
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { JCard } from 'DAV/JCard';
//import { VCardProperty } from 'DAV/VCardProperty';
@@ -80,7 +81,7 @@ export class ContactModel extends AbstractModel {
this.jCard = ['vcard',[]];
this.addObservables({
addObservablesTo(this, {
// Also used by Selector
focused: false,
selected: false,
@@ -113,7 +114,7 @@ export class ContactModel extends AbstractModel {
this.url = ko.observableArray();
this.adr = ko.observableArray();
this.addComputables({
addComputablesTo(this, {
fullName: () => [this.namePrefix(), this.givenName(), this.middleName(), this.surName()].join(' ').trim(),
display: () => {

View File

@@ -18,7 +18,7 @@ import { i18n, translateTrigger } from 'Common/Translator';
import { AbstractModel } from 'Knoin/AbstractModel';
import { koComputable } from 'External/ko';
import { koComputable, addObservablesTo } from 'External/ko';
//import { mailBox } from 'Common/Links';
@@ -234,7 +234,7 @@ export class FolderModel extends AbstractModel {
// this.id = null;
this.uidNext = null;
this.addObservables({
addObservablesTo(this, {
name: '',
type: FolderType.User,
selectable: false,

View File

@@ -1,4 +1,5 @@
import { AbstractModel } from 'Knoin/AbstractModel';
import { addObservablesTo } from 'External/ko';
export class IdentityModel extends AbstractModel {
/**
@@ -8,7 +9,7 @@ export class IdentityModel extends AbstractModel {
constructor(id, email) {
super();
this.addObservables({
addObservablesTo(this, {
id: id || '',
email: email,
name: '',

View File

@@ -7,6 +7,7 @@ import { doc, SettingsGet } from 'Common/Globals';
import { encodeHtml, plainToHtml, htmlToPlain, cleanHtml } from 'Common/Html';
import { arrayLength, forEachObjectEntry } from 'Common/Utils';
import { serverRequestRaw, proxy } from 'Common/Links';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { FolderUserStore, isAllowedKeyword } from 'Stores/User/Folder';
import { SettingsUserStore } from 'Stores/User/Settings';
@@ -65,7 +66,7 @@ export class MessageModel extends AbstractModel {
this._reset();
this.addObservables({
addObservablesTo(this, {
subject: '',
plain: '',
html: '',
@@ -108,7 +109,7 @@ export class MessageModel extends AbstractModel {
this.unsubsribeLinks = ko.observableArray();
this.flags = ko.observableArray();
this.addComputables({
addComputablesTo(this, {
attachmentIconClass: () => FileInfo.getAttachmentsIconClass(this.attachments()),
threadsLen: () => this.threads().length,
listAttachments: () => this.attachments()

View File

@@ -1,10 +1,9 @@
import ko from 'ko';
import { koComputable } from 'External/ko';
import { koComputable, addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
import { FolderType } from 'Common/EnumsUser';
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { forEachObjectEntry } from 'Common/Utils';
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache';
import { Settings, SettingsCapa } from 'Common/Globals';
//import Remote from 'Remote/User/Fetch'; // Circular dependency

View File

@@ -1,11 +1,10 @@
import { koComputable } from 'External/ko';
import { koComputable, addObservablesTo, addComputablesTo } from 'External/ko';
import { SMAudio } from 'Common/Audio';
import { Notification } from 'Common/Enums';
import { MessageSetAction } from 'Common/EnumsUser';
import { $htmlCL } from 'Common/Globals';
import { arrayLength, pInt, pString } from 'Common/Utils';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import {

View File

@@ -1,9 +1,8 @@
import ko from 'ko';
import { koComputable } from 'External/ko';
import { koComputable, addObservablesTo } from 'External/ko';
import { Layout } from 'Common/EnumsUser';
import { pInt } from 'Common/Utils';
import { addObservablesTo } from 'External/ko';
import { $htmlCL, SettingsGet, fireEvent } from 'Common/Globals';
import { ThemeStore } from 'Stores/Theme';

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
});