Apply requested changes

This commit is contained in:
Ginger 2025-09-24 10:14:56 -04:00
parent 3cc7c085c2
commit 3eea7dd074
No known key found for this signature in database
3 changed files with 197 additions and 169 deletions

View file

@ -11,7 +11,7 @@ export const useExploreSelected = (): boolean => {
return !!match;
};
export const useExploreFeaturedRooms = (): boolean => {
export const useExploreFeaturedSelected = (): boolean => {
const match = useMatch({
path: getExploreFeaturedPath(),
caseSensitive: true,

View file

@ -7,22 +7,22 @@ export type InCinnyExploreServersContent = {
servers?: string[];
};
export const useExploreServers = (
exclude?: string[]
): [string[], (server: string) => Promise<void>, (server: string) => Promise<void>] => {
export const useExploreServers = (): [
string[],
(server: string) => Promise<void>,
(server: string) => Promise<void>
] => {
const mx = useMatrixClient();
const accountData = useAccountData(AccountDataEvent.CinnyExplore);
const userAddedServers = useMemo(
() =>
accountData
?.getContent<InCinnyExploreServersContent>()
?.servers?.filter((server) => !exclude?.includes(server)) ?? [],
[exclude, accountData]
() => accountData?.getContent<InCinnyExploreServersContent>()?.servers ?? [],
[accountData]
);
const addServer = useCallback(
async (server: string) => {
if (userAddedServers.indexOf(server) === -1) {
// @ts-expect-error Custom account data event
await mx.setAccountData(AccountDataEvent.CinnyExplore, {
servers: [...userAddedServers, server],
});
@ -33,6 +33,7 @@ export const useExploreServers = (
const removeServer = useCallback(
async (server: string) => {
// @ts-expect-error Custom account data event
await mx.setAccountData(AccountDataEvent.CinnyExplore, {
servers: userAddedServers.filter((addedServer) => server !== addedServer),
});