From a17cd2d4d315be3888c0f489ff7c0bc1c65da518 Mon Sep 17 00:00:00 2001 From: Miklos Aubert Date: Fri, 1 Feb 2019 14:09:23 +0100 Subject: [PATCH 1/3] Add custom trigger on reply start --- app/slackapp/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/slackapp/index.js b/app/slackapp/index.js index 0597cba..cf2248e 100644 --- a/app/slackapp/index.js +++ b/app/slackapp/index.js @@ -75,6 +75,11 @@ const setupAppHandlers = (slackapp, apiClient, enableReviewQueries) => { ); } else { reviewReply.showReplyDialog(bot, message); + slackapp.trigger('reply_dialog_opened', [ + { + reviewId: message.callback_id, + }, + ]); } }; From 79018070b497b489fff2968c1eb0666a5c6efe11 Mon Sep 17 00:00:00 2001 From: Miklos Aubert Date: Fri, 1 Feb 2019 14:24:55 +0100 Subject: [PATCH 2/3] Add custom trigger when opening feed settings --- app/slackapp/feed-settings.js | 3 ++- app/slackapp/index.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/slackapp/feed-settings.js b/app/slackapp/feed-settings.js index 6875ce6..4833134 100644 --- a/app/slackapp/feed-settings.js +++ b/app/slackapp/feed-settings.js @@ -102,7 +102,7 @@ const showIntroMessage = (message, bot) => { } }; -const showFeedSettings = (bot, message) => { +const showFeedSettings = (slackapp) => (bot, message) => { const team = bot.team_info; const { starFilter = 'all', canReply } = getChannelFeedSettingsOrDefault(team, message.channel); const sourceMessage = { @@ -135,6 +135,7 @@ const showFeedSettings = (bot, message) => { console.log(err, res); } }); + slackapp.trigger('feed_settings_dialog_opened', [bot]); }; const handleNewFeedSettings = async (bot, message, slackapp) => { diff --git a/app/slackapp/index.js b/app/slackapp/index.js index cf2248e..185709e 100644 --- a/app/slackapp/index.js +++ b/app/slackapp/index.js @@ -124,7 +124,7 @@ const setupAppHandlers = (slackapp, apiClient, enableReviewQueries) => { const action = message.actions[0].value; const actionHandlers = { ['step_1_write_reply']: handleReplyButton, - ['open_feed_settings']: feedSettings.showFeedSettings, + ['open_feed_settings']: feedSettings.showFeedSettings(slackapp), ['delete_feed_settings']: feedSettings.deleteFeedSettings(slackapp), }; await actionHandlers[action](bot, message); From 23b1bbc37a65b5f4701f3fa86b9160a66d758ef0 Mon Sep 17 00:00:00 2001 From: Miklos Aubert Date: Tue, 5 Feb 2019 12:07:07 +0100 Subject: [PATCH 3/3] Add custom trigger when deleting feed settings --- app/slackapp/feed-settings.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/slackapp/feed-settings.js b/app/slackapp/feed-settings.js index 4833134..ea456eb 100644 --- a/app/slackapp/feed-settings.js +++ b/app/slackapp/feed-settings.js @@ -181,9 +181,13 @@ const deleteFeedSettings = (slackapp) => async (bot, message) => { if (team.incoming_webhook && team.incoming_webhook.channel_id === channelId) { team.incoming_webhook = null; } + const deletedFeed = team.feeds && team.feeds.find((f) => f.channelId === channelId); team.feeds = (team.feeds || []).filter((f) => f.channelId !== channelId); slackapp.saveTeamAsync = slackapp.saveTeamAsync || promisify(slackapp.saveTeam); await slackapp.saveTeamAsync(team); + if (deletedFeed) { + slackapp.trigger('feed_settings_deleted', [{ businessUnitId: deletedFeed.businessUnitId }]); + } showIntroMessage(message, bot); };