فهرست منبع

add NextShareBlocks

zahmis 5 سال پیش
والد
کامیت
f2f8fa4d22
1فایلهای تغییر یافته به همراه45 افزوده شده و 49 حذف شده
  1. 45 49
      src/server/service/bolt.js

+ 45 - 49
src/server/service/bolt.js

@@ -248,66 +248,62 @@ class BoltService {
 
     const keywordsAndDesc = `keyword(s) : "${keywords}" \n ${searchResultsDesc}.`;
 
+    let NextShareBlocks;
     try {
       if (resultsTotal <= offset + PAGINGLIMIT) {
-        await this.client.chat.postEphemeral({
-          channel: command.channel_id,
-          user: command.user_id,
-          blocks: [
-            this.generateMarkdownSectionBlock(keywordsAndDesc),
-            this.generateMarkdownSectionBlock(`${urls.join('\n')}`),
+        NextShareBlocks = {
+          type: 'actions',
+          elements: [
             {
-              type: 'actions',
-              elements: [
-                {
-                  type: 'button',
-                  text: {
-                    type: 'plain_text',
-                    text: 'Share',
-                  },
-                  style: 'primary',
-                  action_id: 'shareSearchResults',
-                  value: `${keywordsAndDesc} \n\n ${urls.join('\n')}`,
-                },
-              ],
+              type: 'button',
+              text: {
+                type: 'plain_text',
+                text: 'Share',
+              },
+              style: 'primary',
+              action_id: 'shareSearchResults',
+              value: `${keywordsAndDesc} \n\n ${urls.join('\n')}`,
             },
           ],
-        });
+        };
       }
       else {
-        await this.client.chat.postEphemeral({
-          channel: command.channel_id,
-          user: command.user_id,
-          blocks: [
-            this.generateMarkdownSectionBlock(keywordsAndDesc),
-            this.generateMarkdownSectionBlock(`${urls.join('\n')}`),
+        NextShareBlocks = {
+          type: 'actions',
+          elements: [
+            {
+              type: 'button',
+              text: {
+                type: 'plain_text',
+                text: 'Next',
+              },
+              action_id: 'showNextResults',
+              value: JSON.stringify({ offset, command, args }),
+            },
             {
-              type: 'actions',
-              elements: [
-                {
-                  type: 'button',
-                  text: {
-                    type: 'plain_text',
-                    text: 'Next',
-                  },
-                  action_id: 'showNextResults',
-                  value: JSON.stringify({ offset, command, args }),
-                },
-                {
-                  type: 'button',
-                  text: {
-                    type: 'plain_text',
-                    text: 'Share',
-                  },
-                  style: 'primary',
-                  action_id: 'shareSearchResults',
-                  value: `${keywordsAndDesc} \n\n ${urls.join('\n')}`,
-                },
-              ],
+              type: 'button',
+              text: {
+                type: 'plain_text',
+                text: 'Share',
+              },
+              style: 'primary',
+              action_id: 'shareSearchResults',
+              value: `${keywordsAndDesc} \n\n ${urls.join('\n')}`,
             },
           ],
-        });
+        };
       }
+      await this.client.chat.postEphemeral({
+        channel: command.channel_id,
+        user: command.user_id,
+        blocks: [
+          this.generateMarkdownSectionBlock(keywordsAndDesc),
+          this.generateMarkdownSectionBlock(`${urls.join('\n')}`),
+          NextShareBlocks,
+        ],
+      });
+
+
     }
     catch {
       logger.error('Failed to get search results.');