feat: refresh shared chat and server workflows
This commit is contained in:
@@ -9,7 +9,6 @@ const PREVIEW_TARGET_SAMPLE_ID_QUERY_KEY = 'previewSampleId';
|
||||
const PREVIEW_RUNTIME_CACHE_RESET_MARKER_KEY = 'work-app.preview-runtime.cache-reset.v1';
|
||||
const PREVIEW_RUNTIME_CACHE_RESET_PARAM_KEY = '__previewRuntimeCacheReset';
|
||||
const PREVIEW_RUNTIME_CLEANUP_TIMEOUT_MS = 2500;
|
||||
const PREVIEW_RUNTIME_NAVIGATION_GRACE_TIMEOUT_MS = 1200;
|
||||
const PREVIEW_RUNTIME_PRESERVED_QUERY_KEYS = [
|
||||
PREVIEW_RUNTIME_QUERY_KEY,
|
||||
PREVIEW_RUNTIME_PARENT_ORIGIN_KEY,
|
||||
@@ -151,24 +150,23 @@ export async function ensurePreviewRuntimeFreshState() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (resetSearchParam) {
|
||||
const nextUrl = new URL(window.location.href);
|
||||
nextUrl.searchParams.delete(PREVIEW_RUNTIME_CACHE_RESET_PARAM_KEY);
|
||||
window.history.replaceState(window.history.state, '', nextUrl.pathname + nextUrl.search + nextUrl.hash);
|
||||
writePreviewRuntimeCacheResetMarker(currentLocationKey);
|
||||
return;
|
||||
}
|
||||
|
||||
const changed = await withTimeout(clearPreviewRuntimeServiceWorkersAndCaches(), PREVIEW_RUNTIME_CLEANUP_TIMEOUT_MS, false);
|
||||
|
||||
if (!changed) {
|
||||
if (resetSearchParam) {
|
||||
const nextUrl = new URL(window.location.href);
|
||||
nextUrl.searchParams.delete(PREVIEW_RUNTIME_CACHE_RESET_PARAM_KEY);
|
||||
window.history.replaceState(window.history.state, '', `${nextUrl.pathname}${nextUrl.search}${nextUrl.hash}`);
|
||||
}
|
||||
|
||||
writePreviewRuntimeCacheResetMarker(currentLocationKey);
|
||||
return;
|
||||
}
|
||||
|
||||
writePreviewRuntimeCacheResetMarker(currentLocationKey);
|
||||
window.location.replace(buildPreviewRuntimeCacheResetUrl());
|
||||
await new Promise<void>((resolve) => {
|
||||
window.setTimeout(resolve, PREVIEW_RUNTIME_NAVIGATION_GRACE_TIMEOUT_MS);
|
||||
});
|
||||
}
|
||||
|
||||
export function getPreviewRuntimeParentOrigin() {
|
||||
|
||||
Reference in New Issue
Block a user