mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-09 16:50:28 +03:00
Apply requested changes
This commit is contained in:
parent
3cc7c085c2
commit
3eea7dd074
3 changed files with 197 additions and 169 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue