diff options
| author | tusooa <tusooa@kazv.moe> | 2022-11-24 22:16:42 +0000 |
|---|---|---|
| committer | tusooa <tusooa@kazv.moe> | 2022-11-24 22:16:42 +0000 |
| commit | 2e3d4d772835b5de8750db2e8669c1abc4903994 (patch) | |
| tree | 4d61dcb7008c79aeb994294467f5a44085d364b6 /src | |
| parent | da94c94fbe95a183476fd2b71efc45c95e945b9c (diff) | |
| parent | 15124319735f3bf0cb384edb95a0060f902ccc63 (diff) | |
Merge branch 'fix-leaky-journal' into 'develop'
fix leaky journal by running uniq on addToCollection entries
Closes #1214
See merge request pleroma/pleroma-fe!1687
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/serverSideStorage.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/modules/serverSideStorage.js b/src/modules/serverSideStorage.js index 56164be7..c933ce8d 100644 --- a/src/modules/serverSideStorage.js +++ b/src/modules/serverSideStorage.js @@ -1,5 +1,5 @@ import { toRaw } from 'vue' -import { isEqual, cloneDeep, set, get, clamp, flatten, groupBy, findLastIndex, takeRight } from 'lodash' +import { isEqual, cloneDeep, set, get, clamp, flatten, groupBy, findLastIndex, takeRight, uniqWith } from 'lodash' import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js' export const VERSION = 1 @@ -149,12 +149,21 @@ const _mergeJournal = (...journals) => { if (path.startsWith('collections')) { const lastRemoveIndex = findLastIndex(journal, ({ operation }) => operation === 'removeFromCollection') // everything before last remove is unimportant + let remainder if (lastRemoveIndex > 0) { - return journal.slice(lastRemoveIndex) + remainder = journal.slice(lastRemoveIndex) } else { // everything else doesn't need trimming - return journal + remainder = journal } + return uniqWith(remainder, (a, b) => { + if (a.path !== b.path) { return false } + if (a.operation !== b.operation) { return false } + if (a.operation === 'addToCollection') { + return a.args[0] === b.args[0] + } + return false + }) } else if (path.startsWith('simple')) { // Only the last record is important return takeRight(journal) |
