Skip to content

Commit 914ee65

Browse files
committed
Don't use a persisted setting when switching users; ref pterodactyl#3021
1 parent 3053a89 commit 914ee65

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

resources/scripts/components/dashboard/DashboardContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import Pagination from '@/components/elements/Pagination';
1616
export default () => {
1717
const { clearFlashes, clearAndAddHttpError } = useFlash();
1818
const [ page, setPage ] = useState(1);
19-
const { rootAdmin } = useStoreState(state => state.user.data!);
20-
const [ showOnlyAdmin, setShowOnlyAdmin ] = usePersistedState('show_all_servers', false);
19+
const uuid = useStoreState(state => state.user.data!.uuid);
20+
const rootAdmin = useStoreState(state => state.user.data!.rootAdmin);
21+
const [ showOnlyAdmin, setShowOnlyAdmin ] = usePersistedState(`${uuid}:show_all_servers`, false);
2122

2223
const { data: servers, error } = useSWR<PaginatedResult<Server>>(
2324
[ '/api/client/servers', showOnlyAdmin, page ],

resources/scripts/plugins/usePersistedState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
22

3-
export function usePersistedState<S = undefined> (key: string, defaultValue: S): [S | undefined, Dispatch<SetStateAction<S | undefined>>] {
3+
export function usePersistedState<S = undefined> (key: string, defaultValue: S): [ S | undefined, Dispatch<SetStateAction<S | undefined>> ] {
44
const [ state, setState ] = useState(
55
() => {
66
try {
@@ -12,7 +12,7 @@ export function usePersistedState<S = undefined> (key: string, defaultValue: S):
1212

1313
return defaultValue;
1414
}
15-
}
15+
},
1616
);
1717

1818
useEffect(() => {

0 commit comments

Comments
 (0)