diff --git a/backend/events.go b/backend/events.go index df88833..2c6bcf4 100644 --- a/backend/events.go +++ b/backend/events.go @@ -144,14 +144,15 @@ func CreateEventsHandler(notifier *Notifier[Notification]) http.HandlerFunc { w.Header().Set("Connection", "keep-alive") // w.(http.Flusher).Flush() - if err := notifier.Create(userId.String()); err != nil { - // TODO: this could be better. - // EG: The user could attempt to create many connections - // and they just get a 500, with no explanation. - w.WriteHeader(http.StatusInternalServerError) - // w.(http.Flusher).Flush() - return - } + // if err := notifier.Create(userId.String()); err != nil { + // // TODO: this could be better. + // // EG: The user could attempt to create many connections + // // and they just get a 500, with no explanation. + // fmt.Println(err) + // w.WriteHeader(http.StatusInternalServerError) + // // w.(http.Flusher).Flush() + // return + // } listener := notifier.Listeners[userId.String()] @@ -171,7 +172,7 @@ func CreateEventsHandler(notifier *Notifier[Notification]) http.HandlerFunc { fmt.Printf("Sending msg %s\n", msg) fmt.Fprintf(w, "event: data\ndata: %s\n\n", string(msgString)) - // w.(http.Flusher).Flush() + w.(http.Flusher).Flush() } } } diff --git a/frontend/src/notifications/index.ts b/frontend/src/notifications/index.ts index 881e413..493a87d 100644 --- a/frontend/src/notifications/index.ts +++ b/frontend/src/notifications/index.ts @@ -54,27 +54,14 @@ export const Notifications = (onCompleteImage: () => void) => { return; } + console.log("SSE: ", processingImage); + const { ImageID, Status } = processingImage.output; - if (state.ProcessingImages[ImageID] != null) { - const localImageStatus = state.ProcessingImages[ImageID]; - if (localImageStatus !== "in-progress" || Status !== "complete") { - console.error( - "Invalid state, an image present must always be in process", - ); - return; - } - + if (Status === "complete") { setState("ProcessingImages", ImageID, undefined); onCompleteImage(); } else { - if (Status !== "in-progress") { - console.error( - "Invalid state, at this point a new image that isn't present should be in-progress", - ); - return; - } - setState("ProcessingImages", ImageID, Status); } };