Skip to content

Commit

Permalink
Flag corpora outdated after creating, fix #151
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Feb 12, 2024
1 parent 31b8c75 commit 4e8b670
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ As this project is a user-facing application, the places in the semantic version

### Fixed

- Status panel is empty for new corpus, until page is reloaded [#151](https://github.com/spraakbanken/mink-frontend/issues/151)
- Upgraded dependencies

## [1.2.0] (2024-01-17)
Expand Down
4 changes: 4 additions & 0 deletions src/corpus/createCorpus.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@/api/corpusConfig";
import type { AxiosError } from "axios";
import type { MinkResponse } from "@/api/api.types";
import useCorpora from "@/corpora/corpora.composable";

export default function useCreateCorpus() {
const corpusStore = useCorpusStore();
Expand All @@ -20,12 +21,15 @@ export default function useCreateCorpus() {
const { deleteCorpus } = useDeleteCorpus();
const { alert, alertError } = useMessenger();
const mink = useMinkBackend();
const { refreshCorpora } = useCorpora();

async function createCorpus() {
const corpusId = await mink.createCorpus().catch(alertError);
if (!corpusId) return undefined;
// Have the new corpus included in further API calls.
await refreshJwt();
// Mark corpus store outdated. Instead of awaiting to have the ids present, add it manually below.
refreshCorpora();
// Adding the new id to store may trigger API calls, so do it after updating the JWT.
corpusStore.corpora[corpusId] = corpusStore.corpora[corpusId] || {};
return corpusId;
Expand Down

0 comments on commit 4e8b670

Please sign in to comment.