mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
refactor: make transcoding support more deterministic
This commit is contained in:
parent
d73028fb0c
commit
a64353aedc
3 changed files with 10 additions and 16 deletions
|
@ -1,27 +1,20 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import { screen } from '@testing-library/vue'
|
||||
import isMobile from 'ismobilejs'
|
||||
import { commonStore } from '@/stores'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import PreferencesForm from './PreferencesForm.vue'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
it('has "Transcode on mobile" option for mobile users', () => {
|
||||
isMobile.phone = true
|
||||
it('has "Transcode on mobile" option if supported', () => {
|
||||
commonStore.state.supports_transcoding = true
|
||||
this.render(PreferencesForm)
|
||||
screen.getByTestId('transcode_on_mobile')
|
||||
})
|
||||
|
||||
it('does not have "Transcode on mobile" option for non-mobile users', async () => {
|
||||
isMobile.phone = false
|
||||
this.render(PreferencesForm)
|
||||
expect(screen.queryByTestId('transcode_on_mobile')).toBeNull()
|
||||
})
|
||||
|
||||
it('does not have "Transcode on mobile" option if transcoding is not supported', async () => {
|
||||
isMobile.phone = true
|
||||
it('does not have "Transcode on mobile" option if not supported', async () => {
|
||||
commonStore.state.supports_transcoding = false
|
||||
this.render(PreferencesForm)
|
||||
expect(screen.queryByTestId('transcode_on_mobile')).toBeNull()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
Playing a song or episode triggers continuous playback of the entire playlist, album, artist, genre, or podcast
|
||||
</div>
|
||||
</FormRow>
|
||||
<FormRow v-if="isPhone">
|
||||
<FormRow v-if="onMobile">
|
||||
<div>
|
||||
<CheckBox v-model="preferences.show_now_playing_notification" name="notify" />
|
||||
Show “Now Playing” notification
|
||||
</div>
|
||||
</FormRow>
|
||||
<FormRow v-if="!isPhone">
|
||||
<FormRow v-if="!onMobile">
|
||||
<div>
|
||||
<CheckBox v-model="preferences.confirm_before_closing" name="confirm_closing" />
|
||||
Confirm before closing Koel
|
||||
|
@ -53,17 +53,17 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import isMobile from 'ismobilejs'
|
||||
import { computed } from 'vue'
|
||||
import { toRef } from 'vue'
|
||||
import { commonStore, preferenceStore as preferences } from '@/stores'
|
||||
import { useKoelPlus } from '@/composables'
|
||||
|
||||
import CheckBox from '@/components/ui/form/CheckBox.vue'
|
||||
import FormRow from '@/components/ui/form/FormRow.vue'
|
||||
|
||||
const isPhone = isMobile.phone
|
||||
const onMobile = isMobile.any
|
||||
const { isPlus } = useKoelPlus()
|
||||
|
||||
const showTranscodingOption = computed(() => isPhone && commonStore.state.supports_transcoding)
|
||||
const showTranscodingOption = toRef(commonStore.state, 'supports_transcoding')
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
|
|
|
@ -14,6 +14,7 @@ export const defaultPreferences: UserPreferences = {
|
|||
artists_view_mode: null,
|
||||
albums_view_mode: null,
|
||||
transcode_on_mobile: false,
|
||||
transcode_quality: 128,
|
||||
support_bar_no_bugging: false,
|
||||
show_album_art_overlay: true,
|
||||
lyrics_zoom_level: 1,
|
||||
|
|
Loading…
Reference in a new issue