From 8e9fb7dfcb3424e1f86207aec8d2077c2cbd43ba Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Wed, 24 Jan 2024 12:52:09 -0500 Subject: [PATCH] fix: hostd lastannouncement error saving config --- .changeset/twenty-seals-allow.md | 5 +++++ apps/hostd/contexts/config/useOnValid.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/twenty-seals-allow.md diff --git a/.changeset/twenty-seals-allow.md b/.changeset/twenty-seals-allow.md new file mode 100644 index 000000000..513b8686a --- /dev/null +++ b/.changeset/twenty-seals-allow.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +Fixed an error with "lastAnnouncement" that occurs the first time the configuration is saved. diff --git a/apps/hostd/contexts/config/useOnValid.tsx b/apps/hostd/contexts/config/useOnValid.tsx index 584c55d45..912cd89c7 100644 --- a/apps/hostd/contexts/config/useOnValid.tsx +++ b/apps/hostd/contexts/config/useOnValid.tsx @@ -52,7 +52,7 @@ export function useOnValid({ throw Error(response.error) } const needsToAnnounce = - host.data.lastAnnouncement?.address !== values.netAddress + host.data?.lastAnnouncement?.address !== values.netAddress if (needsToAnnounce) { triggerSuccessToast( 'Settings have been saved. Address has changed, make sure to re-announce the host.', @@ -69,7 +69,7 @@ export function useOnValid({ console.log(e) } }, - [showAdvanced, resources, settingsUpdate, revalidateAndResetForm, host] + [showAdvanced, resources, settingsUpdate, revalidateAndResetForm, host.data] ) return onValid }