Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions listeners/actions/sample-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ const sampleActionCallback = async ({
}: AllMiddlewareArgs & SlackActionMiddlewareArgs<BlockAction>) => {
try {
await ack();

/**
* Return if this action somehow wasn't from a modal.
*
* @see {@link ../shortcuts/sample-shortcut.ts}
* @see {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html}
*/
if (body.view?.type !== 'modal') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about adding a logger.warn rather then a comment 🤔 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I'll hold off on this since other actions aren't configured at the moment - I believe modal actions are the only view this app receives from!

return;
}

await client.views.update({
// biome-ignore lint/style/noNonNullAssertion: view may be undefined, depending on the source of this action(did it come from an action within a conversation message or a modal?). take care!
view_id: body.view!.id,
// biome-ignore lint/style/noNonNullAssertion: view may be undefined, depending on the source of this action(did it come from an action within a conversation message or a modal?). take care!
hash: body.view!.hash,
Comment on lines -12 to -15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise 🙏

view_id: body.view.id,
hash: body.view.hash,
view: {
type: 'modal',
callback_id: 'sample_view_id',
Expand Down
4 changes: 3 additions & 1 deletion listeners/events/app-home-opened.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const appHomeOpenedCallback = async ({
logger,
}: AllMiddlewareArgs & SlackEventMiddlewareArgs<'app_home_opened'>) => {
// Ignore the `app_home_opened` event for anything but the Home tab
if (event.tab !== 'home') return;
if (event.tab !== 'home') {
return;
}

try {
await client.views.publish({
Expand Down
1 change: 1 addition & 0 deletions tests/actions/sample-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fakeAck, fakeClient, fakeLogger } from '../helpers.js';

const fakeBody = {
view: {
type: 'modal',
id: 'test_id',
hash: '156772938.1827394',
},
Expand Down