diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-05-27 19:33:28 +0200 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-05-29 21:25:28 +0200 |
commit | 4b38ac3bed78dfbd5159af37674c18a7ea5e69d5 (patch) | |
tree | 134bd6abc76cd009e0b2e4a6c7de39333e480765 /app/javascript/flavours/glitch/reducers/notifications.js | |
parent | 6020a211304a3c33cc311083b15edc3f08a13edc (diff) |
[Glitch] Fix comparing id
Port 0ba49eca8b49c6ce0ec04fd546951c95938da4e6 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/reducers/notifications.js')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/notifications.js | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js index 39ac03f21..dc820b476 100644 --- a/app/javascript/flavours/glitch/reducers/notifications.js +++ b/app/javascript/flavours/glitch/reducers/notifications.js @@ -18,6 +18,7 @@ import { } from 'flavours/glitch/actions/accounts'; import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from 'flavours/glitch/actions/timelines'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import compareId from 'flavours/glitch/util/compare_id'; const initialState = ImmutableMap({ items: ImmutableList(), @@ -54,13 +55,6 @@ const normalizeNotification = (state, notification) => { }); }; -const newer = (m, n) => { - const mId = m.get('id'); - const nId = n.get('id'); - - return mId.length === nId.length ? mId > nId : mId.length > nId.length; -}; - const expandNormalizedNotifications = (state, notifications, next) => { let items = ImmutableList(); @@ -72,11 +66,11 @@ const expandNormalizedNotifications = (state, notifications, next) => { if (!items.isEmpty()) { mutable.update('items', list => { const lastIndex = 1 + list.findLastIndex( - item => item !== null && (newer(item, items.last()) || item.get('id') === items.last().get('id')) + item => item !== null && (compareId(item.get('id'), items.last().get('id')) > 0 || item.get('id') === items.last().get('id')) ); const firstIndex = 1 + list.take(lastIndex).findLastIndex( - item => item !== null && newer(item, items.first()) + item => item !== null && compareId(item.get('id'), items.first().get('id')) > 0 ); return list.take(firstIndex).concat(items, list.skip(lastIndex)); |