Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kno-5254): hide inaccessible channels #69

Merged
merged 1 commit into from
Feb 21, 2024
Merged

fix(kno-5254): hide inaccessible channels #69

merged 1 commit into from
Feb 21, 2024

Conversation

meryldakin
Copy link
Contributor

This handles the case where a user has a slack channel connected in Knock, but it isn't found in the list of Slack channels from the API, potentially because the bot doesn't have access to it (like a private channel it doesn't belong to). In this case it also wouldn't be able to post to the channel so it is accurate to show to the user that it is not connected.

It also updates some minor styling issues.

Copy link

changeset-bot bot commented Feb 20, 2024

⚠️ No Changeset found

Latest commit: e9665e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Base automatically changed from md-kno-5010 to main February 20, 2024 20:57
@meryldakin meryldakin force-pushed the md-kno-5254 branch 3 times, most recently from 886fc84 to 67b4a48 Compare February 20, 2024 21:02
Copy link
Contributor

@cjbell cjbell left a comment

Choose a reason for hiding this comment

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

one note

Copy link

vercel bot commented Feb 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
javascript-slack-connect-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 21, 2024 1:32pm

Comment on lines 86 to +100
useEffect(() => {
setCurrentConnectedChannels(connectedChannels);
}, [connectedChannels]);
// Used to make sure we're only showing currently available channels to select from.
// There are cases where a channel is "connected" in Knock, but it wouldn't be
// posting to it if the channel is private and the Slackbot doesn't belong to it,
// so the channel won't show up here and it won't be posted to.
const slackChannelsMap = new Map(
slackChannels.map((channel) => [channel.id, channel]),
);

const channels = connectedChannels?.filter((connectedChannel) => {
return slackChannelsMap.has(connectedChannel.channel_id);
}) || [];

setCurrentConnectedChannels(channels);
}, [connectedChannels, slackChannels]);
Copy link
Member

Choose a reason for hiding this comment

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

I think this is definitely fine for now since we're pushing to get this out, but semantically might make more sense for this to run in a useCallback? Can worry about it later!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok good call, i will come back to this ty!

@meryldakin meryldakin merged commit 4853cf0 into main Feb 21, 2024
3 checks passed
@meryldakin meryldakin deleted the md-kno-5254 branch February 21, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants