Skip to content

Commit

Permalink
Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
dobby5 committed Jul 8, 2023
1 parent 4edd2b4 commit d2d3bde
Show file tree
Hide file tree
Showing 25 changed files with 239 additions and 400 deletions.
4 changes: 2 additions & 2 deletions src/components/ListviewItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<template>
<div>
<ListItem
v-hold="() => emit('menu', item)"
link
:disabled="!itemIsAvailable(item) || isDisabled"
@click.stop="emit('click', item)"
@click.right.prevent="emit('menu', item)"
v-hold="() => emit('menu', item)"
>
<template #prepend>
<div v-if="showCheckboxes" class="media-thumb listitem-media-thumb">
Expand Down Expand Up @@ -56,7 +56,7 @@
<!-- subtitle -->
<template #subtitle>
<!-- track: artists(s) + album -->
<div class="line-clamp-1" v-if="item.media_type == MediaType.TRACK">
<div v-if="item.media_type == MediaType.TRACK" class="line-clamp-1">
<v-item-group>
<v-item v-if="'artists' in item">
{{ getArtistsString(item.artists, 2) }}
Expand Down
2 changes: 1 addition & 1 deletion src/components/MediaItemCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<template #append>
<!-- format -->
<Button
icon
v-if="activePlayerQueue && activePlayerQueue?.active"
icon
:disabled="activePlayerQueue && activePlayerQueue?.items == 0"
@click="api.queueCommandPlayPause(activePlayerQueue!.queue_id)"
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProviderIcons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="provider-icons" style="display: inline-flex" :style="`height: ${height};`">
<v-menu v-for="providerDomain of uniqueProviders" :key="providerDomain" location="bottom end" @click:outside.stop>
<template #activator="{ props }">
<Button icon v-bind="props" :key="providerDomain">
<Button v-bind="props" :key="providerDomain" icon>
<provider-icon
:domain="providerDomain"
:size="height"
Expand Down Expand Up @@ -63,7 +63,7 @@
style="height: 50px; display: flex; align-items: center; margin-left: 10px; margin-right: 10px"
@mouseover="fetchPreviewUrl(mapping.provider_domain, mapping.item_id)"
>
<audio controls :src="previewUrls[`${mapping.provider_domain}.${mapping.item_id}`]" />
<audio controls :src="previewUrls[`${mapping.provider_domain}.${mapping.item_id}`]"></audio>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/VolumeControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const setGroupPower = function (player: Player, powered: boolean) {
// send power command to all group child players
for (const childPlayer of getVolumePlayers(player)) {
// bypass api throttling by sending the command directly
api.sendCommand(`players/cmd/power`, {
api.sendCommand('players/cmd/power', {
player_id: childPlayer.player_id,
powered,
});
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<v-menu location="bottom end">
<template #activator="{ props }">
<Button
icon
v-if="store.topBarContextMenuItems.length > 0"
icon
style="height: 50px; height: 38px !important"
v-bind="props"
>
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/default/PlayerOSD/PlayerExtendedControls.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<!-- active queue -->
<Button
icon
v-if="props.visibleComponents && props.visibleComponents.queue?.isVisible"
icon
v-bind="props.visibleComponents.queue.icon"
@click="
store.showFullscreenPlayer = false;
Expand All @@ -16,8 +16,8 @@
</Button>
<!-- active player -->
<Button
icon
v-if="props.visibleComponents && props.visibleComponents.player?.isVisible"
icon
v-bind="props.visibleComponents.player.icon"
class="mediacontrols-right"
@click="store.showPlayersMenu = true"
Expand All @@ -26,7 +26,7 @@
</Button>
<!-- active player volume -->
<div v-if="props.visibleComponents && props.visibleComponents.volume?.isVisible">
<v-menu v-if="activePlayerQueue" class="volume-control-dialog" v-model="showVolume" :close-on-content-click="false">
<v-menu v-if="activePlayerQueue" v-model="showVolume" class="volume-control-dialog" :close-on-content-click="false">
<template #activator="{ props: menu }">
<div v-if="getBreakpointValue('bp5') || !responsiveVolumeSize">
<PlayerVolume
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/default/PlayerOSD/PlayerTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
@mouseleave="isThumbHidden = true"
@mousedown="startDragging"
@mouseup="stopDragging"
>
</v-slider>
/>

<!-- end time detail -->
<div style="z-index: 1" class="text-caption">
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/default/PlayerOSD/PlayerTrackDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@
{{ curQueueItem.media_item.artists[0].name }}
</div>
<!-- radio live metadata -->
<div class="line-clamp-1" v-else-if="curQueueItem?.streamdetails?.stream_title">
<div v-else-if="curQueueItem?.streamdetails?.stream_title" class="line-clamp-1">
{{ curQueueItem?.streamdetails?.stream_title }}
</div>
<!-- other description -->
<div class="line-clamp-1" v-else-if="curQueueItem && curQueueItem.media_item?.metadata.description">
<div v-else-if="curQueueItem && curQueueItem.media_item?.metadata.description" class="line-clamp-1">
{{ curQueueItem.media_item.metadata.description }}
</div>
<!-- queue empty message -->
<div class="line-clamp-1" v-else-if="activePlayerQueue && activePlayerQueue.items == 0">
<div v-else-if="activePlayerQueue && activePlayerQueue.items == 0" class="line-clamp-1">
{{ $t('queue_empty') }}
</div>
<!-- 3rd party source active -->
<div class="line-clamp-1" v-else-if="store.selectedPlayer?.active_source != store.selectedPlayer?.player_id">
<div v-else-if="store.selectedPlayer?.active_source != store.selectedPlayer?.player_id" class="line-clamp-1">
{{ $t('external_source_active', [store.selectedPlayer?.active_source]) }}
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<router-view v-slot="{ Component }" app>
<transition name="fade" mode="out-in">
<component v-scroll:#cont="onScroll" :is="Component" />
<component :is="Component" v-scroll:#cont="onScroll" />
</transition>
</router-view>
</v-main>
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export class MusicAssistantApi {
// Play item at index (or item_id) X in queue.
this.playerQueueCommand(queueId, 'play_index', { index });
}
public queueCommandMoveItem(queueId: string, queue_item_id: string, pos_shift: number = 1) {
public queueCommandMoveItem(queueId: string, queue_item_id: string, pos_shift = 1) {
// Move queue item x up/down the queue.
// - queue_id: id of the queue to process this request.
// - queue_item_id: the item_id of the queueitem that needs to be moved.
Expand Down Expand Up @@ -759,7 +759,7 @@ export class MusicAssistantApi {
- player_id: player_id of the groupplayer to handle the command.
- members: list of player ids to set as members.
*/
this.sendCommand(`players/cmd/set_members`, {
this.sendCommand('players/cmd/set_members', {
player_id,
members,
});
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { createI18n } from "vue-i18n";
import { createI18n } from 'vue-i18n';

/*
* All i18n resources specified in the plugin `include` option can be loaded
* at once using the import syntax
*/
import messages from "@intlify/unplugin-vue-i18n/messages";
import messages from '@intlify/unplugin-vue-i18n/messages';

export const i18n = createI18n({
legacy: false,
Expand Down
109 changes: 40 additions & 69 deletions src/views/AlbumDetails.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
<template>
<section>
<InfoHeader :item="itemDetails" />
<v-tabs
v-model="activeTab"
show-arrows
grow
hide-slider
>
<v-tab
value="tracks"
>
{{ $t("tracks") }}
<v-tabs v-model="activeTab" show-arrows grow hide-slider>
<v-tab value="tracks">
{{ $t('tracks') }}
</v-tab>
<v-tab
value="versions"
>
{{ $t("other_versions") }}
<v-tab value="versions">
{{ $t('other_versions') }}
</v-tab>
</v-tabs>
<v-divider />
Expand All @@ -28,7 +19,10 @@
:load-data="loadAlbumTracks"
:sort-keys="['track_number', 'sort_name', 'duration']"
:update-available="updateAvailable"
@refresh-clicked="loadItemDetails();updateAvailable=false;"
@refresh-clicked="
loadItemDetails();
updateAvailable = false;
"
/>
<ItemsListing
v-if="activeTab == 'versions'"
Expand All @@ -39,72 +33,61 @@
:load-data="loadAlbumVersions"
:sort-keys="['provider', 'sort_name', 'year']"
:update-available="updateAvailable"
@refresh-clicked="loadItemDetails();updateAvailable=false;"
@refresh-clicked="
loadItemDetails();
updateAvailable = false;
"
/>
</section>
</template>

<script setup lang="ts">
import ItemsListing from "../components/ItemsListing.vue";
import { filteredItems } from "../components/ItemsListing.vue";
import InfoHeader from "../components/InfoHeader.vue";
import {
EventType,
type Album,
type EventMessage,
type MediaItemType,
} from "../plugins/api/interfaces";
import { api } from "../plugins/api";
import { ref, onMounted, onBeforeUnmount, watch } from "vue";
import ItemsListing from '../components/ItemsListing.vue';
import { filteredItems } from '../components/ItemsListing.vue';
import InfoHeader from '../components/InfoHeader.vue';
import { EventType, type Album, type EventMessage, type MediaItemType } from '../plugins/api/interfaces';
import { api } from '../plugins/api';
import { ref, onMounted, onBeforeUnmount, watch } from 'vue';
export interface Props {
itemId: string;
provider: string;
forceProviderVersion?: string;
}
const props = defineProps<Props>();
const activeTab = ref("");
const activeTab = ref('');
const updateAvailable = ref(false);
const itemDetails = ref<Album>();
const loadItemDetails = async function () {
itemDetails.value = await api.getAlbum(
props.itemId,
props.provider
);
activeTab.value = "tracks";
itemDetails.value = await api.getAlbum(props.itemId, props.provider);
activeTab.value = 'tracks';
};
watch(
() => props.itemId,
(val) => {
if (val) loadItemDetails();
}, { immediate: true }
},
{ immediate: true },
);
onMounted(() => {
//reload if/when item updates
const unsub = api.subscribe_multi(
[EventType.MEDIA_ITEM_ADDED, EventType.MEDIA_ITEM_UPDATED],
(evt: EventMessage) => {
// signal user that there might be updated info available for this item
const updatedItem = evt.data as MediaItemType;
if (itemDetails.value?.uri == updatedItem.uri) {
updateAvailable.value = true;
} else {
for (const provId of updatedItem.provider_mappings) {
if (
provId.provider_domain == itemDetails.value?.provider &&
provId.item_id == itemDetails.value?.item_id
) {
updateAvailable.value = true;
break;
}
const unsub = api.subscribe_multi([EventType.MEDIA_ITEM_ADDED, EventType.MEDIA_ITEM_UPDATED], (evt: EventMessage) => {
// signal user that there might be updated info available for this item
const updatedItem = evt.data as MediaItemType;
if (itemDetails.value?.uri == updatedItem.uri) {
updateAvailable.value = true;
} else {
for (const provId of updatedItem.provider_mappings) {
if (provId.provider_domain == itemDetails.value?.provider && provId.item_id == itemDetails.value?.item_id) {
updateAvailable.value = true;
break;
}
}
}
);
});
onBeforeUnmount(unsub);
});
Expand All @@ -113,7 +96,7 @@ const loadAlbumTracks = async function (
limit: number,
sort: string,
search?: string,
inLibraryOnly = true
inLibraryOnly = true,
) {
const albumTracks = await api.getAlbumTracks(props.itemId, props.provider);
return filteredItems(albumTracks, offset, limit, sort, search, inLibraryOnly);
Expand All @@ -124,23 +107,11 @@ const loadAlbumVersions = async function (
limit: number,
sort: string,
search?: string,
inLibraryOnly = true
inLibraryOnly = true,
) {
const albumVersions = await api.getAlbumVersions(
props.itemId,
props.provider
);
return filteredItems(
albumVersions,
offset,
limit,
sort,
search,
inLibraryOnly
);
const albumVersions = await api.getAlbumVersions(props.itemId, props.provider);
return filteredItems(albumVersions, offset, limit, sort, search, inLibraryOnly);
};
</script>

<style lang="scss">
</style>
<style lang="scss"></style>
8 changes: 1 addition & 7 deletions src/views/LibraryAlbums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ onBeforeUnmount(() => {
store.topBarContextMenuItems = [];
});
const loadItems = async function (
offset: number,
limit: number,
sort: string,
search?: string,
inLibraryOnly = true
) {
const loadItems = async function (offset: number, limit: number, sort: string, search?: string, inLibraryOnly = true) {
const library = inLibraryOnly || undefined;
return await api.getAlbums(library, search, limit, offset, sort);
};
Expand Down
Loading

0 comments on commit d2d3bde

Please sign in to comment.