Skip to content

Commit

Permalink
fix: 🐛 fix slack channel parsing when name is given
Browse files Browse the repository at this point in the history
  • Loading branch information
themashcodee committed Sep 13, 2024
1 parent f15ba19 commit 95e792f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"repository": "https://github.com/themashcodee/slack-blocks-to-jsx.git",
"license": "MIT",
"version": "0.5.7",
"version": "0.5.8",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
15 changes: 13 additions & 2 deletions src/utils/markdown_parser/sub_elements/slack_channel_mention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@ export const SlackChannelMention = (props: Props) => {

const channel_id = element.value;
const channel = channels.find((u) => u.id === channel_id || u.name === channel_id);
const label = channel?.name || channel_id;
const label = channel?.name || channel_id.split("|")[1] || channel_id;

if (hooks.channel) return <>{hooks.channel(channel || { id: channel_id, name: label })}</>;
if (hooks.channel) {
return (
<>
{hooks.channel(
channel || {
id: channel_id.split("|")[0] || channel_id,
name: label,
},
)}
</>
);
}

return (
<span className="slack_channel" data-channel-id={channel?.id || channel_id}>
Expand Down

0 comments on commit 95e792f

Please sign in to comment.