Rename moment to time as it has nothing todo anymore with momentjs

Change some observables to static as they never change later
This commit is contained in:
the-djmaze 2024-02-05 01:15:05 +01:00
parent 673126ae8a
commit 2084913a4d
7 changed files with 65 additions and 65 deletions

View file

@ -144,7 +144,7 @@ export const
time = Date.parse(element.dateTime) / 1000;
}
let key = element.dataset.momentFormat;
let key = element.dataset.timeFormat;
if (key) {
element.textContent = timestampToString(time, key);
if ('FULL' !== key && 'FROMNOW' !== key) {

View file

@ -103,7 +103,7 @@ Object.assign(ko.bindingHandlers, {
}
},
moment: {
time: {
init: ttn,
update: ttn
},

View file

@ -56,42 +56,51 @@ export class MessageModel extends AbstractModel {
constructor() {
super();
this.folder = '';
this.uid = 0;
this.hash = '';
this.from = new EmailCollectionModel;
this.to = new EmailCollectionModel;
this.cc = new EmailCollectionModel;
this.bcc = new EmailCollectionModel;
this.sender = new EmailCollectionModel;
this.replyTo = new EmailCollectionModel;
this.deliveredTo = new EmailCollectionModel;
this.body = null;
this.draftInfo = [];
this.dkim = [];
this.spf = [];
this.dmarc = [];
this.messageId = '';
this.inReplyTo = '';
this.references = '';
this.autocrypt = {/*addr:'', 'prefer-encrypt':'nopreference', keydata:'BASE64'*/};
Object.assign(this, {
folder: '',
uid: 0,
hash: '',
from: new EmailCollectionModel,
to: new EmailCollectionModel,
cc: new EmailCollectionModel,
bcc: new EmailCollectionModel,
sender: new EmailCollectionModel,
replyTo: new EmailCollectionModel,
deliveredTo: new EmailCollectionModel,
body: null,
draftInfo: [],
dkim: [],
spf: [],
dmarc: [],
messageId: '',
inReplyTo: '',
references: '',
autocrypt: {/*addr:'', 'prefer-encrypt':'nopreference', keydata:'BASE64'*/},
hasVirus: null, // or boolean when scanned
priority: 3, // Normal
internalTimestamp: 0,
senderEmailsString: '',
senderClearEmailsString: '',
isSpam: false,
spamScore: 0,
spamResult: '',
size: 0,
readReceipt: '',
preview: null,
attachments: ko.observableArray(new AttachmentCollectionModel),
threads: ko.observableArray(),
threadUnseen: ko.observableArray(),
unsubsribeLinks: ko.observableArray(),
flags: ko.observableArray(),
headers: ko.observableArray(new MimeHeaderCollectionModel)
});
addObservablesTo(this, {
subject: '',
plain: '',
html: '',
preview: null,
size: 0,
spamScore: 0,
spamResult: '',
isSpam: false,
hasVirus: null, // or boolean when scanned
dateTimestamp: 0,
internalTimestamp: 0,
priority: 3, // Normal
senderEmailsString: '',
senderClearEmailsString: '',
deleted: false,
@ -111,20 +120,11 @@ export class MessageModel extends AbstractModel {
pgpEncrypted: null,
pgpDecrypted: false,
readReceipt: '',
// rfc8621
id: '',
// threadId: ''
});
this.attachments = ko.observableArray(new AttachmentCollectionModel);
this.threads = ko.observableArray();
this.threadUnseen = ko.observableArray();
this.unsubsribeLinks = ko.observableArray();
this.flags = ko.observableArray();
this.headers = ko.observableArray(new MimeHeaderCollectionModel);
addComputablesTo(this, {
attachmentIconClass: () =>
this.encrypted() ? 'icon-lock' : FileInfo.getAttachmentsIconClass(this.attachments()),
@ -199,23 +199,23 @@ export class MessageModel extends AbstractModel {
}
spamStatus() {
let spam = this.spamResult();
return spam ? i18n(this.isSpam() ? 'GLOBAL/SPAM' : 'GLOBAL/NOT_SPAM') + ': ' + spam : '';
let spam = this.spamResult;
return spam ? i18n(this.isSpam ? 'GLOBAL/SPAM' : 'GLOBAL/NOT_SPAM') + ': ' + spam : '';
}
/**
* @returns {string}
*/
friendlySize() {
return FileInfo.friendlySize(this.size());
return FileInfo.friendlySize(this.size);
}
computeSenderEmail() {
const list = this[
[FolderUserStore.sentFolder(), FolderUserStore.draftsFolder()].includes(this.folder) ? 'to' : 'from'
];
this.senderEmailsString(list.toString(true));
this.senderClearEmailsString(list.map(email => email?.email).filter(email => email).join(', '));
this.senderEmailsString = list.toString(true);
this.senderClearEmailsString = list.map(email => email?.email).filter(email => email).join(', ');
}
/**
@ -250,9 +250,9 @@ export class MessageModel extends AbstractModel {
|| headers.valueByName('X-Priority');
if (value) {
if (/[h12]/.test(value[0])) {
this.priority(1);
this.priority = 1;
} else if (/[l45]/.test(value[0])) {
this.priority(5);
this.priority = 5;
}
}
@ -264,13 +264,13 @@ export class MessageModel extends AbstractModel {
}
if (headers.valueByName('X-Virus')) {
this.hasVirus(true);
this.hasVirus = true;
}
if (value = headers.valueByName('X-Virus-Status')) {
if (value.includes('infected')) {
this.hasVirus(true);
this.hasVirus = true;
} else if (value.includes('clean')) {
this.hasVirus(false);
this.hasVirus = false;
}
}
/*
@ -301,7 +301,7 @@ export class MessageModel extends AbstractModel {
checked: this.checked(),
unseen: this.isUnseen(),
focused: this.focused(),
priorityHigh: this.priority() === 1,
priorityHigh: this.priority === 1,
withAttachments: !!this.attachments().length,
// hasChildrenMessage: 1 < this.threadsLen()
}, (key, value) => value && classes.push(key));
@ -368,7 +368,7 @@ export class MessageModel extends AbstractModel {
this.hasExternals(result.hasExternals);
this.hasImages(!!result.hasExternals);
body.innerHTML = result.html;
if (!this.isSpam() && FolderUserStore.spamFolder() != this.folder) {
if (!this.isSpam && FolderUserStore.spamFolder() != this.folder) {
if ('always' === SettingsUserStore.viewImages()) {
this.showExternalImages();
}

View file

@ -1194,7 +1194,7 @@ export class ComposePopupView extends AbstractViewPopup {
const attachment = new ComposeAttachmentModel(
message.requestHash,
message.subject() /*+ '-' + Jua.randomId()*/ + '.eml',
message.size()
message.size
);
attachment.fromMessage = true;
attachment.complete(true);

View file

@ -155,7 +155,7 @@ export class MailMessageView extends AbstractViewRight {
: ''
).join(' '),
askReadReceipt: () => currentMessage()?.readReceipt()
askReadReceipt: () => currentMessage()?.readReceipt
&& !(MessagelistUserStore.isDraftFolder() || MessagelistUserStore.isSentFolder())
&& !currentMessage()?.flags().includes('$mdnsent')
&& !currentMessage()?.flags().includes('\\answered'),
@ -526,7 +526,7 @@ export class MailMessageView extends AbstractViewRight {
*/
readReceipt() {
let oMessage = currentMessage()
if (oMessage.readReceipt()) {
if (oMessage.readReceipt) {
Remote.request('SendReadReceiptMessage', iError => {
if (!iError) {
oMessage.flags.push('$mdnsent');
@ -535,7 +535,7 @@ export class MailMessageView extends AbstractViewRight {
}, {
messageFolder: oMessage.folder,
messageUid: oMessage.uid,
readReceipt: oMessage.readReceipt(),
readReceipt: oMessage.readReceipt,
subject: i18n('READ_RECEIPT/SUBJECT', { SUBJECT: oMessage.subject() }),
plain: i18n('READ_RECEIPT/BODY', { 'READ-RECEIPT': AccountUserStore.email() })
});

View file

@ -144,7 +144,7 @@
<i data-bind="css: attachmentIconClass"></i>
</div>
<div class="sizeParent" data-bind="text: friendlySize()"></div>
<time data-bind="attr:{'data-moment-format':$root.timeFormat()}, moment: dateTimestamp"></time>
<time data-bind="attr:{'data-time-format':$root.timeFormat()}, time: dateTimestamp"></time>
</div>
</div>
<!-- /ko -->
@ -164,7 +164,7 @@
<i data-bind="css: attachmentIconClass"></i>
</div>
<div class="sizeParent" data-bind="text: friendlySize()"></div>
<time data-moment-format="AUTO" data-bind="moment: dateTimestamp"></time>
<time data-time-format="AUTO" data-bind="time: dateTimestamp"></time>
</div>
</div>
</div>

View file

@ -138,7 +138,7 @@
<div id="messageItem">
<div class="messageItemHeader" data-bind="if: message, i18nUpdate: message">
<div data-bind="hidden: showFullInfo">
<time class="date" data-moment-format="FULL" data-bind="visible: 0 < message().dateTimestamp(), moment: message().dateTimestamp()"></time>
<time class="date" data-time-format="FULL" data-bind="visible: 0 < message().dateTimestamp(), time: message().dateTimestamp()"></time>
<div class="informationShortWrp">
<div class="informationShort" data-bind="visible: message().to.length">
<span data-i18n="GLOBAL/TO"></span>:
@ -149,9 +149,9 @@
<span data-bind="text: message().cc"></span>
</div>
</div>
<div class="informationShort" data-bind="visible: message().spamResult()">
<div class="informationShort" data-bind="visible: message().spamResult">
<span data-i18n="MESSAGE/SPAM_SCORE"></span>:
<meter min="0" max="100" optimum="0" low="33" high="66" data-bind="value: message().spamScore(), attr:{ title: message().spamStatus() }"></meter>
<meter min="0" max="100" optimum="0" low="33" high="66" data-bind="value: message().spamScore, attr:{ title: message().spamStatus() }"></meter>
</div>
</div>
<div class="informationFull" data-bind="visible: showFullInfo, with: message">
@ -181,9 +181,9 @@
<tr data-bind="visible: dateTimestamp">
<td data-i18n="MESSAGE/LABEL_DATE"></td>
<td>
<time data-moment-format="FULL" data-bind="moment: dateTimestamp"></time>
<time data-time-format="FULL" data-bind="time: dateTimestamp"></time>
&nbsp;
(<time data-moment-format="FROMNOW" data-bind="moment: dateTimestamp"></time>)
(<time data-time-format="FROMNOW" data-bind="time: dateTimestamp"></time>)
</td>
</tr>
<tr data-bind="visible: spamResult">
@ -196,7 +196,7 @@
</tr>
</table>
</div>
<div class="hasVirus" data-bind="visible: message().hasVirus()" data-i18n="MESSAGE/HAS_VIRUS_WARNING"></div>
<div class="hasVirus" data-bind="visible: message().hasVirus" data-i18n="MESSAGE/HAS_VIRUS_WARNING"></div>
<!-- ko if: tagsAllowed -->
<div class="messageTags">
<span data-i18n="MESSAGE/TAGS"></span>: