Common/Base64.js not needed, see simple Remote/User/Ajax.js urlsafeArray()

Although unescape() is "deprecated" it is still ECMAScript defined, and TextEncoder not supported by Edge.
This commit is contained in:
djmaze 2020-08-19 22:23:28 +02:00
parent 578925c904
commit 5d402f6405
2 changed files with 32 additions and 29 deletions

View file

@ -17,7 +17,6 @@ import {
} from 'Common/Cache';
import { subQueryPrefix } from 'Common/Links';
import * as Base64 from 'Common/Base64';
import * as Settings from 'Storage/Settings';
import AppStore from 'Stores/User/App';
@ -27,6 +26,14 @@ import { getApp } from 'Helper/Apps/User';
import { AbstractAjaxRemote } from 'Remote/AbstractAjax';
//const toUTF8 = window.TextEncoder
// ? text => String.fromCharCode(...new TextEncoder().encode(text))
// : text => unescape(encodeURIComponent(text)),
const urlsafeArray = array => btoa(unescape(encodeURIComponent(array.join(0x00).replace(/\r\n/g, '\n'))))
.replace('+', '-')
.replace('/', '_')
.replace('=', '');
class RemoteUserAjax extends AbstractAjaxRemote {
constructor() {
super();
@ -315,19 +322,17 @@ class RemoteUserAjax extends AbstractAjaxRemote {
'MessageList/' +
subQueryPrefix() +
'/' +
Base64.urlsafe_encode(
[
sFolderFullNameRaw,
iOffset,
iLimit,
sSearch,
AppStore.projectHash(),
folderHash,
inboxUidNext,
useThreads ? 1 : 0,
useThreads ? sThreadUid : ''
].join(String.fromCharCode(0))
),
urlsafeArray([
sFolderFullNameRaw,
iOffset,
iLimit,
sSearch,
AppStore.projectHash(),
folderHash,
inboxUidNext,
useThreads ? 1 : 0,
useThreads ? sThreadUid : ''
]),
bSilent ? [] : ['MessageList']
);
}
@ -384,14 +389,12 @@ class RemoteUserAjax extends AbstractAjaxRemote {
'Message/' +
subQueryPrefix() +
'/' +
Base64.urlsafe_encode(
[
sFolderFullNameRaw,
iUid,
AppStore.projectHash(),
AppStore.threadsAllowed() && SettingsStore.useThreads() ? 1 : 0
].join(String.fromCharCode(0))
),
urlsafeArray([
sFolderFullNameRaw,
iUid,
AppStore.projectHash(),
AppStore.threadsAllowed() && SettingsStore.useThreads() ? 1 : 0
]),
['Message']
);