Skip to content

Commit

Permalink
fix: don't fetch unused cache, FF fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 authored and hargoniX committed Sep 21, 2023
1 parent cf072e2 commit 8000418
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions static/declaration-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export class DeclarationDataCenter {
);

// try to use cache first
const data = await fetchCachedDeclarationData().catch(_e => null);
// TODO: This API is not thought 100% through. If we have a DB cached
// already it will not even ask the remote for a new one so we end up
// with outdated declaration-data. This has to have some form of cache
// invalidation: https://github.com/leanprover/doc-gen4/issues/133
// const data = await fetchCachedDeclarationData().catch(_e => null);
const data = null;
if (data) {
// if data is defined, use the cached one.
return new DeclarationDataCenter(data);
Expand All @@ -72,7 +77,7 @@ export class DeclarationDataCenter {
* Search for a declaration.
* @returns {Array<any>}
*/
search(pattern, strict = true, allowedKinds=undefined, maxResults=undefined) {
search(pattern, strict = true, allowedKinds = undefined, maxResults = undefined) {
if (!pattern) {
return [];
}
Expand Down Expand Up @@ -258,12 +263,7 @@ async function fetchCachedDeclarationData() {
return new Promise((resolve, reject) => {
let transactionRequest = store.get(CACHE_DB_KEY);
transactionRequest.onsuccess = function (event) {
// TODO: This API is not thought 100% through. If we have a DB cached
// already it will not even ask the remote for a new one so we end up
// with outdated declaration-data. This has to have some form of cache
// invalidation: https://github.com/leanprover/doc-gen4/issues/133
//resolve(event.target.result);
resolve(undefined);
resolve(event.target.result);
};
transactionRequest.onerror = function (event) {
reject(new Error(`fail to store declaration data`));
Expand Down
2 changes: 1 addition & 1 deletion static/find/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const queryParams = new Map(
const fragmentPaths = fragment?.split(LEAN_FRIENDLY_SLASH_SEPARATOR) ?? [];

const encodedPattern = queryParams.get("pattern") ?? fragmentPaths[1]; // if first fail then second, may be undefined
const pattern = decodeURIComponent(encodedPattern);
const pattern = encodedPattern && decodeURIComponent(encodedPattern);
const strict = (queryParams.get("strict") ?? "true") === "true"; // default to true
const view = fragmentPaths[0];

Expand Down

0 comments on commit 8000418

Please sign in to comment.