Skip to content

Commit

Permalink
Remove unused force parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Feb 12, 2024
1 parent 4e8b670 commit a3f1900
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/corpora/corpora.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ export default function useCorpora() {
const { alertError } = useMessenger();
const mink = useMinkBackend();

async function loadCorpora(force = false) {
async function loadCorpora() {
// Skip if already loaded.
if (isCorporaFresh && !force) return;
if (isCorporaFresh) return;

// Store the pending request in module scope, so simultaneous calls will await the same promise.
if (!loadPromise)
// loadCorpusIds has less information, but it is faster and will update UI sooner.
loadPromise = Promise.all([loadCorpusIds(), loadResourceInfo()]);
await loadPromise;

// Unset the promise slot to allow any future, forced calls.
// Unset the promise slot to allow any future calls.
loadPromise = null;
// Register that data has been loaded to skip future, unforced calls.
// Register that data has been loaded to skip future calls.
isCorporaFresh = true;
}

Expand Down
6 changes: 2 additions & 4 deletions src/corpus/corpus.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ export default function useCorpus(corpusId: string) {

/**
* Load data about a corpus and store it.
*
* @param force Calling again will do nothing, unless `force` is enabled
*/
async function loadCorpus(force = false): Promise<void> {
async function loadCorpus(): Promise<void> {
if (!corpusId) {
throw new RangeError("Corpus ID missing");
}

// Make sure the corpus has an entry in the store.
await loadCorpora();
if (isCorpusFresh[corpusId] && !force) {
if (isCorpusFresh[corpusId]) {
return;
}

Expand Down

0 comments on commit a3f1900

Please sign in to comment.