瀏覽代碼

small bugfixes

Mike L 2 年之前
父節點
當前提交
616ce4a403
共有 2 個文件被更改,包括 10 次插入12 次删除
  1. 5 6
      dist/twitter.js
  2. 5 6
      src/twitter.ts

+ 5 - 6
dist/twitter.js

@@ -283,20 +283,20 @@ class default_1 {
             logger.debug(`pulling feed ${currentFeed}`);
             const promise = new Promise(resolve => {
                 let job = Promise.resolve();
-                let match = /https:\/\/twitter.com\/([^\/]+)\/lists\/([^\/]+)/.exec(currentFeed);
-                let id;
+                let id = lock.threads[currentFeed].id;
                 let endpoint;
+                let match = /https:\/\/twitter.com\/([^\/]+)\/lists\/([^\/]+)/.exec(currentFeed);
                 if (match) {
                     endpoint = 'listTweets';
                     if (match[1] === 'i') {
                         id = match[2];
                     }
-                    else {
+                    else if (id === undefined) {
                         job = job.then(() => this.client.v1.list({
                             owner_screen_name: match[1],
                             slug: match[2],
                         })).then(({ id_str }) => {
-                            id = id_str;
+                            lock.threads[currentFeed].id = id = id_str;
                         });
                     }
                 }
@@ -304,9 +304,8 @@ class default_1 {
                     match = /https:\/\/twitter.com\/([^\/]+)/.exec(currentFeed);
                     if (match) {
                         endpoint = 'userTimeline';
-                        id = lock.threads[currentFeed].id;
                         if (id === undefined) {
-                            job = job.then(() => this.queryUser(match[1])).then(userNameId => {
+                            job = job.then(() => this.queryUser(match[1].replace(/^@?(.*)$/, '$1'))).then(userNameId => {
                                 lock.threads[currentFeed].id = id = userNameId.split(':')[1];
                             });
                         }

+ 5 - 6
src/twitter.ts

@@ -470,30 +470,29 @@ export default class {
 
     const promise = new Promise<Tweet[]>(resolve => {
       let job = Promise.resolve();
-      let match = /https:\/\/twitter.com\/([^\/]+)\/lists\/([^\/]+)/.exec(currentFeed);
-      let id: string;
+      let id = lock.threads[currentFeed].id;
       let endpoint: Parameters<typeof this.get>[0];
 
+      let match = /https:\/\/twitter.com\/([^\/]+)\/lists\/([^\/]+)/.exec(currentFeed);
       if (match) {
         endpoint = 'listTweets';
         if (match[1] === 'i') {
           id = match[2];
-        } else {
+        } else if (id === undefined) {
           job = job.then(() => this.client.v1.list({
             owner_screen_name: match[1],
             slug: match[2],
           })).then(({id_str}) => {
-            id = id_str;
+            lock.threads[currentFeed].id = id = id_str;
           });
         }
       } else {
         match = /https:\/\/twitter.com\/([^\/]+)/.exec(currentFeed);
         if (match) {
           endpoint = 'userTimeline';
-          id = lock.threads[currentFeed].id;
           if (id === undefined) {
             job = job.then(() => this.queryUser(
-              match[1]
+              match[1].replace(/^@?(.*)$/, '$1')
             )).then(userNameId => {
               lock.threads[currentFeed].id = id = userNameId.split(':')[1];
             });