fix(files): an upload is announced once, as an upload, and a finish shows in Files at once
An upload that came back done was announced twice: by the upload dialog ("File uploaded") and
again by the tray, which saw a job turn done ("Downloaded: …"). The dialog now marks its job as
announced, so the queue keeps it for the tray but does not say it again. An upload the worker
converted first is still the tray's to announce, now as "Uploaded: …".
A finished job's notice offered "Open" while Files still listed the folder without it (its own
poll runs every 15 s): the tray now refreshes the library the moment it sees a finish.
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import type { QueueJob } from "../lib/api";
|
||||
import { quickShareLink } from "../lib/downloads";
|
||||
import { invalidateDownloads, quickShareLink } from "../lib/downloads";
|
||||
import { failCopyKeys, failTitleKey } from "../lib/downloadFailure";
|
||||
import {
|
||||
IN_FLIGHT,
|
||||
@@ -190,7 +190,10 @@ export default function DownloadTray() {
|
||||
const title = jobTitle(job);
|
||||
notify({
|
||||
level: "success",
|
||||
title: t("tray.done.title", { title }),
|
||||
// An upload the worker had to convert first is done here too — it was never downloaded.
|
||||
title: t(job.source_key === "upload" ? "tray.done.uploadedTitle" : "tray.done.title", {
|
||||
title,
|
||||
}),
|
||||
message: t(job.asset?.media_kind === "file" ? "tray.done.file" : "tray.done.phone"),
|
||||
action: { label: t("tray.done.copyLink"), onClick: () => void quickShareLink(qc, job, t) },
|
||||
secondaryAction: {
|
||||
@@ -202,8 +205,12 @@ export default function DownloadTray() {
|
||||
const fresh = useUnannounced();
|
||||
useEffect(() => {
|
||||
// The take clears them, so a second pass (StrictMode, a re-render) announces nothing again.
|
||||
if (fresh.length) takeUnannounced().forEach(announce);
|
||||
}, [fresh]);
|
||||
if (!fresh.length) return;
|
||||
// A notice that offers "Open" while Files still lists the folder without the file (its own poll
|
||||
// is slower) sends the reader to something not there yet.
|
||||
invalidateDownloads(qc);
|
||||
takeUnannounced().forEach(announce);
|
||||
}, [fresh, qc]);
|
||||
|
||||
// --- Back to top steps up over the tray while it shows -----------------------------------------
|
||||
useLayoutEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user