feat(settings): move Hide IP toggle into Settings modal, persist it
Hide-IP was a sidebar button held only in memory, so it reset on reload. Moved it into the Settings modal Canvas section and persist it to localStorage (new ipDisplay util); the canvas store now seeds hideIp from storage and writes through on toggleHideIp/setHideIp. Settings is now also reachable in standalone (no-backend) builds, with the backend-only status interval guarded so the modal still works there. ha-relevant: yes
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { readHideIp, writeHideIp } from '@/utils/ipDisplay'
|
||||
|
||||
describe('ipDisplay persistence', () => {
|
||||
beforeEach(() => localStorage.clear())
|
||||
|
||||
it('defaults to false when nothing is stored', () => {
|
||||
expect(readHideIp()).toBe(false)
|
||||
})
|
||||
|
||||
it('round-trips true', () => {
|
||||
writeHideIp(true)
|
||||
expect(localStorage.getItem('homelable.hideIp')).toBe('true')
|
||||
expect(readHideIp()).toBe(true)
|
||||
})
|
||||
|
||||
it('round-trips false', () => {
|
||||
writeHideIp(true)
|
||||
writeHideIp(false)
|
||||
expect(readHideIp()).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
// Persisted client-side preference for masking IP addresses on the canvas.
|
||||
// Kept in localStorage (per-user UI preference, not canvas data) so it
|
||||
// survives a page reload.
|
||||
|
||||
const KEY = 'homelable.hideIp'
|
||||
|
||||
export function readHideIp(): boolean {
|
||||
try {
|
||||
return localStorage.getItem(KEY) === 'true'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function writeHideIp(value: boolean): void {
|
||||
try {
|
||||
localStorage.setItem(KEY, String(value))
|
||||
} catch {
|
||||
/* quota / SSR */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user