diff options
author | Max Wu | 2018-03-03 16:25:30 +0800 |
---|---|---|
committer | Max Wu | 2018-03-03 16:26:19 +0800 |
commit | d08c9522c0dd414a6fed1671064701160d233603 (patch) | |
tree | d6ffeaadc516b2e75200a4d7e4f80fa2b5ab810e /public/js/history.js | |
parent | fe429e9ac17b73638835b2ec1c5033043c5f9942 (diff) |
Update to migrate note url in the history of browser storage and cookie
Signed-off-by: Max Wu <jackymaxj@gmail.com>
Diffstat (limited to 'public/js/history.js')
-rw-r--r-- | public/js/history.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/public/js/history.js b/public/js/history.js index e14b80d8..e7d289fb 100644 --- a/public/js/history.js +++ b/public/js/history.js @@ -3,6 +3,12 @@ import store from 'store' import S from 'string' +import LZString from 'lz-string' + +import { + checkNoteIdValid, + encodeNoteId +} from './utils' import { checkIfAuth @@ -291,6 +297,15 @@ function parseToHistory (list, notehistory, callback) { else if (!list || !notehistory) callback(list, notehistory) else if (notehistory && notehistory.length > 0) { for (let i = 0; i < notehistory.length; i++) { + // migrate LZString encoded id to base64url encoded id + try { + let id = LZString.decompressFromBase64(notehistory[i].id) + if (id && checkNoteIdValid(id)) { + notehistory[i].id = encodeNoteId(id) + } + } catch (err) { + // na + } // parse time to timestamp and fromNow const timestamp = (typeof notehistory[i].time === 'number' ? moment(notehistory[i].time) : moment(notehistory[i].time, 'MMMM Do YYYY, h:mm:ss a')) notehistory[i].timestamp = timestamp.valueOf() |