Skip to content

Commit

Permalink
Render ProcessDropdown in Navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Nov 7, 2024
1 parent 19dd190 commit 81bfdfe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 37 deletions.
3 changes: 3 additions & 0 deletions src/lib/components/forms/DocumentUpload.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ progress through the three-part upload process.
isWithinSizeLimit,
} from "$lib/utils/files";
import { getCsrfToken } from "$lib/utils/api";
import { load } from "../processing/ProcessContext.svelte";
export let files: File[] = getFilesToUpload();
export let projects: Project[] = [];
Expand Down Expand Up @@ -189,6 +190,8 @@ progress through the three-part upload process.
form,
),
);
// Try to load processing context after all uploads are triggered
load();
// errors are handled within each promise, so we can just wait for all to be settled
await Promise.allSettled(promises);
Expand Down
2 changes: 0 additions & 2 deletions src/lib/components/layouts/AppLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import Navigation from "./Navigation.svelte";
import PlausibleTracker from "../common/PlausibleTracker.svelte";
import ProcessContext from "../processing/ProcessContext.svelte";
import ProcessDrawer from "../processing/ProcessDrawer.svelte";
import Toaster from "./Toaster.svelte";
</script>

Expand All @@ -15,7 +14,6 @@
</div>
</Navigation>
<Toaster />
<ProcessDrawer />
</div>
</ProcessContext>
</PlausibleTracker>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/layouts/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import TipOfDay from "../common/TipOfDay.svelte";
import UserMenu from "../accounts/UserMenu.svelte";
import ProcessDropdown from "$lib/components/processing/ProcessDropdown.svelte";
import Portal from "./Portal.svelte";
import Modal from "./Modal.svelte";
import UserFeedback from "../forms/UserFeedback.svelte";
Expand Down Expand Up @@ -49,6 +50,7 @@
<slot name="breadcrumbs">
<Breadcrumbs trail={$page.data.breadcrumbs} />
</slot>
<ProcessDropdown />
{#if !BREAKPOINTS.BOTTOM_NAV}
<SignedIn>
{#if $me}
Expand Down
38 changes: 3 additions & 35 deletions src/lib/components/processing/AddOns.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,11 @@ This component should update on a timer.
import Flex from "../common/Flex.svelte";
import Process from "./Process.svelte";
import { history, dismiss, cancel, rate } from "$lib/api/addons";
import { dismiss, cancel, rate } from "$lib/api/addons";
import { getCsrfToken } from "$lib/utils/api";
import { getRunningAddons } from "./ProcessContext.svelte";
import type { Nullable } from "$lib/api/types";
let timeout: Nullable<string | number | NodeJS.Timeout>;
const running = getRunningAddons();
/*
onMount(async () => {
if ($running.length === 0) {
await load();
}
});
afterUpdate(() => {
if ($running.length > 0) {
timeout = setTimeout(load, POLL_INTERVAL);
}
});
onDestroy(() => {
stop();
});
*/
function stop() {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
}
async function load() {
const { data, error } = await history({ dismissed: false, per_page: 100 });
if (!error) {
$running = data?.results;
}
}
async function rateRun(rating: number, run: Run) {
const csrftoken = getCsrfToken();
Expand All @@ -73,12 +40,13 @@ This component should update on a timer.
}
async function dismissRun(run: Run) {
run = { ...run, dismissed: true }; // optimistic update
const csrftoken = getCsrfToken();
if (!csrftoken) {
console.error("No CSRF token");
run = { ...run, dismissed: false }; // put it back
return;
}
run = { ...run, dismissed: true }; // optimistic update
const { data, error } = await dismiss(run.uuid, csrftoken);
if (error || !data) {
console.error(error?.errors ?? "No data");
Expand Down

0 comments on commit 81bfdfe

Please sign in to comment.