mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Merge branch 'master' into plugin-2fa
This commit is contained in:
commit
2064c1613b
41 changed files with 261 additions and 167 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { MessageSetAction } from 'Common/EnumsUser';
|
||||
import { isNonEmptyArray, pInt } from 'Common/Utils';
|
||||
import { arrayLength, pInt } from 'Common/Utils';
|
||||
|
||||
let FOLDERS_CACHE = {},
|
||||
FOLDERS_NAME_CACHE = {},
|
||||
|
|
@ -255,7 +255,7 @@ export class MessageFlagsCache
|
|||
* @param {Array} flags
|
||||
*/
|
||||
static storeByFolderAndUid(folder, uid, flags) {
|
||||
if (isNonEmptyArray(flags)) {
|
||||
if (arrayLength(flags)) {
|
||||
this.setFor(folder, uid, flags);
|
||||
}
|
||||
}
|
||||
|
|
@ -269,7 +269,7 @@ export class MessageFlagsCache
|
|||
let unread = 0;
|
||||
const flags = this.getFor(folder, uid);
|
||||
|
||||
if (isNonEmptyArray(flags)) {
|
||||
if (arrayLength(flags)) {
|
||||
if (flags[0]) {
|
||||
unread = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint key-spacing: 0 */
|
||||
/* eslint quote-props: 0 */
|
||||
|
||||
import { isNonEmptyArray } from 'Common/Utils';
|
||||
import { arrayLength } from 'Common/Utils';
|
||||
|
||||
const
|
||||
cache = {},
|
||||
|
|
@ -250,7 +250,7 @@ export const FileInfo = {
|
|||
* @returns {string}
|
||||
*/
|
||||
getCombinedIconClass: data => {
|
||||
if (isNonEmptyArray(data)) {
|
||||
if (arrayLength(data)) {
|
||||
let icons = data
|
||||
.map(item => item ? FileInfo.getIconClass(FileInfo.getExtension(item[0]), item[1]) : '')
|
||||
.validUnique();
|
||||
|
|
|
|||
|
|
@ -40,19 +40,18 @@ export const keyScope = (()=>{
|
|||
keyScope(keyScopeFake);
|
||||
}
|
||||
});
|
||||
return ko.computed({
|
||||
read: () => keyScopeFake,
|
||||
write: value => {
|
||||
return value => {
|
||||
if (value) {
|
||||
if (Scope.Menu !== value) {
|
||||
keyScopeFake = value;
|
||||
if (dropdownVisibility()) {
|
||||
value = Scope.Menu;
|
||||
}
|
||||
}
|
||||
|
||||
keyScopeReal(value);
|
||||
shortcuts.setScope(value);
|
||||
} else {
|
||||
return keyScopeFake;
|
||||
}
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
||||
keyScopeReal.subscribe(value => shortcuts.setScope(value));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { doc, elementById } from 'Common/Globals';
|
|||
|
||||
export const
|
||||
isArray = Array.isArray,
|
||||
isNonEmptyArray = array => isArray(array) && array.length,
|
||||
arrayLength = array => isArray(array) && array.length,
|
||||
isFunction = v => typeof v === 'function';
|
||||
|
||||
/**
|
||||
|
|
@ -116,7 +116,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
|
|||
}
|
||||
rl.fetchJSON(url, init)
|
||||
.then(data => {
|
||||
if (data && isArray(data) && 2 === data.length) {
|
||||
if (2 === arrayLength(data)) {
|
||||
themeStyle.textContent = data[1];
|
||||
themeStyle.dataset.href = url;
|
||||
themeStyle.dataset.theme = data[0];
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import { createElement } from 'Common/Globals';
|
|||
* @param {boolean=} includeZero = true
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isPosNumeric(value, includeZero = true) {
|
||||
return null != value && (includeZero ? /^[0-9]*$/ : /^[1-9]+[0-9]*$/).test(value.toString());
|
||||
export function isPosNumeric(value) {
|
||||
return null != value && /^[0-9]*$/.test(value.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -395,13 +395,13 @@ export function computedPaginatorHelper(koCurrentPage, koPageCount) {
|
|||
if (3 === prev) {
|
||||
fAdd(2, false);
|
||||
} else if (3 < prev) {
|
||||
fAdd(Math.round((prev - 1) / 2), false, '...');
|
||||
fAdd(Math.round((prev - 1) / 2), false, '…');
|
||||
}
|
||||
|
||||
if (pageCount - 2 === next) {
|
||||
fAdd(pageCount - 1, true);
|
||||
} else if (pageCount - 2 > next) {
|
||||
fAdd(Math.round((pageCount + next) / 2), true, '...');
|
||||
fAdd(Math.round((pageCount + next) / 2), true, '…');
|
||||
}
|
||||
|
||||
// first and last
|
||||
|
|
@ -434,22 +434,20 @@ export function mailToHelper(mailToUrl) {
|
|||
mailToUrl = mailToUrl.toString().substr(7);
|
||||
|
||||
let to = [],
|
||||
cc = null,
|
||||
bcc = null,
|
||||
params = {};
|
||||
|
||||
const email = mailToUrl.replace(/\?.+$/, ''),
|
||||
query = mailToUrl.replace(/^[^?]*\?/, '');
|
||||
query = mailToUrl.replace(/^[^?]*\?/, ''),
|
||||
toEmailModel = value => null != value ? EmailModel.parseEmailLine(decodeURIComponent(value)) : null;
|
||||
|
||||
query.split('&').forEach(temp => {
|
||||
temp = temp.split('=');
|
||||
params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
|
||||
});
|
||||
|
||||
if (undefined !== params.to) {
|
||||
to = EmailModel.parseEmailLine(decodeURIComponent(email + ',' + params.to));
|
||||
if (null != params.to) {
|
||||
to = Object.values(
|
||||
to.reduce((result, value) => {
|
||||
toEmailModel(email + ',' + params.to).reduce((result, value) => {
|
||||
if (value) {
|
||||
if (result[value.email]) {
|
||||
if (!result[value.email].name) {
|
||||
|
|
@ -466,20 +464,12 @@ export function mailToHelper(mailToUrl) {
|
|||
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([
|
||||
ComposeType.Empty,
|
||||
null,
|
||||
to,
|
||||
cc,
|
||||
bcc,
|
||||
toEmailModel(params.cc),
|
||||
toEmailModel(params.bcc),
|
||||
null == params.subject ? null : decodeURIComponent(params.subject),
|
||||
null == params.body ? null : plainToHtml(decodeURIComponent(params.body))
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue