Skip to content

Commit

Permalink
fixed Something on the server is not working feedback with successful…
Browse files Browse the repository at this point in the history
… refresh.
  • Loading branch information
bengarrett committed Sep 24, 2024
1 parent e752ee6 commit f7bc0b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 8 additions & 2 deletions assets/js/editor-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,18 @@ import { getElmById } from "./helper.mjs";
}
const errClass = "text-danger";
const xhr = event.detail.xhr;
if (event.detail.successful) {
const statusFound = xhr.status === 200 || xhr.status === 302;
if ((event.detail && event.detail.successful) || statusFound) {
feedback.innerText = `${xhr.responseText}`;
feedback.classList.remove(errClass);
return;
}
if (event.detail.failed && event.detail.xhr) {
if (
event.detail &&
event.detail.failed !== undefined &&
event.detail.failed &&
event.detail.xhr
) {
feedback.classList.add(errClass);
feedback.innerText =
`Something on the server is not working, ` +
Expand Down
6 changes: 2 additions & 4 deletions handler/htmx/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ var (
//
// [HTMX header]: https://htmx.org/reference/#response_headers
func pageRefresh(c echo.Context) echo.Context {
res := c.Response()
const htmxRefresh = "HX-Refresh"
res.Header().Set(htmxRefresh, "true")
res.WriteHeader(http.StatusOK)
c.Response().Header().Set("HX-Refresh", "true")
c.Response().WriteHeader(http.StatusFound)
return c
}

Expand Down
2 changes: 1 addition & 1 deletion public/js/editor-assets.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7bc0b8

Please sign in to comment.