Skip to content

Commit 3844949

Browse files
committed
Fix useRampQuotes to preserve errors
1 parent 616167d commit 3844949

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/hooks/useRampQuotes.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ export const useRampQuotes = ({
7777

7878
// Determine which plugins need fresh quotes
7979
const pluginsNeedingRefresh = new Set<string>()
80-
const validPrevQuotes = new Map<string, RampQuoteResult[]>()
80+
const validPrevResults = new Map<
81+
string,
82+
Result<RampQuoteResult[], QuoteError>
83+
>()
8184

8285
// Check previous results for expired quotes
8386
prevResults.forEach(result => {
@@ -95,8 +98,14 @@ export const useRampQuotes = ({
9598
if (hasExpiredQuotes || validQuotes.length === 0) {
9699
pluginsNeedingRefresh.add(pluginId)
97100
} else {
98-
validPrevQuotes.set(pluginId, validQuotes)
101+
// Store the complete successful result with only valid quotes
102+
validPrevResults.set(pluginId, { ok: true, value: validQuotes })
99103
}
104+
} else {
105+
// Preserve error results as-is
106+
const pluginId = result.error.pluginId
107+
validPrevResults.set(pluginId, result)
108+
// Don't add to pluginsNeedingRefresh - we keep the error
100109
}
101110
})
102111

@@ -176,10 +185,10 @@ export const useRampQuotes = ({
176185
mergedResults.push(result)
177186
})
178187

179-
// Add valid previous results for plugins we didn't refresh
180-
validPrevQuotes.forEach((quotes, pluginId) => {
188+
// Add valid previous results (including errors) for plugins we didn't refresh
189+
validPrevResults.forEach((result, pluginId) => {
181190
if (!pluginsNeedingRefresh.has(pluginId)) {
182-
mergedResults.push({ ok: true, value: quotes })
191+
mergedResults.push(result)
183192
}
184193
})
185194

0 commit comments

Comments
 (0)