Skip to content

Commit

Permalink
refactor: use the new useTemplateRef utility
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
  • Loading branch information
ferferga committed Sep 6, 2024
1 parent 9dc36c0 commit 1970a7e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<script setup lang="ts">
import { transfer } from 'comlink';
import { shallowRef, watch } from 'vue';
import { shallowRef, watch, useTemplateRef } from 'vue';
import { blurhashDecoder, canvasDrawer } from '@/plugins/workers';
import { BLURHASH_DEFAULT_HEIGHT, BLURHASH_DEFAULT_WIDTH, BLURHASH_DEFAULT_PUNCH } from '@/store';
Expand All @@ -26,7 +26,7 @@ const props = withDefaults(
);
const error = shallowRef(false);
const canvas = shallowRef<HTMLCanvasElement>();
const canvas = useTemplateRef<HTMLCanvasElement>('canvas');
let offscreen: OffscreenCanvas | undefined;
watch([props, canvas], async () => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Playback/DraggableQueue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
<script setup lang="ts">
import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client';
import Sortable from 'sortablejs';
import { onBeforeUnmount, shallowRef, watch } from 'vue';
import { onBeforeUnmount, watch, useTemplateRef } from 'vue';
import { isNumber } from '@/utils/validation';
import { playbackManager } from '@/store/playback-manager';
let sortable: Sortable | undefined;
const container = shallowRef<HTMLSpanElement>();
const container = useTemplateRef<HTMLSpanElement>('container');
/**
* Destroys the sortable instance
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Playback/MusicVisualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
</template>

<script setup lang="ts">
import { onBeforeUnmount, shallowRef, watch } from 'vue';
import { onBeforeUnmount, useTemplateRef, watch } from 'vue';
import AudioMotionAnalyzer from 'audiomotion-analyzer';
import { mediaWebAudio } from '@/store';
let visualizerInstance: AudioMotionAnalyzer | undefined;
const visualizerElement = shallowRef<HTMLDivElement>();
const visualizerElement = useTemplateRef<HTMLDivElement>('visualizerElement');
/**
* Destroy the visualizer instance.
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/components/lib/JVirtual/JVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import {
onBeforeUnmount,
shallowRef,
watch,
type StyleValue
type StyleValue,
useTemplateRef
} from 'vue';
import { wrap } from 'comlink';
import {
Expand Down Expand Up @@ -118,8 +119,8 @@ const props = withDefaults(
/**
* == TEMPLATE REFS ==
*/
const rootRef = shallowRef<HTMLElement>();
const probeRef = shallowRef<HTMLElement>();
const rootRef = useTemplateRef<HTMLElement>('rootRef');
const probeRef = useTemplateRef<HTMLElement>('probeRef');
/**
* == STATE REFS ==
Expand Down

0 comments on commit 1970a7e

Please sign in to comment.