Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor([issue-712]): drop dead approve-error branch + unique busy keys

Adam Eivya112d49bc01f
diff --git a/client/src/components/mobile/MobileApproveFlow.jsx b/client/src/components/mobile/MobileApproveFlow.jsx
index 147f25c3a6..0b42974709 100644
--- a/client/src/components/mobile/MobileApproveFlow.jsx
+++ b/client/src/components/mobile/MobileApproveFlow.jsx
@@ -20,10 +20,7 @@ export default function MobileApproveFlow() {
return null;
});
setBusyId(null);
- if (!result || result.error) {
- if (result?.error) toast.error(result.error);
- return;
- }
+ if (!result) return; // approve rejects on failure → handled by the catch above
toast.success('Approved');
refetch();
};
diff --git a/client/src/components/mobile/MobileLogFlow.jsx b/client/src/components/mobile/MobileLogFlow.jsx
index 56e833e537..f48067a845 100644
--- a/client/src/components/mobile/MobileLogFlow.jsx
+++ b/client/src/components/mobile/MobileLogFlow.jsx
@@ -33,9 +33,10 @@ export default function MobileLogFlow() {
const { data: customDrinks } = useAutoRefetch(() => api.getCustomDrinks({ silent: true }), 300_000);
const { data: customNicotine } = useAutoRefetch(() => api.getCustomNicotineProducts({ silent: true }), 300_000);
- const logDrink = async (drink) => {
- const key = `${drink.name}-${drink.oz}-${drink.abv}`;
- setBusy(key);
+ // busyKey uniquely identifies the tapped button (value signature + index) so
+ // two presets with identical values don't disable together during one tap.
+ const logDrink = async (drink, busyKey) => {
+ setBusy(busyKey);
// silent: this flow owns the error toast in the catch below.
const result = await api.logAlcoholDrink({ name: drink.name, oz: drink.oz, abv: drink.abv }, { silent: true }).catch((err) => {
toast.error(`Log failed: ${err.message}`);
@@ -46,9 +47,8 @@ export default function MobileLogFlow() {
flash(`${drink.name} logged`);
};
- const logNic = async (product) => {
- const key = `${product.product}-${product.mgPerUnit}`;
- setBusy(key);
+ const logNic = async (product, busyKey) => {
+ setBusy(busyKey);
// silent: this flow owns the error toast in the catch below.
const result = await api.logNicotine({ product: product.product, mgPerUnit: product.mgPerUnit }, { silent: true }).catch((err) => {
toast.error(`Log failed: ${err.message}`);
@@ -69,20 +69,16 @@ export default function MobileLogFlow() {
// Normalize both kinds into one button shape { key, label, detail, onTap }
// so a single grid renders either tab.
const buttons = tab === 'alcohol'
- ? [...DRINK_PRESETS, ...(Array.isArray(customDrinks) ? customDrinks : [])].map((d) => ({
- key: `${d.name}-${d.oz}-${d.abv}`,
- label: d.name,
- detail: `${d.oz}oz · ${d.abv}%`,
- onTap: () => logDrink(d),
- }))
+ ? [...DRINK_PRESETS, ...(Array.isArray(customDrinks) ? customDrinks : [])].map((d, i) => {
+ const key = `${d.name}-${d.oz}-${d.abv}-${i}`;
+ return { key, label: d.name, detail: `${d.oz}oz · ${d.abv}%`, onTap: () => logDrink(d, key) };
+ })
: [...NICOTINE_PRESETS, ...(Array.isArray(customNicotine)
? customNicotine.map((p) => ({ product: p.name, mgPerUnit: p.mgPerUnit }))
- : [])].map((p) => ({
- key: `${p.product}-${p.mgPerUnit}`,
- label: p.product,
- detail: `${p.mgPerUnit}mg`,
- onTap: () => logNic(p),
- }));
+ : [])].map((p, i) => {
+ const key = `${p.product}-${p.mgPerUnit}-${i}`;
+ return { key, label: p.product, detail: `${p.mgPerUnit}mg`, onTap: () => logNic(p, key) };
+ });
return (
<div className="space-y-4">
@@ -98,9 +94,9 @@ export default function MobileLogFlow() {
)}
<div className="grid grid-cols-2 gap-3">
- {buttons.map((b, i) => (
+ {buttons.map((b) => (
<button
- key={`${b.key}-${i}`}
+ key={b.key}
onClick={b.onTap}
disabled={busy === b.key}
className="flex min-h-[72px] flex-col items-center justify-center rounded-xl border border-port-border bg-port-card disabled:opacity-50"