mirror of
https://github.com/DerTyp7/react-teamspeak-remote-app-api.git
synced 2025-10-29 04:42:11 +01:00
add clientsinchannel state
This commit is contained in:
@@ -13,6 +13,8 @@ export default function useTSRemoteApp({ remoteAppPort = 5899 }: { remoteAppPort
|
|||||||
const [currentChannel, setCurrentChannel] = useState<IChannel | undefined>(undefined);
|
const [currentChannel, setCurrentChannel] = useState<IChannel | undefined>(undefined);
|
||||||
const [currentClient, setCurrentClient] = useState<IClient | undefined>(undefined);
|
const [currentClient, setCurrentClient] = useState<IClient | undefined>(undefined);
|
||||||
|
|
||||||
|
const [clientsInChannel, setClientsInChannel] = useState<IClient[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const tsConnection: ITS5ConnectionHandler = new TS5ConnectionHandler(
|
const tsConnection: ITS5ConnectionHandler = new TS5ConnectionHandler(
|
||||||
remoteAppPort,
|
remoteAppPort,
|
||||||
@@ -36,6 +38,13 @@ export default function useTSRemoteApp({ remoteAppPort = 5899 }: { remoteAppPort
|
|||||||
setCurrentChannel(currentChannel);
|
setCurrentChannel(currentChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentChannel) {
|
||||||
|
const clientsInChannel = clients.filter((client) => {
|
||||||
|
return client.channel?.id === currentChannel?.id && client.channel.connection.id === activeConnectionId;
|
||||||
|
});
|
||||||
|
setClientsInChannel(clientsInChannel);
|
||||||
|
}
|
||||||
}, [clients, channels, connections, activeConnectionId]);
|
}, [clients, channels, connections, activeConnectionId]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -46,5 +55,6 @@ export default function useTSRemoteApp({ remoteAppPort = 5899 }: { remoteAppPort
|
|||||||
currentConnection,
|
currentConnection,
|
||||||
currentChannel,
|
currentChannel,
|
||||||
currentClient,
|
currentClient,
|
||||||
|
clientsInChannel,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user