mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 00:20:05 +01:00
Only show artwork paintings & reload on timer
Some checks are pending
Tests / tests (push) Waiting to run
Some checks are pending
Tests / tests (push) Waiting to run
This commit is contained in:
parent
d8a4188a66
commit
641857f2d1
|
|
@ -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()}`,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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"]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user