Skip to content

Commit

Permalink
Update the Settings Model with the server
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Guidée <[email protected]>
  • Loading branch information
quentinguidee committed Nov 27, 2023
1 parent 7f68b7a commit 47d11a2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function SettingsNotifications() {
});

useEffect(() => {
setWebhook(settings?.notifications?.webhook);
setWebhook(settings?.webhook);
}, [settings]);

const onWebhookChange = (e: any) => {
Expand All @@ -38,7 +38,7 @@ export default function SettingsNotifications() {
const onSave = () => {
setSaving(true);
api.settings
.patch({ notifications: { webhook } })
.patch({ webhook })
.then(() => setChanged(false))
.catch(console.error)
.finally(() => setSaving(false));
Expand Down
2 changes: 1 addition & 1 deletion src/apps/Settings/SettingsUpdates/SettingsUpdates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function SettingsUpdates() {
<Paragraph>Enable Beta channel</Paragraph>
<Spacer />
<ToggleButton
value={settings?.updates?.channel === "beta"}
value={settings?.updates_channel === "beta"}
onChange={(beta: boolean) => setChannel(beta)}
disabled={isLoading}
/>
Expand Down
4 changes: 1 addition & 3 deletions src/apps/Settings/hooks/useSettingsMutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export const useSettingsChannelMutation = (
mutationKey: ["settings"],
mutationFn: (beta?: boolean) =>
api.settings.patch({
updates: {
channel: beta ? "beta" : "stable",
},
updates_channel: beta ? "beta" : "stable",
}),
...options,
});
Expand Down
9 changes: 2 additions & 7 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
type Settings = {
notifications?: {
webhook?: string;
};

updates?: {
channel?: string;
};
webhook?: string;
updates_channel?: string;
};

0 comments on commit 47d11a2

Please sign in to comment.