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

@ -80,23 +80,23 @@ Things might work in Edge 18, Firefox 50-62 and Chrome 54-68 due to one polyfill
|js/* |1.14.0 |native | |js/* |1.14.0 |native |
|----------- |--------: |--------: | |----------- |--------: |--------: |
|admin.js |2.130.942 |1.056.416 | |admin.js |2.130.942 |1.056.405 |
|app.js |4.184.455 |2.727.475 | |app.js |4.184.455 |2.712.755 |
|boot.js | 671.522 | 43.856 | |boot.js | 671.522 | 43.856 |
|libs.js | 647.614 | 317.218 | |libs.js | 647.614 | 317.218 |
|polyfills.js | 325.834 | 0 | |polyfills.js | 325.834 | 0 |
|TOTAL |7.960.367 |4.144.965 | |TOTAL |7.960.367 |4.130.234 |
|js/min/* |1.14.0 |native |gzip 1.14 |gzip | |js/min/* |1.14.0 |native |gzip 1.14 |gzip |
|--------------- |--------: |--------: |--------: |--------: | |--------------- |--------: |--------: |--------: |--------: |
|admin.min.js | 252.147 | 144.091 | 73.657 | 41.256 | |admin.min.js | 252.147 | 144.090 | 73.657 | 41.258 |
|app.min.js | 511.202 | 365.966 |140.462 | 96.362 | |app.min.js | 511.202 | 364.533 |140.462 | 95.741 |
|boot.min.js | 66.007 | 5.579 | 22.567 | 2.328 | |boot.min.js | 66.007 | 5.579 | 22.567 | 2.328 |
|libs.min.js | 572.545 | 300.771 |176.720 | 92.928 | |libs.min.js | 572.545 | 300.771 |176.720 | 92.928 |
|polyfills.min.js | 32.452 | 0 | 11.312 | 0 | |polyfills.min.js | 32.452 | 0 | 11.312 | 0 |
|TOTAL |1.434.353 | 816.407 |424.718 |232.874 | |TOTAL |1.434.353 | 814.973 |424.718 |232.255 |
617.946 bytes (191.844 gzip) is not much, but it feels faster. 619.380 bytes (192.463 gzip) is not much, but it feels faster.
|css/* |1.14.0 |native | |css/* |1.14.0 |native |

View file

@ -17,7 +17,6 @@ import {
} from 'Common/Cache'; } from 'Common/Cache';
import { subQueryPrefix } from 'Common/Links'; import { subQueryPrefix } from 'Common/Links';
import * as Base64 from 'Common/Base64';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';
import AppStore from 'Stores/User/App'; import AppStore from 'Stores/User/App';
@ -27,6 +26,14 @@ import { getApp } from 'Helper/Apps/User';
import { AbstractAjaxRemote } from 'Remote/AbstractAjax'; 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 { class RemoteUserAjax extends AbstractAjaxRemote {
constructor() { constructor() {
super(); super();
@ -315,19 +322,17 @@ class RemoteUserAjax extends AbstractAjaxRemote {
'MessageList/' + 'MessageList/' +
subQueryPrefix() + subQueryPrefix() +
'/' + '/' +
Base64.urlsafe_encode( urlsafeArray([
[ sFolderFullNameRaw,
sFolderFullNameRaw, iOffset,
iOffset, iLimit,
iLimit, sSearch,
sSearch, AppStore.projectHash(),
AppStore.projectHash(), folderHash,
folderHash, inboxUidNext,
inboxUidNext, useThreads ? 1 : 0,
useThreads ? 1 : 0, useThreads ? sThreadUid : ''
useThreads ? sThreadUid : '' ]),
].join(String.fromCharCode(0))
),
bSilent ? [] : ['MessageList'] bSilent ? [] : ['MessageList']
); );
} }
@ -384,14 +389,12 @@ class RemoteUserAjax extends AbstractAjaxRemote {
'Message/' + 'Message/' +
subQueryPrefix() + subQueryPrefix() +
'/' + '/' +
Base64.urlsafe_encode( urlsafeArray([
[ sFolderFullNameRaw,
sFolderFullNameRaw, iUid,
iUid, AppStore.projectHash(),
AppStore.projectHash(), AppStore.threadsAllowed() && SettingsStore.useThreads() ? 1 : 0
AppStore.threadsAllowed() && SettingsStore.useThreads() ? 1 : 0 ]),
].join(String.fromCharCode(0))
),
['Message'] ['Message']
); );