diff --git a/src/components/communitySettings/HivemindSettings/TcHivemindDiscordAnswering.tsx b/src/components/communitySettings/HivemindSettings/TcHivemindDiscordAnswering.tsx
index 22db690a..232d52ee 100644
--- a/src/components/communitySettings/HivemindSettings/TcHivemindDiscordAnswering.tsx
+++ b/src/components/communitySettings/HivemindSettings/TcHivemindDiscordAnswering.tsx
@@ -112,7 +112,7 @@ function TcHivemindDiscordAnswering({
handleModuleConfigChange({
selectedChannels,
});
- }, [selectedChannels, handleModuleConfigChange]);
+ }, [selectedChannels]);
return (
diff --git a/src/components/communitySettings/communityPlatforms/TcDiscordIntegrationSettingsDialog.tsx b/src/components/communitySettings/communityPlatforms/TcDiscordIntegrationSettingsDialog.tsx
index 4669b6bc..5fdb031f 100644
--- a/src/components/communitySettings/communityPlatforms/TcDiscordIntegrationSettingsDialog.tsx
+++ b/src/components/communitySettings/communityPlatforms/TcDiscordIntegrationSettingsDialog.tsx
@@ -1,5 +1,5 @@
import { TreeItem, TreeView } from '@mui/lab';
-import { CircularProgress, FormControlLabel } from '@mui/material';
+import { CircularProgress, FormControlLabel, Typography } from '@mui/material';
import moment from 'moment';
import { useRouter } from 'next/router';
import React, { useEffect, useState } from 'react';
@@ -23,6 +23,7 @@ import { useSnackbar } from '../../../context/SnackbarContext';
import { truncateCenter } from '../../../helpers/helper';
import useAppStore from '../../../store/useStore';
import { IPlatformProps } from '../../../utils/interfaces';
+import { useToken } from '../../../context/TokenContext';
interface TcDiscordIntegrationSettingsDialog {
platform: IPlatformProps;
@@ -32,8 +33,12 @@ function TcDiscordIntegrationSettingsDialog({
platform,
handleUpdateCommunityPlatform,
}: TcDiscordIntegrationSettingsDialog) {
+ const { community, updateCommunity } = useToken();
+
const { retrievePlatformProperties, patchPlatformById, deletePlatform } =
useAppStore();
+ const [isFetchingIntialData, setIsFetchingIntialData] =
+ useState(true);
const [open, setOpen] = useState(false);
const [loading, setLoading] = useState(false);
const [isAnalyizingDialogOpen, setIsAnalyizingDialogOpen] =
@@ -57,6 +62,21 @@ function TcDiscordIntegrationSettingsDialog({
}
}, []);
+ useEffect(() => {
+ const discordPlatformIsFetchingIntialData = community?.platforms
+ .filter(
+ (platform) =>
+ platform.disconnectedAt === null && platform.name === 'discord'
+ )
+ .map((platform) => platform.metadata?.isFetchingIntialData)[0];
+
+ setIsFetchingIntialData(
+ discordPlatformIsFetchingIntialData
+ ? discordPlatformIsFetchingIntialData
+ : false
+ );
+ }, [community]);
+
const fetchDiscordPlatformProperties = async () => {
if (!platform) return;
@@ -173,6 +193,14 @@ function TcDiscordIntegrationSettingsDialog({
setIsDeleteDialogOpen(false);
showMessage('Platform disconnected successfully.', 'success');
handleUpdateCommunityPlatform();
+
+ if (community) {
+ const updatedPlatforms = community.platforms.filter(
+ (p) => p.id !== platform.id
+ );
+ const updatedCommunity = { ...community, platforms: updatedPlatforms };
+ updateCommunity(updatedCommunity);
+ }
}
} catch (error) {
console.error('Failed to disconnect Discord integration:', error);
@@ -241,167 +269,179 @@ function TcDiscordIntegrationSettingsDialog({
onClick={() => setOpen(false)}
/>
-
-
-
-
-
-
- }
- onClick={handleClick}
- text={dateTimeDisplay}
- aria-describedby={id}
- />
-
-
-
-
-
-
-
-
-
- window.open(
- `${conf.GITBOOK_URL}features/smart-announcements#how-to-set-permissions-for-the-smart-announcements-to-work`
- )
- }
- />
-
-
-
-
}
- size='small'
- onClick={handleRefresh}
- />
+ {isFetchingIntialData ? (
+
+
+
+
+ We are fetching data of your server. It may take a few minutes.
+
+
- {loading ? (
-
-
+ ) : (
+ <>
+
- ) : (
-
}
- defaultExpandIcon={
}
- >
- {discordPlatformChannels &&
- discordPlatformChannels.map((channel, index) => (
-
-
- e.stopPropagation()}
- control={
-
- selectedChannels?.includes(
- subChannel.channelId
+
+
+
+
+
+ }
+ onClick={handleClick}
+ text={dateTimeDisplay}
+ aria-describedby={id}
+ />
+
+
+
+
+
+
+
+
+
+ window.open(
+ `${conf.GITBOOK_URL}features/smart-announcements#how-to-set-permissions-for-the-smart-announcements-to-work`
+ )
+ }
+ />
+
+
+
+ }
+ size='small'
+ onClick={handleRefresh}
+ />
+
+ {loading ? (
+
+
+
+ ) : (
+
}
+ defaultExpandIcon={
}
+ >
+ {discordPlatformChannels?.map((channel, index) => (
+
+
+ e.stopPropagation()}
+ control={
+
+ selectedChannels?.includes(
+ subChannel.channelId
+ )
+ )}
+ disabled={channel.subChannels.some(
+ (subChannel) =>
+ !subChannel.canReadMessageHistoryAndViewChannel
+ )}
+ onChange={(e) =>
+ handleToggleAllChannelSubChannels(
+ e,
+ channel.channelId
)
- )}
- disabled={channel.subChannels.some(
- (subChannel) =>
- !subChannel.canReadMessageHistoryAndViewChannel
- )}
- onChange={(e) =>
- handleToggleAllChannelSubChannels(
- e,
- channel.channelId
- )
- }
- />
+ }
+ />
+ }
+ label='Enable All'
+ />
+
+ }
+ key={index}
+ >
+ {channel.subChannels.map((subChannel, index) => (
+
+
+ e.stopPropagation()}
+ control={
+
+ handleToggleSubChannel(
+ e,
+ subChannel.channelId
+ )
+ }
+ />
+ }
+ label='Enable'
+ />
+
}
- label='Enable All'
+ key={index}
/>
-
- }
- key={index}
- >
- {channel.subChannels.map((subChannel, index) => (
-
-
- e.stopPropagation()}
- control={
-
- handleToggleSubChannel(
- e,
- subChannel.channelId
- )
- }
- />
- }
- label='Enable'
- />
-
- }
- key={index}
- />
- ))}
-
- ))}
-
- )}
-
+ ))}
+
+ ))}
+
+ )}
+
+ >
+ )}
handlePatchDiscordIntegrationSettings()}
/>
diff --git a/src/utils/interfaces.ts b/src/utils/interfaces.ts
index d194370d..78a94680 100644
--- a/src/utils/interfaces.ts
+++ b/src/utils/interfaces.ts
@@ -181,6 +181,7 @@ export interface ICommunityDiscordPlatfromProps {
permissions: Permissions;
analyzerStartedAt?: string;
isInProgress?: boolean;
+ isFetchingIntialData?: boolean;
};
disconnectedAt: string | null;
}