mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
Cleanup some code
This commit is contained in:
parent
b16b184ac9
commit
4645209053
3 changed files with 15 additions and 25 deletions
|
|
@ -520,8 +520,8 @@ class AppUser extends AbstractApp {
|
||||||
if (
|
if (
|
||||||
!iError &&
|
!iError &&
|
||||||
1 < arrayLength(data.Result) &&
|
1 < arrayLength(data.Result) &&
|
||||||
isPosNumeric(data.Result[0], true) &&
|
isPosNumeric(data.Result[0]) &&
|
||||||
isPosNumeric(data.Result[1], true)
|
isPosNumeric(data.Result[1])
|
||||||
) {
|
) {
|
||||||
QuotaUserStore.populateData(pInt(data.Result[1]), pInt(data.Result[0]));
|
QuotaUserStore.populateData(pInt(data.Result[1]), pInt(data.Result[0]));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import { createElement } from 'Common/Globals';
|
||||||
* @param {boolean=} includeZero = true
|
* @param {boolean=} includeZero = true
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function isPosNumeric(value, includeZero = true) {
|
export function isPosNumeric(value) {
|
||||||
return null != value && (includeZero ? /^[0-9]*$/ : /^[1-9]+[0-9]*$/).test(value.toString());
|
return null != value && /^[0-9]*$/.test(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -395,13 +395,13 @@ export function computedPaginatorHelper(koCurrentPage, koPageCount) {
|
||||||
if (3 === prev) {
|
if (3 === prev) {
|
||||||
fAdd(2, false);
|
fAdd(2, false);
|
||||||
} else if (3 < prev) {
|
} else if (3 < prev) {
|
||||||
fAdd(Math.round((prev - 1) / 2), false, '...');
|
fAdd(Math.round((prev - 1) / 2), false, '…');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pageCount - 2 === next) {
|
if (pageCount - 2 === next) {
|
||||||
fAdd(pageCount - 1, true);
|
fAdd(pageCount - 1, true);
|
||||||
} else if (pageCount - 2 > next) {
|
} else if (pageCount - 2 > next) {
|
||||||
fAdd(Math.round((pageCount + next) / 2), true, '...');
|
fAdd(Math.round((pageCount + next) / 2), true, '…');
|
||||||
}
|
}
|
||||||
|
|
||||||
// first and last
|
// first and last
|
||||||
|
|
@ -434,22 +434,20 @@ export function mailToHelper(mailToUrl) {
|
||||||
mailToUrl = mailToUrl.toString().substr(7);
|
mailToUrl = mailToUrl.toString().substr(7);
|
||||||
|
|
||||||
let to = [],
|
let to = [],
|
||||||
cc = null,
|
|
||||||
bcc = null,
|
|
||||||
params = {};
|
params = {};
|
||||||
|
|
||||||
const email = mailToUrl.replace(/\?.+$/, ''),
|
const email = mailToUrl.replace(/\?.+$/, ''),
|
||||||
query = mailToUrl.replace(/^[^?]*\?/, '');
|
query = mailToUrl.replace(/^[^?]*\?/, ''),
|
||||||
|
toEmailModel = value => null != value ? EmailModel.parseEmailLine(decodeURIComponent(value)) : null;
|
||||||
|
|
||||||
query.split('&').forEach(temp => {
|
query.split('&').forEach(temp => {
|
||||||
temp = temp.split('=');
|
temp = temp.split('=');
|
||||||
params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
|
params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (undefined !== params.to) {
|
if (null != params.to) {
|
||||||
to = EmailModel.parseEmailLine(decodeURIComponent(email + ',' + params.to));
|
|
||||||
to = Object.values(
|
to = Object.values(
|
||||||
to.reduce((result, value) => {
|
toEmailModel(email + ',' + params.to).reduce((result, value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
if (result[value.email]) {
|
if (result[value.email]) {
|
||||||
if (!result[value.email].name) {
|
if (!result[value.email].name) {
|
||||||
|
|
@ -466,20 +464,12 @@ export function mailToHelper(mailToUrl) {
|
||||||
to = EmailModel.parseEmailLine(email);
|
to = EmailModel.parseEmailLine(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (undefined !== params.cc) {
|
|
||||||
cc = EmailModel.parseEmailLine(decodeURIComponent(params.cc));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (undefined !== params.bcc) {
|
|
||||||
bcc = EmailModel.parseEmailLine(decodeURIComponent(params.bcc));
|
|
||||||
}
|
|
||||||
|
|
||||||
showMessageComposer([
|
showMessageComposer([
|
||||||
ComposeType.Empty,
|
ComposeType.Empty,
|
||||||
null,
|
null,
|
||||||
to,
|
to,
|
||||||
cc,
|
toEmailModel(params.cc),
|
||||||
bcc,
|
toEmailModel(params.bcc),
|
||||||
null == params.subject ? null : decodeURIComponent(params.subject),
|
null == params.subject ? null : decodeURIComponent(params.subject),
|
||||||
null == params.body ? null : plainToHtml(decodeURIComponent(params.body))
|
null == params.body ? null : plainToHtml(decodeURIComponent(params.body))
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ export class FolderModel extends AbstractModel {
|
||||||
folder.messageCountAll = ko.computed({
|
folder.messageCountAll = ko.computed({
|
||||||
read: folder.privateMessageCountAll,
|
read: folder.privateMessageCountAll,
|
||||||
write: (iValue) => {
|
write: (iValue) => {
|
||||||
if (isPosNumeric(iValue, true)) {
|
if (isPosNumeric(iValue)) {
|
||||||
folder.privateMessageCountAll(iValue);
|
folder.privateMessageCountAll(iValue);
|
||||||
} else {
|
} else {
|
||||||
folder.privateMessageCountAll.valueHasMutated();
|
folder.privateMessageCountAll.valueHasMutated();
|
||||||
|
|
@ -238,7 +238,7 @@ export class FolderModel extends AbstractModel {
|
||||||
folder.messageCountUnread = ko.computed({
|
folder.messageCountUnread = ko.computed({
|
||||||
read: folder.privateMessageCountUnread,
|
read: folder.privateMessageCountUnread,
|
||||||
write: (value) => {
|
write: (value) => {
|
||||||
if (isPosNumeric(value, true)) {
|
if (isPosNumeric(value)) {
|
||||||
folder.privateMessageCountUnread(value);
|
folder.privateMessageCountUnread(value);
|
||||||
} else {
|
} else {
|
||||||
folder.privateMessageCountUnread.valueHasMutated();
|
folder.privateMessageCountUnread.valueHasMutated();
|
||||||
|
|
@ -371,6 +371,6 @@ export class FolderModel extends AbstractModel {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
printableFullName() {
|
printableFullName() {
|
||||||
return this.fullName.split(this.delimiter).join(' / ');
|
return this.fullName.replace(this.delimiter, ' / ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue