提交 ecb1a65b 编写于 作者: M Matt Bierner

💄

上级 3bdb4a9e
......@@ -8,7 +8,10 @@
const resourceRoot = '/vscode-resource';
/**
* @typedef {{resolve: () => void, promise: Promise<Response> }} ResourcePathEntry
* @typedef {{
* resolve: () => void,
* promise: Promise<Response>
* }} ResourcePathEntry
*/
/**
......@@ -105,17 +108,14 @@ self.addEventListener('fetch', (event) => {
const webviewId = getWebviewIdForClient(client);
const resourcePath = requestUrl.pathname.replace(resourceRoot, '');
const allClients = await self.clients.matchAll({ includeUncontrolled: true });
// Check if we've already resolved this request
const existing = resourceRequestManager.get(webviewId, resourcePath);
if (existing) {
return existing.promise.then(r => r.clone());
}
const allClients = await self.clients.matchAll({ includeUncontrolled: true });
if (resourceRequestManager.has(webviewId, resourcePath)) {
// Someone else added it in the meantime
return resourceRequestManager.get(resourceRequestManager).promise.then(r => r.clone());
}
// Find parent iframe
for (const client of allClients) {
const clientUrl = new URL(client.url);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册