Skip to content

Commit

Permalink
feat: update secret when changed (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: kunish <[email protected]>
  • Loading branch information
PuerNya and kunish authored Aug 31, 2023
1 parent 21e2b29 commit 935908e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/pages/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ export default () => {
const { form } = createForm<z.infer<typeof schema>>({
extend: validator({ schema }),
async onSubmit({ url, secret }) {
const endpointFromHistory = endpointList().find(
(history) => history.url === url && history.secret === secret,
)
const i = endpointList().findIndex((history) => history.url === url)

if (endpointFromHistory) {
onSetupSuccess(endpointFromHistory.id)
if (i > -1) {
const { id, secret: oldSecret } = endpointList()[i]

if (secret !== oldSecret && !(await checkEndpoint(url, secret))) {
endpointList()[i].secret = secret
setEndpointList(endpointList())
}

onSetupSuccess(id)
return
}

Expand Down

0 comments on commit 935908e

Please sign in to comment.