Auto-fetch contract on symbol enable; hide contract when disabled
- POST /api/instruments/contracts now accepts optional { symbols[] } body
to resolve a subset rather than all enabled instruments
- Settings toggle() fires a targeted resolve when enabling a symbol,
merging the result into contracts state without a full page refresh
- Active Contract cell is hidden (null) when the instrument is disabled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6d3e8b6065
commit
cade280b2d
+18
-4
@@ -67,6 +67,22 @@ export default function SettingsPage() {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ enabled }),
|
||||
});
|
||||
|
||||
// When enabling a symbol, auto-resolve its active contract
|
||||
if (enabled) {
|
||||
fetch('/api/instruments/contracts', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ symbols: [symbol] }),
|
||||
})
|
||||
.then((r) => r.json())
|
||||
.then((fresh: Record<string, ResolvedContract | null>) => {
|
||||
if (!fresh.error) {
|
||||
setContracts((prev) => ({ ...prev, ...fresh }));
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
async function saveSettings() {
|
||||
@@ -161,7 +177,7 @@ export default function SettingsPage() {
|
||||
{instr.symbol}
|
||||
</td>
|
||||
<td className="px-4 py-2.5">
|
||||
{c ? (
|
||||
{instr.enabled && c ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={`font-mono text-sm ${wasRolled ? 'text-amber-600 font-semibold' : 'text-slate-600'}`}>
|
||||
{c.name}
|
||||
@@ -177,9 +193,7 @@ export default function SettingsPage() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-xs text-slate-300 italic">—</span>
|
||||
)}
|
||||
) : null}
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-right">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user