Fix channel configured status (#44)

This commit is contained in:
paisley
2026-02-11 11:44:06 +08:00
committed by GitHub
Unverified
parent 92c1b68a54
commit 01f4d4800e
2 changed files with 31 additions and 12 deletions

View File

@@ -59,17 +59,6 @@ export function Channels() {
fetchChannels();
}, [fetchChannels]);
useEffect(() => {
const unsubscribe = window.electron.ipcRenderer.on('gateway:channel-status', () => {
fetchChannels();
});
return () => {
if (typeof unsubscribe === 'function') {
unsubscribe();
}
};
}, [fetchChannels]);
// Fetch configured channel types from config file
const fetchConfiguredTypes = useCallback(async () => {
try {
@@ -90,6 +79,18 @@ export function Channels() {
void fetchConfiguredTypes();
}, [fetchConfiguredTypes]);
useEffect(() => {
const unsubscribe = window.electron.ipcRenderer.on('gateway:channel-status', () => {
fetchChannels();
fetchConfiguredTypes();
});
return () => {
if (typeof unsubscribe === 'function') {
unsubscribe();
}
};
}, [fetchChannels, fetchConfiguredTypes]);
// Get channel types to display
const displayedChannelTypes = showAllChannels ? getAllChannels() : getPrimaryChannels();
@@ -205,7 +206,9 @@ export function Channels() {
channel={channel}
onDelete={() => {
if (confirm('Are you sure you want to delete this channel?')) {
deleteChannel(channel.id);
deleteChannel(channel.id).then(() => {
fetchConfiguredTypes();
});
}
}}
/>