fixing wallpapers again and improving pipeline for release
Build and Release to Staging / Build Vision Start (push) Successful in 1m22s
Build and Release to Staging / Build Vision Start Image (push) Successful in 2m40s
Build and Release to Staging / Deploy Vision Start (staging) (push) Successful in 14s
Build and Release / build (push) Successful in 1m21s
Build and Release / virus-total-check (push) Successful in 1m29s
Build and Release / Build Vision Start Image (push) Successful in 2m42s
Build and Release / Deploy Vision Start (production) (push) Successful in 9s
Build and Release / Capture Vision Start Screenshots (push) Successful in 47s
Build and Release / release (push) Successful in 1m0s
Build and Release to Staging / Build Vision Start (push) Successful in 1m22s
Build and Release to Staging / Build Vision Start Image (push) Successful in 2m40s
Build and Release to Staging / Deploy Vision Start (staging) (push) Successful in 14s
Build and Release / build (push) Successful in 1m21s
Build and Release / virus-total-check (push) Successful in 1m29s
Build and Release / Build Vision Start Image (push) Successful in 2m42s
Build and Release / Deploy Vision Start (production) (push) Successful in 9s
Build and Release / Capture Vision Start Screenshots (push) Successful in 47s
Build and Release / release (push) Successful in 1m0s
This commit is contained in:
@@ -21,4 +21,31 @@ export const getRandomWallpaperIndex = (wallpaperCount: number, currentIndex: nu
|
||||
if (wallpaperCount <= 1) return 0;
|
||||
const offset = Math.floor(Math.random() * (wallpaperCount - 1)) + 1;
|
||||
return (currentIndex + offset) % wallpaperCount;
|
||||
};
|
||||
};
|
||||
|
||||
export const loadWallpaperState = (names: string[], now = Date.now()) => {
|
||||
let state: Record<string, unknown> = {};
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(localStorage.getItem('wallpaperState') || '{}');
|
||||
if (parsed && typeof parsed === 'object') state = parsed as Record<string, unknown>;
|
||||
} catch {
|
||||
state = {};
|
||||
}
|
||||
const namedIndex = typeof state.currentName === 'string' ? names.indexOf(state.currentName) : -1;
|
||||
const index = namedIndex >= 0 ? namedIndex : typeof state.currentName === 'string' ? 0 : state.currentIndex;
|
||||
const currentIndex = typeof index === 'number' && Number.isInteger(index) && index >= 0 && index < names.length ? index : 0;
|
||||
const timestamp = typeof state.lastWallpaperChange === 'string' ? Date.parse(state.lastWallpaperChange) : NaN;
|
||||
const lastChange = Number.isFinite(timestamp) && timestamp <= now && timestamp >= 0 ? timestamp : now;
|
||||
return { currentIndex, lastChange };
|
||||
};
|
||||
|
||||
export const saveWallpaperState = (names: string[], currentIndex: number, lastChange: number): void => {
|
||||
const payload = JSON.stringify({
|
||||
currentIndex,
|
||||
currentName: names[currentIndex],
|
||||
lastWallpaperChange: new Date(lastChange).toISOString(),
|
||||
});
|
||||
if (localStorage.getItem('wallpaperState') !== payload) {
|
||||
localStorage.setItem('wallpaperState', payload);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user