Skip to content

Commit

Permalink
Merge pull request #314 from amansinghbais/#313
Browse files Browse the repository at this point in the history
Improved: clearing gitbook search modal queries on modal dismiss and promise for fetching resources (#313)
  • Loading branch information
ymaheshwari1 authored Jul 18, 2024
2 parents 6cb6667 + a9a3087 commit 23d3b96
Showing 1 changed file with 15 additions and 2 deletions.
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>

0 comments on commit 23d3b96

Please sign in to comment.