Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: clearing gitbook search modal queries on modal dismiss and promise for fetching resources (#313) #314

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/components/DxpGitBookSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</ion-tab-button>

<!-- Using inline modal(as recommended by ionic), also using it inline as the component inside modal is not getting mounted when using modalController -->
<ion-modal ref="gitBookSearchModal" trigger="gibook-search-modal">
<ion-modal ref="gitBookSearchModal" trigger="gibook-search-modal" @willDismiss="clearQueryState()">
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
Expand Down Expand Up @@ -230,7 +230,7 @@ async function fetchSources() {
isResourceLoading.value = true;
const list = [] as any;

const responses = await Promise.all(answer.value.sources.map((source: any) => {
const responses = await (Promise as any).allSettled(answer.value.sources.map((source: any) => {
if(source.type === "page") {
return gitBookContext.getGitBookPage({
pageId: source.page,
Expand Down Expand Up @@ -260,4 +260,17 @@ function searchRelatedQuestion(question: string) {
queryString.value = question;
askQuery()
}

function clearQueryState() {
selectedSegment.value = "search";
queryString.value = "";
searchedItems.value = [];
answer.value = {};

isLoading.value = false;

isResourceLoading.value = false;
sources.value = [];
isResourceFetched.value = false;
}
</script>
Loading