add open featured communities as default config option

This commit is contained in:
Ajay Bura 2024-03-22 20:48:32 +05:30
parent 95abc8d281
commit 3927f60057
3 changed files with 11 additions and 4 deletions

View file

@ -11,6 +11,7 @@
"allowCustomHomeservers": true,
"featuredCommunities": {
"openAsDefault": false,
"spaces": [
"#cinny-space:matrix.org",
"#community:matrix.org",

View file

@ -6,6 +6,7 @@ export type ClientConfig = {
allowCustomHomeservers?: boolean;
featuredCommunities?: {
openAsDefault?: boolean;
spaces?: string[];
rooms?: string[];
};

View file

@ -275,14 +275,19 @@ export function Explore() {
export function ExploreRedirect() {
const navigate = useNavigate();
const clientConfig = useClientConfig();
const mx = useMatrixClient();
useEffect(() => {
const userId = mx.getUserId();
const userServer = userId ? getMxIdServer(userId) : undefined;
if (userServer) navigate(getExploreServerPath(userServer), { replace: true });
}, [navigate, mx]);
if (clientConfig.featuredCommunities?.openAsDefault) {
navigate(getExploreFeaturedPath(), { replace: true });
} else {
const userId = mx.getUserId();
const userServer = userId ? getMxIdServer(userId) : undefined;
if (userServer) navigate(getExploreServerPath(userServer), { replace: true });
}
}, [navigate, mx, clientConfig]);
return null;
}