fixing wallpaper
All checks were successful
Build and Release to Staging / Build Vision Start (push) Successful in 31s
Build and Release to Staging / Build Vision Start Image (push) Successful in 2m54s
Build and Release to Staging / Deploy Vision Start (staging) (push) Successful in 1m10s

This commit is contained in:
2026-07-02 19:22:19 -03:00
parent c397e77c01
commit ddf2f2a416
4 changed files with 115 additions and 37 deletions

24
App.tsx
View File

@@ -31,6 +31,7 @@ const App: React.FC = () => {
const [editingCategory, setEditingCategory] = useState<Category | null>(null);
const [isCategoryModalOpen, setIsCategoryModalOpen] = useState(false);
const [config, setConfig] = useState<Config>(() => ConfigurationService.loadConfig());
const [wallpaperVersion, setWallpaperVersion] = useState(0);
useEffect(() => {
ConfigurationService.saveConfig(config);
@@ -53,6 +54,27 @@ const App: React.FC = () => {
setConfig(prev => ({ ...prev, ...newConfig }));
};
const handleNextWallpaper = () => {
const names = config.currentWallpapers;
if (names.length === 0) return;
try {
const state = JSON.parse(localStorage.getItem('wallpaperState') || '{}');
const current = typeof state.currentIndex === 'number' ? state.currentIndex : 0;
const safeCurrent = current < 0 || current >= names.length ? 0 : current;
const nextIndex = (safeCurrent + 1) % names.length;
localStorage.setItem(
'wallpaperState',
JSON.stringify({
lastWallpaperChange: new Date().toISOString(),
currentIndex: nextIndex,
}),
);
} catch (error) {
console.error('Error advancing wallpaper state', error);
}
setWallpaperVersion(v => v + 1);
};
const handleSaveWebsite = (website: Partial<Website>) => {
if (editingWebsite) {
const idToUpdate = website.id ?? editingWebsite.id;
@@ -185,6 +207,7 @@ const App: React.FC = () => {
brightness={config.wallpaperBrightness}
opacity={config.wallpaperOpacity}
wallpaperFrequency={config.wallpaperFrequency}
wallpaperVersion={wallpaperVersion}
/>
<EditButton isEditing={isEditing} onClick={() => setIsEditing(!isEditing)} />
<ConfigurationButton onClick={() => setIsConfigModalOpen(true)} />
@@ -258,6 +281,7 @@ const App: React.FC = () => {
onClose={() => setIsConfigModalOpen(false)}
onSave={handleSaveConfig}
onWallpaperChange={handleWallpaperChange}
onNextWallpaper={handleNextWallpaper}
/>
)}
</main>