Skip to content

Commit

Permalink
fix(important): save username instantly so it doesn't reset when you …
Browse files Browse the repository at this point in the history
…reload the page if you didn't change it
  • Loading branch information
zardoy committed Feb 14, 2025
1 parent df4dd69 commit 0f29053
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/react/ServersListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ const Inner = ({ hidden, customServersList }: { hidden?: boolean, customServersL
const [quickConnectIp, setQuickConnectIp] = useState('')
const [selectedIndex, setSelectedIndex] = useState(0)

// Save username to localStorage when component mounts if it doesn't exist
useEffect(() => {
if (!localStorage['username']) {
localStorage.setItem('username', defaultUsername)
}
}, [])

const setAuthenticatedAccounts = (newState: typeof authenticatedAccounts) => {
_setAuthenticatedAccounts(newState)
localStorage.setItem('authenticatedAccounts', JSON.stringify(newState))
Expand Down

0 comments on commit 0f29053

Please sign in to comment.