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

Commit

Permalink
Tighten the condition for audio playback to continue across pages (#2147
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dhruvkb authored Feb 8, 2023
1 parent e31a8ae commit 695247c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/VAudioTrack/VAudioTrack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ import {
layoutMappings,
} from "~/constants/audio"
import { useSeekable } from "~/composables/use-seekable"
import {
useMatchSearchRoutes,
useMatchSingleResultRoutes,
} from "~/composables/use-match-routes"
import { defineEvent } from "~/types/emits"
Expand Down Expand Up @@ -304,9 +308,13 @@ export default defineComponent({
localAudio?.removeEventListener(name, fn)
)
const { matches: isSearchRoute } = useMatchSearchRoutes()
const { matches: isSingleResultRoute } = useMatchSingleResultRoutes()
if (
route.value?.params?.id === props.audio.id ||
mediaStore.getItemById(AUDIO, props.audio.id)
(isSingleResultRoute.value &&
route.value?.params?.id === props.audio.id) ||
(isSearchRoute.value && mediaStore.getItemById(AUDIO, props.audio.id))
) {
/**
* If switching to any route other than the single result
Expand Down
6 changes: 6 additions & 0 deletions test/unit/specs/components/AudioTrack/v-audio-track.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const mockI18n = new Vuei18n({
messages: { en: enMessages },
})

jest.mock("~/composables/use-match-routes", () => ({
// mocking `Ref<boolean>` as `{ value: boolean }`
useMatchSearchRoutes: jest.fn(() => ({ matches: { value: false } })),
useMatchSingleResultRoutes: jest.fn(() => ({ matches: { value: false } })),
}))

jest.mock("~/composables/use-browser-detection", () => ({
useBrowserIsBlink: jest.fn(() => false),
}))
Expand Down

0 comments on commit 695247c

Please sign in to comment.