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,
} 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<string, WallpaperHandler> = {
@ -47,6 +48,7 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
return {
fallbackBackground,
newWallpaperFit,
updateTimeout: MILLISECONDS_IN_DAY,
wallpaperUrl,
};
},
@ -66,6 +68,11 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
is_public_domain: true,
},
},
{
terms: {
artwork_type_id: [1], // Painting
},
},
{
exists: {
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, {
body: JSON.stringify(requestPayload),
@ -99,12 +105,14 @@ export const wallpaperHandler: Record<string, WallpaperHandler> = {
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()}`,
}),
};

View File

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

View File

@ -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();

View File

@ -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) {

View File

@ -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"]);