diff --git a/apps/app/src/library/SendButton.test.tsx b/apps/app/src/library/SendButton.test.tsx
index 3f7b068..fe31185 100644
--- a/apps/app/src/library/SendButton.test.tsx
+++ b/apps/app/src/library/SendButton.test.tsx
@@ -24,4 +24,30 @@ describe("send button", () => {
fireEvent.click(await screen.findByRole("button", { name: "Enviar de novo a que já tinha ido" }));
await waitFor(() => expect(calls).toEqual([[["a", "b"], false], [["a"], true]]));
});
+
+ it("remembers the chosen destination across a remount (tab switch)", () => {
+ try {
+ window.localStorage.clear();
+ } catch {
+ /* jsdom without storage */
+ }
+ const api = {} as unknown as ApiClient;
+ const targets = [
+ { id: "zz", name: "ZZ", kind: "ZEROZERO" },
+ { id: "fpa", name: "FPA", kind: "NEXTCLOUD" },
+ ] as unknown as DeliveryTarget[];
+ const view = render(
+
+ {}} />
+ ,
+ );
+ fireEvent.change(screen.getByRole("combobox"), { target: { value: "fpa" } });
+ view.unmount();
+ render(
+
+ {}} />
+ ,
+ );
+ expect((screen.getByRole("combobox") as HTMLSelectElement).value).toBe("fpa");
+ });
});
diff --git a/apps/app/src/library/SendButton.tsx b/apps/app/src/library/SendButton.tsx
index bf6e52e..0316b77 100644
--- a/apps/app/src/library/SendButton.tsx
+++ b/apps/app/src/library/SendButton.tsx
@@ -26,7 +26,10 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
const [busy, setBusy] = useState(false);
const [note, setNote] = useState(null);
useEffect(() => {
- if (targets.length && !targets.some((x) => x.id === targetId)) setTargetId(targets[0]!.id);
+ if (targets.length && !targets.some((x) => x.id === targetId)) {
+ setTargetId(targets[0]!.id);
+ prefs.set(LAST_TARGET, targets[0]!.id);
+ }
}, [targets, targetId]);
useEffect(() => setAlready([]), [targetId, eventId]);
useEffect(() => {
@@ -84,7 +87,7 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
{target?.kind === "ZEROZERO" && eventId && }
{targets.length > 1 && (
-