From ba6242270fd802154c36a65018642d7b99ac8825 Mon Sep 17 00:00:00 2001 From: Sahand Seifi Date: Sat, 25 Oct 2025 13:30:04 -0400 Subject: [PATCH 1/2] Fix rerenders --- lib/components/Slack/SlackConnect.tsx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/components/Slack/SlackConnect.tsx b/lib/components/Slack/SlackConnect.tsx index 4a67839..1f6eeea 100644 --- a/lib/components/Slack/SlackConnect.tsx +++ b/lib/components/Slack/SlackConnect.tsx @@ -42,6 +42,7 @@ export function SlackConnect({ selectChannelText = 'Choose a channel or user to receive notifications:' }: SlackConnectProps = {}) { const context = useContext(NotificationAPIContext); + const client = context?.getClient(); const [slackToken, setSlackToken] = useState< User['slackToken'] | undefined >(); @@ -53,11 +54,10 @@ export function SlackConnect({ const [isEditing, setIsEditing] = useState(false); const fetchUserSlackStatus = useCallback(async () => { - if (!context) return; + if (!client) return; try { setLoading(true); - const client = context.getClient(); // Get user's current slack configuration using user.get const user = await client.user.get(); @@ -75,15 +75,14 @@ export function SlackConnect({ } finally { setLoading(false); } - }, [context]); + }, [client]); const loadChannels = useCallback(async () => { - if (!context || !slackToken) return []; + if (!client || !slackToken) return []; try { setLoading(true); setError(null); - const client = context.getClient(); // Get channels and users from Slack const response = await client.slack.getChannels(); @@ -115,7 +114,7 @@ export function SlackConnect({ } finally { setLoading(false); } - }, [context, slackToken]); + }, [client, slackToken]); useEffect(() => { // Fetch the user's current slackToken and slackChannel from the API @@ -129,12 +128,11 @@ export function SlackConnect({ }, [slackToken, slackChannel, isEditing, loadChannels]); const handleConnectSlack = async () => { - if (!context) return; + if (!client) return; try { setLoading(true); setError(null); - const client = context.getClient(); // Generate Slack OAuth URL const url = await client.slack.getOAuthUrl(); @@ -150,12 +148,11 @@ export function SlackConnect({ }; const handleSaveChannel = async () => { - if (!context || !selectedChannel) return; + if (!client || !selectedChannel) return; try { setLoading(true); setError(null); - const client = context.getClient(); // Find the selected channel info to get its name and type const channelInfo = channels.find((c) => c.id === selectedChannel); @@ -184,12 +181,11 @@ export function SlackConnect({ }; const handleDisconnect = async () => { - if (!context) return; + if (!client) return; try { setLoading(true); setError(null); - const client = context.getClient(); // Remove slackToken and slackChannel using identify await client.identify({ @@ -243,7 +239,7 @@ export function SlackConnect({ setSelectedChannel(''); }; - if (!context) { + if (!client) { return null; } From 22a545b180e0e1a098fcd689dbbb6f8d59ca1097 Mon Sep 17 00:00:00 2001 From: Sahand Seifi Date: Sat, 25 Oct 2025 13:30:12 -0400 Subject: [PATCH 2/2] 1.5.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1bbbc91..ba5b1c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@notificationapi/react", - "version": "1.5.0", + "version": "1.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@notificationapi/react", - "version": "1.5.0", + "version": "1.5.1", "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.0", diff --git a/package.json b/package.json index f1c6b6a..316b18e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@notificationapi/react", "private": false, - "version": "1.5.0", + "version": "1.5.1", "type": "module", "overrides": { "esbuild": "^0.25.0",