From aa3bcfab382bbac8f45c24c67e6eef7c3e93fd98 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 26 May 2018 10:36:28 +0900 Subject: [PATCH] Compare tweet ids with bigint --- package.json | 1 + src/reducers/tabs-by-user-id.js | 3 ++- yarn.lock | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 91e7dd6..92cfab4 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ }, "dependencies": { "autolinker": "^0.19.0", + "big-integer": "^1.6.28", "moment": "^2.11.2", "node-twitter-api": "^1.6.0", "react": "^0.14.7", diff --git a/src/reducers/tabs-by-user-id.js b/src/reducers/tabs-by-user-id.js index 05b1bd7..27323d2 100644 --- a/src/reducers/tabs-by-user-id.js +++ b/src/reducers/tabs-by-user-id.js @@ -1,11 +1,12 @@ import Actions from '../actions'; +import bigInt from 'big-integer'; const MAX_TWEETS_FOR_EACH_TAB = 100; // Return set order by id DESC. const sortedAdd = (set, tweet) => { for (let i in set) { - let result = set[i].id_str.localeCompare(tweet.id_str); + let result = bigInt(set[i].id_str).compare(bigInt(tweet.id_str)); if (result == -1) { // If set[i].id_str is smaller than tweet.id_str, prepend tweet to set[i]. return [...set.slice(0, i), tweet, ...set.slice(i)]; diff --git a/yarn.lock b/yarn.lock index 862a8df..1842a36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -885,6 +885,10 @@ beeper@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" +big-integer@^1.6.28: + version "1.6.28" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.28.tgz#8cef0fda3ccde8759c2c66efcfacc35aea658283" + binary@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79"