Skip to content

Commit

Permalink
Fix: 背景画像が更新されない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
shm11C3 committed Nov 23, 2024
1 parent 3375063 commit 93836f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ const Page = () => {
),
};

console.log("displayTarget", displayTarget);

return (
<ErrorBoundary FallbackComponent={ErrorFallback} onError={onError}>
<div className="bg-zinc-200 dark:bg-gray-900 text-gray-900 dark:text-white min-h-screen bg-cover ease-in-out duration-300">
Expand Down
17 changes: 9 additions & 8 deletions src/hooks/useBgImage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSettingsAtom } from "@/atom/useSettingsAtom";
import { convertFileToBase64 } from "@/lib/file";
import { commands } from "@/rspc/bindings";
import { isError } from "@/types/result";
import { isError, isOk } from "@/types/result";
import type { BackgroundImage } from "@/types/settingsType";
import { atom, useAtom } from "jotai";
import { useCallback, useEffect } from "react";
Expand All @@ -18,13 +18,14 @@ export const useBackgroundImage = () => {

const initBackgroundImage = useCallback(async () => {
if (settings.selectedBackgroundImg) {
try {
const base64Image = await commands.getBackgroundImage(
settings.selectedBackgroundImg,
);
setBackgroundImage(`data:image/png;base64,${base64Image}`);
} catch (error) {
console.error("Failed to load background image:", error);
const base64Image = await commands.getBackgroundImage(
settings.selectedBackgroundImg,
);

if (isOk(base64Image)) {
setBackgroundImage(`data:image/png;base64,${base64Image.data}`);
} else {
console.error("Failed to load background image:", base64Image.error);
}
} else {
setBackgroundImage(null);
Expand Down

0 comments on commit 93836f7

Please sign in to comment.