feat(ux): R11 feedback symmetry — Plex/download/rollback/deny notices
Give equal-weight actions equal-weight feedback (R11). S1 Plex error toasts: the watched-toggles (card / season mark-all / episode / info-panel / show mark-all) used to fail silently on 403/404/429; each now surfaces the server reason via a shared notifyActionError() + resyncs the optimistic flip. The playback auto-mark-watched stays intentionally silent (a mid-play toast is noise; the next sync corrects it). New generic lib/actionErrors.ts (Plex + saved views reuse it; notifyYouTubeActionError delegates its non-403 case to it). S2 download-done inbox notification: worker.py emits a best-effort type=download_done notice to the job owner on real completion (regular + edit jobs, not instant cache-hits), rendered/localized in the inbox with an Open-Downloads link. S3 optimistic rollbacks: SavedViewsWidget create/rename/toggle-default/remove/reorder and the inbox revert-state no longer swallow failures — they toast + refetch to resync (the reorder's optimistic order reverts to server truth). S4 access-request deny: deny_invite now emails the requester (send_access_denied), mirroring approve — no more silent limbo.
This commit is contained in:
@@ -34,10 +34,31 @@ from app.downloads import edit as editmod
|
||||
from app.downloads import errors as dlerrors
|
||||
from app.downloads import formats, quota, service, storage
|
||||
from app.models import DownloadJob, MediaAsset
|
||||
from app.notifications import create_notification
|
||||
from app.titles import normalize_title
|
||||
|
||||
log = logging.getLogger("siftlode.worker")
|
||||
|
||||
|
||||
def _notify_download_done(db, job: DownloadJob | None, title: str | None) -> None:
|
||||
"""Post a best-effort 'download ready' notice to the owner's inbox — downloads used to slide to
|
||||
Done silently while scheduler jobs and playlist-push already notified (R11 feedback symmetry).
|
||||
A notification failure must never mask the completed download, so it is isolated + rolled back
|
||||
(mirrors scheduler._notify_done). English title is a fallback; the inbox localizes from `data`."""
|
||||
if not job:
|
||||
return
|
||||
try:
|
||||
create_notification(
|
||||
db,
|
||||
user_id=job.user_id,
|
||||
type="download_done",
|
||||
title=f"Download ready: {title}" if title else "Download ready",
|
||||
data={"title": title},
|
||||
)
|
||||
except Exception:
|
||||
db.rollback()
|
||||
log.exception("failed to write download-done notification for job %s", job.id)
|
||||
|
||||
_stop = threading.Event()
|
||||
|
||||
|
||||
@@ -637,6 +658,7 @@ def _download(job_id: int, asset_id: int, source_kind: str, source_ref: str, spe
|
||||
# display_name is VARCHAR(255) — clip a long title (see _fill_asset_meta_early).
|
||||
job.display_name = meta.title[:255] if meta.title else None
|
||||
db.commit()
|
||||
_notify_download_done(db, job, meta.title)
|
||||
log.info("job %s done: %s", job_id, rel)
|
||||
|
||||
except (_Aborted, editmod.EditAborted):
|
||||
@@ -769,6 +791,7 @@ def _process_edit(job_id: int, asset_id: int) -> None:
|
||||
job.progress = 100
|
||||
job.phase = None
|
||||
db.commit()
|
||||
_notify_download_done(db, job, asset.title if asset else None)
|
||||
log.info("edit job %s done: %s", job_id, rel)
|
||||
|
||||
except editmod.EditAborted:
|
||||
|
||||
Reference in New Issue
Block a user