Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(plugins): "Update all" on the phone updates the plugins one after another

Maurice8dd8635b8759
diff --git a/client/src/components/Admin/plugins/usePluginsAdmin.test.ts b/client/src/components/Admin/plugins/usePluginsAdmin.test.ts
index ce22de7a5..890434571 100644
--- a/client/src/components/Admin/plugins/usePluginsAdmin.test.ts
+++ b/client/src/components/Admin/plugins/usePluginsAdmin.test.ts
@@ -66,8 +66,8 @@ function deferred<T>() {
return { promise, resolve };
}
-async function mounted(options?: Parameters<typeof usePluginsAdmin>[0]) {
- const hook = renderHook(() => usePluginsAdmin(options));
+async function mounted() {
+ const hook = renderHook(() => usePluginsAdmin());
await waitFor(() => expect(hook.result.current.loading).toBe(false));
return hook;
}
@@ -184,7 +184,7 @@ describe('usePluginsAdmin', () => {
expect(toast.error).not.toHaveBeenCalled();
});
- it('FE-ADMIN-PLUGINS-HOOK-008: by default Update all runs the updates one after another', async () => {
+ it('FE-ADMIN-PLUGINS-HOOK-008: Update all runs the updates one after another', async () => {
serve([row({ id: 'a', name: 'A' }), row({ id: 'b', name: 'B' })], [entry({ id: 'a' }), entry({ id: 'b' })]);
const first = deferred<unknown>();
const update = vi
@@ -205,18 +205,15 @@ describe('usePluginsAdmin', () => {
expect(update).toHaveBeenCalledTimes(2);
});
- it('FE-ADMIN-PLUGINS-HOOK-009: with updateAllInParallel every update starts at once, without a version', async () => {
+ it('FE-ADMIN-PLUGINS-HOOK-009: Update all starts only the first update, without a version', async () => {
serve([row({ id: 'a', name: 'A' }), row({ id: 'b', name: 'B' })], [entry({ id: 'a' }), entry({ id: 'b' })]);
const update = vi.spyOn(adminApi, 'pluginUpdate').mockReturnValue(new Promise(() => {}));
- const { result } = await mounted({ updateAllInParallel: true });
+ const { result } = await mounted();
await waitFor(() => expect(result.current.updatable).toHaveLength(2));
act(() => {
void result.current.updateAll();
});
- expect(update.mock.calls).toEqual([
- ['a', undefined],
- ['b', undefined],
- ]);
+ expect(update.mock.calls).toEqual([['a', undefined]]);
});
it('FE-ADMIN-PLUGINS-HOOK-010: the drop overlay arms on a file drag and ignores an unmatched leave', async () => {
diff --git a/client/src/components/Admin/plugins/usePluginsAdmin.ts b/client/src/components/Admin/plugins/usePluginsAdmin.ts
index 98cb934eb..a1717ce2e 100644
--- a/client/src/components/Admin/plugins/usePluginsAdmin.ts
+++ b/client/src/components/Admin/plugins/usePluginsAdmin.ts
@@ -26,11 +26,6 @@ import {
type VersionMismatch,
} from './pluginModel';
-interface UsePluginsAdminOptions {
- /** Start every pending update at once from "Update all" instead of one after another. */
- updateAllInParallel?: boolean;
-}
-
/**
* Admin > Plugins, the logic behind both shells (the desktop panel and the phone panel
* render their own markup over it): the installed list and the registry, the toolbar
@@ -38,7 +33,7 @@ interface UsePluginsAdminOptions {
* updates and version switches, signature refusals and re-trust, egress hosts, error
* logs and the instance settings form.
*/
-export function usePluginsAdmin({ updateAllInParallel = false }: UsePluginsAdminOptions = {}) {
+export function usePluginsAdmin() {
const { t } = useTranslation();
const toast = useToast();
const [runtimeOn, setRuntimeOn] = useState(false);
@@ -549,15 +544,8 @@ export function usePluginsAdmin({ updateAllInParallel = false }: UsePluginsAdmin
const updatable = useMemo(() => plugins.filter((p) => isUpdateAvailable(p, latest)), [plugins, latest]);
// One after another: busy is a single slot, so parallel updates would leave the
- // other rows clickable mid-install and refresh once per plugin. The phone still
- // starts them all at once (updateAllInParallel).
+ // other rows clickable mid-install and refresh once per plugin.
const updateAll = async () => {
- if (updateAllInParallel) {
- // p => runUpdate(p), NOT forEach(runUpdate): forEach's index would land in
- // runUpdate's `version` parameter and pin the update to a number.
- updatable.forEach((p) => void runUpdate(p));
- return;
- }
for (const p of updatable) await runUpdate(p);
};
diff --git a/client/src/mobile/screens/admin/MAdminPluginsPanel.tsx b/client/src/mobile/screens/admin/MAdminPluginsPanel.tsx
index cd7b4f03d..d49dec817 100644
--- a/client/src/mobile/screens/admin/MAdminPluginsPanel.tsx
+++ b/client/src/mobile/screens/admin/MAdminPluginsPanel.tsx
@@ -128,7 +128,7 @@ export default function MAdminPluginsPanel() {
updatable, updateAll, shownInstalled, shownRegistry, anyFilter, ignoreTrekRange, rowMenuPlugin, reviewBlock,
askUninstall, uninstallConfirmed, downgradeConfirmed, retrustBlocked, consentUnsigned, approveConsent,
deferConsent, downloadDependency,
- } = usePluginsAdmin({ updateAllInParallel: true })
+ } = usePluginsAdmin()
return (
<div className="relative space-y-3"