Remember last team.
Some checks are pending
Create docker images (cloud) / Build, push, and deploy (push) Waiting to run
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run

This commit is contained in:
Mike Cao 2025-11-17 19:12:25 -08:00
parent 1852acc333
commit ef3f7274e3
3 changed files with 30 additions and 2 deletions

View file

@ -5,11 +5,22 @@ import { UpdateNotice } from './UpdateNotice';
import { SideNav } from '@/app/(main)/SideNav';
import { useLoginQuery, useConfig, useNavigation } from '@/components/hooks';
import { MobileNav } from '@/app/(main)/MobileNav';
import { useEffect } from 'react';
import { removeItem, setItem } from '@/lib/storage';
import { LAST_TEAM_CONFIG } from '@/lib/constants';
export function App({ children }) {
const { user, isLoading, error } = useLoginQuery();
const config = useConfig();
const { pathname } = useNavigation();
const { pathname, teamId } = useNavigation();
useEffect(() => {
if (teamId) {
setItem(LAST_TEAM_CONFIG, teamId);
} else {
removeItem(LAST_TEAM_CONFIG);
}
}, [teamId]);
if (isLoading || !config) {
return <Loading placement="absolute" />;

View file

@ -1,5 +1,21 @@
'use client';
import { useEffect } from 'react';
import { redirect } from 'next/navigation';
import { getItem, removeItem } from '@/lib/storage';
import { LAST_TEAM_CONFIG } from '@/lib/constants';
export default function RootPage() {
redirect('/websites');
useEffect(() => {
const lastTeam = getItem(LAST_TEAM_CONFIG);
if (lastTeam) {
redirect(`/teams/${lastTeam}/websites`);
} else {
removeItem(LAST_TEAM_CONFIG);
redirect(`/websites`);
}
}, []);
return null;
}

View file

@ -5,6 +5,7 @@ export const TIMEZONE_CONFIG = 'umami.timezone';
export const DATE_RANGE_CONFIG = 'umami.date-range';
export const THEME_CONFIG = 'umami.theme';
export const DASHBOARD_CONFIG = 'umami.dashboard';
export const LAST_TEAM_CONFIG = 'umami.last-team';
export const VERSION_CHECK = 'umami.version-check';
export const SHARE_TOKEN_HEADER = 'x-umami-share-token';
export const HOMEPAGE_URL = 'https://umami.is';