fix: surface segment save errors in editor
This commit is contained in:
@@ -205,7 +205,7 @@ func (h *PlaybackHandler) HandleUpsertSkipSegment(c *gin.Context) {
|
||||
userID = u.ID
|
||||
}
|
||||
if userID == "" {
|
||||
c.Status(http.StatusUnauthorized)
|
||||
c.JSON(http.StatusUnauthorized, gin.H{"error": "login required"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -217,12 +217,12 @@ func (h *PlaybackHandler) HandleUpsertSkipSegment(c *gin.Context) {
|
||||
EndTime float64 `json:"end_time"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.Status(http.StatusBadRequest)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request body"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.svc.UpsertSkipSegmentOverride(c.Request.Context(), userID, req.MalID, req.Episode, req.SkipType, req.StartTime, req.EndTime); err != nil {
|
||||
c.Status(http.StatusBadRequest)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,12 @@ export const setupSegmentEditor = (): void => {
|
||||
}),
|
||||
});
|
||||
if (!res.ok) {
|
||||
setError(res.status === 401 ? 'Login required.' : 'Failed to save segment.');
|
||||
let message = res.status === 401 ? 'Login required.' : 'Failed to save segment.';
|
||||
try {
|
||||
const payload = (await res.json()) as { error?: string };
|
||||
if (payload?.error) message = payload.error;
|
||||
} catch {}
|
||||
setError(message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user