mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 14:00:29 +00:00
fix: add hash check to polling fallback and persist sidebar state
- Add content hash check to config watcher polling path to match fsnotify behavior, preventing unnecessary restarts when .env is touched but content unchanged (Related to #748) - Change settings sidebar to expanded by default and persist user preference using usePersistentSignal (Related to #764)
This commit is contained in:
@@ -39,6 +39,7 @@ import { SettingsSectionNav } from './SettingsSectionNav';
|
||||
import { SettingsAPI } from '@/api/settings';
|
||||
import { NodesAPI } from '@/api/nodes';
|
||||
import { UpdatesAPI } from '@/api/updates';
|
||||
import { usePersistentSignal } from '@/hooks/usePersistentSignal';
|
||||
import { Card } from '@/components/shared/Card';
|
||||
import { SectionHeader } from '@/components/shared/SectionHeader';
|
||||
import { Toggle } from '@/components/shared/Toggle';
|
||||
@@ -596,7 +597,7 @@ const Settings: Component<SettingsProps> = (props) => {
|
||||
);
|
||||
|
||||
const [hasUnsavedChanges, setHasUnsavedChanges] = createSignal(false);
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = createSignal(true);
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = usePersistentSignal('settings-sidebar-collapsed', false);
|
||||
const [nodes, setNodes] = createSignal<NodeConfigWithStatus[]>([]);
|
||||
const [discoveredNodes, setDiscoveredNodes] = createSignal<DiscoveredServer[]>([]);
|
||||
const [showNodeModal, setShowNodeModal] = createSignal(false);
|
||||
|
||||
@@ -265,8 +265,17 @@ func (cw *ConfigWatcher) pollForChanges() {
|
||||
// Check .env
|
||||
if stat, err := os.Stat(cw.envPath); err == nil {
|
||||
if stat.ModTime().After(cw.lastModTime) {
|
||||
log.Info().Msg("Detected .env file change via polling")
|
||||
cw.lastModTime = stat.ModTime()
|
||||
// Check if content actually changed to prevent restart loops on touch
|
||||
newHash, err := cw.calculateFileHash(cw.envPath)
|
||||
if err == nil {
|
||||
if newHash == cw.lastEnvHash {
|
||||
log.Debug().Msg("Detected .env file touch but content unchanged (polling), skipping reload")
|
||||
continue
|
||||
}
|
||||
cw.lastEnvHash = newHash
|
||||
}
|
||||
log.Info().Msg("Detected .env file change via polling")
|
||||
cw.reloadConfig()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user