Skip to content

Commit

Permalink
Improved: clearing gitbook search modal queries on modal dismiss and …
Browse files Browse the repository at this point in the history
…promise for fetching resources (hotwax#313)
  • Loading branch information
amansinghbais committed Jul 15, 2024
1 parent 6cb6667 commit a9a3087
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 a9a3087

Please sign in to comment.