Skip to content

Commit

Permalink
設定更新時のロジックを改良
Browse files Browse the repository at this point in the history
  • Loading branch information
shm11C3 committed Nov 16, 2024
1 parent 067f0f9 commit c1e3d0b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/atom/useSettingsAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ export const useSettingsAtom = () => {
key: K,
value: Settings[K],
) => {
const previousValue = settings[key];

try {
await mapSettingUpdater[key](value);
setSettings((prev) => ({ ...prev, [key]: value }));
await mapSettingUpdater[key](value);
} catch (e) {
console.error(e);
setSettings((prev) => ({ ...prev, [key]: previousValue }));
}
};

Expand Down

0 comments on commit c1e3d0b

Please sign in to comment.