Only show artwork paintings & reload on timer
Some checks are pending
Tests / tests (push) Waiting to run

This commit is contained in:
Dustin Brett 2025-10-13 15:10:09 -07:00
parent d8a4188a66
commit 641857f2d1
5 changed files with 16 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import {
type ArtInstituteOfChicagoResponse, type ArtInstituteOfChicagoResponse,
} from "components/system/Desktop/Wallpapers/types"; } from "components/system/Desktop/Wallpapers/types";
import { type WallpaperFit } from "contexts/session/types"; import { type WallpaperFit } from "contexts/session/types";
import { MILLISECONDS_IN_DAY, MILLISECONDS_IN_HOUR } from "utils/constants";
import { import {
jsonFetch, jsonFetch,
viewWidth, viewWidth,
@ -14,7 +15,7 @@ import {
const API_URL = { const API_URL = {
APOD: "https://api.nasa.gov/planetary/apod", 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<string, WallpaperHandler> = { export const wallpaperHandler: Record<string, WallpaperHandler> = {
@ -47,6 +48,7 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
return { return {
fallbackBackground, fallbackBackground,
newWallpaperFit, newWallpaperFit,
updateTimeout: MILLISECONDS_IN_DAY,
wallpaperUrl, wallpaperUrl,
}; };
}, },
@ -66,6 +68,11 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
is_public_domain: true, is_public_domain: true,
}, },
}, },
{
terms: {
artwork_type_id: [1], // Painting
},
},
{ {
exists: { exists: {
field: "image_id", field: "image_id",
@ -80,7 +87,6 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
}, },
}, },
}, },
resources: "artworks",
}; };
const response = (await jsonFetch(API_URL.ART_INSTITUTE_OF_CHICAGO, { const response = (await jsonFetch(API_URL.ART_INSTITUTE_OF_CHICAGO, {
body: JSON.stringify(requestPayload), body: JSON.stringify(requestPayload),
@ -99,12 +105,14 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
return { return {
fallbackBackground: imageUrl(false), fallbackBackground: imageUrl(false),
newWallpaperFit: "fit", newWallpaperFit: "fit",
updateTimeout: MILLISECONDS_IN_HOUR,
wallpaperUrl: imageUrl(true), wallpaperUrl: imageUrl(true),
}; };
}, },
LOREM_PICSUM: () => ({ LOREM_PICSUM: () => ({
fallbackBackground: "", fallbackBackground: "",
newWallpaperFit: "fill", newWallpaperFit: "fill",
updateTimeout: MILLISECONDS_IN_HOUR,
wallpaperUrl: `https://picsum.photos/seed/${Date.now()}/${viewWidth()}/${viewHeight()}`, wallpaperUrl: `https://picsum.photos/seed/${Date.now()}/${viewWidth()}/${viewHeight()}`,
}), }),
}; };

View File

@ -42,6 +42,7 @@ export type WallpaperMessage = { message: string; type: string };
export type WallpaperData = { export type WallpaperData = {
fallbackBackground: string; fallbackBackground: string;
newWallpaperFit: WallpaperFit; newWallpaperFit: WallpaperFit;
updateTimeout: number;
wallpaperUrl: string; wallpaperUrl: string;
}; };

View File

@ -339,6 +339,7 @@ const useWallpaper = (
wallpaperUrl = newWallpaper.wallpaperUrl || ""; wallpaperUrl = newWallpaper.wallpaperUrl || "";
fallbackBackground = newWallpaper.fallbackBackground || ""; fallbackBackground = newWallpaper.fallbackBackground || "";
newWallpaperFit = newWallpaper.newWallpaperFit || newWallpaperFit; newWallpaperFit = newWallpaper.newWallpaperFit || newWallpaperFit;
setTimeout(loadFileWallpaper, newWallpaper.updateTimeout);
} }
} else if (await exists(wallpaperImage)) { } else if (await exists(wallpaperImage)) {
resetWallpaper(); resetWallpaper();

View File

@ -27,7 +27,7 @@ import {
DEFAULT_WALLPAPER, DEFAULT_WALLPAPER,
DEFAULT_WALLPAPER_FIT, DEFAULT_WALLPAPER_FIT,
DESKTOP_PATH, DESKTOP_PATH,
MILLISECONDS_IN_MINUTE, MILLISECONDS_IN_HOUR,
SESSION_FILE, SESSION_FILE,
SHORTCUT_EXTENSION, SHORTCUT_EXTENSION,
SYSTEM_FILES, SYSTEM_FILES,
@ -365,7 +365,7 @@ const useSessionContextState = (): SessionContextState => {
const { spawnSheep } = await import("utils/spawnSheep"); const { spawnSheep } = await import("utils/spawnSheep");
spawnSheep(true); spawnSheep(true);
}, MILLISECONDS_IN_MINUTE * 60); }, MILLISECONDS_IN_HOUR);
}); });
} }
} catch (error) { } catch (error) {

View File

@ -167,6 +167,8 @@ export const MILLISECONDS_IN_SECOND = 1000;
export const MILLISECONDS_IN_MINUTE = 60000; export const MILLISECONDS_IN_MINUTE = 60000;
export const MILLISECONDS_IN_HOUR = 3600000;
export const MILLISECONDS_IN_DAY = 86400000; export const MILLISECONDS_IN_DAY = 86400000;
export const ZIP_EXTENSIONS = new Set([".jsdos", ".pk3", ".wsz", ".zip"]); export const ZIP_EXTENSIONS = new Set([".jsdos", ".pk3", ".wsz", ".zip"]);