|
@@ -279,7 +279,7 @@ class default_1 {
|
|
|
config.since_id = offset;
|
|
|
if (offset < -1)
|
|
|
config.max_id = offset.slice(1);
|
|
|
- const getMore = (gotTweets = []) => this.client.get(endpoint, config, (error, tweets) => {
|
|
|
+ const getMore = (lastTweets = []) => this.client.get(endpoint, config, (error, tweets) => {
|
|
|
if (error) {
|
|
|
if (error instanceof Array && error.length > 0 && error[0].code === 34) {
|
|
|
logger.warn(`error on fetching tweets for ${currentFeed}: ${JSON.stringify(error)}`);
|
|
@@ -292,10 +292,12 @@ class default_1 {
|
|
|
logger.error(`unhandled error on fetching tweets for ${currentFeed}: ${JSON.stringify(error)}`);
|
|
|
}
|
|
|
}
|
|
|
- if (!tweets || tweets.length <= 1)
|
|
|
- return resolve(gotTweets);
|
|
|
- config.max_id = tweets.slice(-1)[0].id_str;
|
|
|
- getMore(gotTweets.concat(tweets));
|
|
|
+ if (!(tweets instanceof Array) || tweets.length === 0)
|
|
|
+ return resolve(lastTweets);
|
|
|
+ if (offset <= 0)
|
|
|
+ return resolve(lastTweets.concat(tweets));
|
|
|
+ config.max_id = utils_1.BigNumOps.plus(tweets.slice(-1)[0].id_str, '-1');
|
|
|
+ getMore(lastTweets.concat(tweets));
|
|
|
});
|
|
|
getMore();
|
|
|
}
|
|
@@ -305,7 +307,7 @@ class default_1 {
|
|
|
const currentThread = lock.threads[currentFeed];
|
|
|
const setOffset = (offset) => currentThread.offset = offset;
|
|
|
const updateDate = () => currentThread.updatedAt = new Date().toString();
|
|
|
- if (!tweets || tweets.length === 0) {
|
|
|
+ if (tweets.length === 0) {
|
|
|
if (currentThread.offset < -1) {
|
|
|
setOffset(utils_1.BigNumOps.plus('1', currentThread.offset));
|
|
|
}
|