Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
14 changes: 11 additions & 3 deletions packages/desktop/src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { createMemoryHistory, MemoryRouter, type BaseRouterProps } from "@solidj
import { createEffect, createMemo, createResource, createSignal, onCleanup, onMount, Show } from "solid-js"
import { render } from "solid-js/web"
import pkg from "../../package.json"
import defaultBackground from "./default-background.avif"
import { initI18n, t } from "./i18n"
import { initializationData, initializationReady } from "./initialization"
import { DesktopFirstLaunchOnboarding } from "./onboarding"
Expand Down Expand Up @@ -112,17 +113,22 @@ function DesktopMemoryRouter(props: BaseRouterProps & { windowID: string }) {

const createPlatform = (windowState: DesktopWindowState): Platform => {
const attachmentPaths = new WeakMap<File, string>()
const [backgroundImage, setBackgroundImage] = createSignal(false)
const [backgroundImage, setBackgroundImage] = createSignal(true)
const applyBackgroundImage = (image: Awaited<ReturnType<typeof window.api.loadBackgroundImage>>) => {
setBackgroundImage(!!image)
document.documentElement.toggleAttribute("data-background-image", !!image)
const active = !!image || localStorage.getItem("background-image.default.dismissed") !== "true"
setBackgroundImage(active)
document.documentElement.toggleAttribute("data-background-image", active)
if (image) {
document.documentElement.style.setProperty(
"--app-background-image",
`url("oc://renderer/background-image?revision=${encodeURIComponent(image.revision)}")`,
)
return true
}
if (active) {
document.documentElement.style.setProperty("--app-background-image", `url("${defaultBackground}")`)
return true
}
document.documentElement.style.removeProperty("--app-background-image")
return false
}
Expand Down Expand Up @@ -333,11 +339,13 @@ const createPlatform = (windowState: DesktopWindowState): Platform => {
async selectBackgroundImage() {
const image = await window.api.selectBackgroundImage()
if (!image) return backgroundImage()
localStorage.removeItem("background-image.default.dismissed")
return applyBackgroundImage(image)
},

async clearBackgroundImage() {
await window.api.clearBackgroundImage()
localStorage.setItem("background-image.default.dismissed", "true")
applyBackgroundImage(null)
},

Expand Down
Loading