-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix resource refresh button not triggering re-fetch #1148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
234b209
3054236
5a2895a
6976069
54d86b4
4076036
42c7a01
82f7104
d15a525
d02e6c1
ffde8cb
c593fb8
01ea4cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -151,6 +151,9 @@ const App = () => { | |||||||||||||||||
| const [resourceContentMap, setResourceContentMap] = useState< | ||||||||||||||||||
| Record<string, string> | ||||||||||||||||||
| >({}); | ||||||||||||||||||
| const [resourceErrorMap, setResourceErrorMap] = useState< | ||||||||||||||||||
| Record<string, string> | ||||||||||||||||||
| >({}); | ||||||||||||||||||
| const [fetchingResources, setFetchingResources] = useState<Set<string>>( | ||||||||||||||||||
| new Set(), | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
@@ -902,13 +905,32 @@ const App = () => { | |||||||||||||||||
| setPromptContent(JSON.stringify(response, null, 2)); | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| const readResource = async (uri: string) => { | ||||||||||||||||||
| if (fetchingResources.has(uri) || resourceContentMap[uri]) { | ||||||||||||||||||
| const readResource = async ( | ||||||||||||||||||
| uri: string, | ||||||||||||||||||
| { bypassCache = false }: { bypassCache?: boolean } = {}, | ||||||||||||||||||
| ) => { | ||||||||||||||||||
| if (fetchingResources.has(uri)) { | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const hasOwn = Object.prototype.hasOwnProperty; | ||||||||||||||||||
| if ( | ||||||||||||||||||
| !bypassCache && | ||||||||||||||||||
| hasOwn.call(resourceContentMap, uri) && | ||||||||||||||||||
| !hasOwn.call(resourceErrorMap, uri) | ||||||||||||||||||
| ) { | ||||||||||||||||||
| setResourceContent(resourceContentMap[uri]); | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
||||||||||||||||||
| setResourceErrorMap((prev) => { | |
| if (!hasOwn.call(prev, uri)) return prev; | |
| const next = { ...prev }; | |
| delete next[uri]; | |
| return next; | |
| }); |
Uh oh!
There was an error while loading. Please reload this page.