From 641857f2d1407367be37d74d3754c4e9357745d0 Mon Sep 17 00:00:00 2001 From: Dustin Brett Date: Mon, 13 Oct 2025 15:10:09 -0700 Subject: [PATCH] Only show artwork paintings & reload on timer --- components/system/Desktop/Wallpapers/handlers.ts | 12 ++++++++++-- components/system/Desktop/Wallpapers/types.ts | 1 + components/system/Desktop/Wallpapers/useWallpaper.ts | 1 + contexts/session/useSessionContextState.ts | 4 ++-- utils/constants.ts | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/system/Desktop/Wallpapers/handlers.ts b/components/system/Desktop/Wallpapers/handlers.ts index 290aa040..cc60c67b 100644 --- a/components/system/Desktop/Wallpapers/handlers.ts +++ b/components/system/Desktop/Wallpapers/handlers.ts @@ -4,6 +4,7 @@ import { type ArtInstituteOfChicagoResponse, } from "components/system/Desktop/Wallpapers/types"; import { type WallpaperFit } from "contexts/session/types"; +import { MILLISECONDS_IN_DAY, MILLISECONDS_IN_HOUR } from "utils/constants"; import { jsonFetch, viewWidth, @@ -14,7 +15,7 @@ import { const API_URL = { APOD: "https://api.nasa.gov/planetary/apod", - ART_INSTITUTE_OF_CHICAGO: "https://api.artic.edu/api/v1/search", + ART_INSTITUTE_OF_CHICAGO: "https://api.artic.edu/api/v1/artworks/search", }; export const wallpaperHandler: Record = { @@ -47,6 +48,7 @@ export const wallpaperHandler: Record = { return { fallbackBackground, newWallpaperFit, + updateTimeout: MILLISECONDS_IN_DAY, wallpaperUrl, }; }, @@ -66,6 +68,11 @@ export const wallpaperHandler: Record = { is_public_domain: true, }, }, + { + terms: { + artwork_type_id: [1], // Painting + }, + }, { exists: { field: "image_id", @@ -80,7 +87,6 @@ export const wallpaperHandler: Record = { }, }, }, - resources: "artworks", }; const response = (await jsonFetch(API_URL.ART_INSTITUTE_OF_CHICAGO, { body: JSON.stringify(requestPayload), @@ -99,12 +105,14 @@ export const wallpaperHandler: Record = { return { fallbackBackground: imageUrl(false), newWallpaperFit: "fit", + updateTimeout: MILLISECONDS_IN_HOUR, wallpaperUrl: imageUrl(true), }; }, LOREM_PICSUM: () => ({ fallbackBackground: "", newWallpaperFit: "fill", + updateTimeout: MILLISECONDS_IN_HOUR, wallpaperUrl: `https://picsum.photos/seed/${Date.now()}/${viewWidth()}/${viewHeight()}`, }), }; diff --git a/components/system/Desktop/Wallpapers/types.ts b/components/system/Desktop/Wallpapers/types.ts index eff80fe9..aa7cc8f3 100644 --- a/components/system/Desktop/Wallpapers/types.ts +++ b/components/system/Desktop/Wallpapers/types.ts @@ -42,6 +42,7 @@ export type WallpaperMessage = { message: string; type: string }; export type WallpaperData = { fallbackBackground: string; newWallpaperFit: WallpaperFit; + updateTimeout: number; wallpaperUrl: string; }; diff --git a/components/system/Desktop/Wallpapers/useWallpaper.ts b/components/system/Desktop/Wallpapers/useWallpaper.ts index db45819a..e04b651f 100644 --- a/components/system/Desktop/Wallpapers/useWallpaper.ts +++ b/components/system/Desktop/Wallpapers/useWallpaper.ts @@ -339,6 +339,7 @@ const useWallpaper = ( wallpaperUrl = newWallpaper.wallpaperUrl || ""; fallbackBackground = newWallpaper.fallbackBackground || ""; newWallpaperFit = newWallpaper.newWallpaperFit || newWallpaperFit; + setTimeout(loadFileWallpaper, newWallpaper.updateTimeout); } } else if (await exists(wallpaperImage)) { resetWallpaper(); diff --git a/contexts/session/useSessionContextState.ts b/contexts/session/useSessionContextState.ts index 22502fc3..26c0135a 100644 --- a/contexts/session/useSessionContextState.ts +++ b/contexts/session/useSessionContextState.ts @@ -27,7 +27,7 @@ import { DEFAULT_WALLPAPER, DEFAULT_WALLPAPER_FIT, DESKTOP_PATH, - MILLISECONDS_IN_MINUTE, + MILLISECONDS_IN_HOUR, SESSION_FILE, SHORTCUT_EXTENSION, SYSTEM_FILES, @@ -365,7 +365,7 @@ const useSessionContextState = (): SessionContextState => { const { spawnSheep } = await import("utils/spawnSheep"); spawnSheep(true); - }, MILLISECONDS_IN_MINUTE * 60); + }, MILLISECONDS_IN_HOUR); }); } } catch (error) { diff --git a/utils/constants.ts b/utils/constants.ts index 5bb84e74..6480b68d 100644 --- a/utils/constants.ts +++ b/utils/constants.ts @@ -167,6 +167,8 @@ export const MILLISECONDS_IN_SECOND = 1000; export const MILLISECONDS_IN_MINUTE = 60000; +export const MILLISECONDS_IN_HOUR = 3600000; + export const MILLISECONDS_IN_DAY = 86400000; export const ZIP_EXTENSIONS = new Set([".jsdos", ".pk3", ".wsz", ".zip"]);