Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Convert search store to an options store #1259

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</template>

<script>
import { ref, useContext, useRouter } from '@nuxtjs/composition-api'
import { onMounted, ref, useContext, useRouter } from '@nuxtjs/composition-api'

import { ALL_MEDIA, supportedSearchTypes } from '~/constants/media'
import { isMinScreen } from '~/composables/use-media-query'
Expand Down Expand Up @@ -177,6 +177,13 @@ const HomePage = {
const mediaStore = useMediaStore()
const searchStore = useSearchStore()

/**
* Reset the search type, search term and filters when the user navigates [back] to the homepage.
*/
onMounted(() => {
searchStore.$reset()
})
Comment on lines +183 to +185
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this clears all the search information, but it doesn't clear the results. So given the following flow:

  • Search for 'dogs' on the homepage
  • See the results on the /search page
  • Click the openverse logo / home link
  • Make a new search for 'cats'

The user will see a flash of dog results while the 'cat' results are loading.

Not sure if that's a problem or should be fixed here, just noting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you for noting this! I'll add add the result reset, too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wait. This will require the reset in the media store. Let me make an issue for fixing it after one of the store PRs is merged.


const featuredSearches = imageInfo.sets.map((setItem) => ({
...setItem,
images: setItem.images.map((imageItem) => ({
Expand Down
Loading