From b6d3295255892774bc71c09b7e2520cf2dc815aa Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Tue, 21 May 2024 09:07:27 +0800 Subject: [PATCH 01/15] $ Extract add video to playlist button into a component --- .../components/ft-list-video/ft-list-video.js | 29 +-- .../ft-list-video/ft-list-video.vue | 12 +- .../ft-playlist-add-video-button.js | 63 +++++++ .../ft-playlist-add-video-button.scss | 176 ++++++++++++++++++ .../ft-playlist-add-video-button.vue | 12 ++ .../watch-video-info/watch-video-info.js | 26 +-- .../watch-video-info/watch-video-info.vue | 13 +- 7 files changed, 277 insertions(+), 54 deletions(-) create mode 100644 src/renderer/components/ft-playlist-add-video-button/ft-playlist-add-video-button.js create mode 100644 src/renderer/components/ft-playlist-add-video-button/ft-playlist-add-video-button.scss create mode 100644 src/renderer/components/ft-playlist-add-video-button/ft-playlist-add-video-button.vue diff --git a/src/renderer/components/ft-list-video/ft-list-video.js b/src/renderer/components/ft-list-video/ft-list-video.js index 578e1f4cf9fd7..88182168b5b60 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.js +++ b/src/renderer/components/ft-list-video/ft-list-video.js @@ -1,5 +1,6 @@ import { defineComponent } from 'vue' import FtIconButton from '../ft-icon-button/ft-icon-button.vue' +import FtPlaylistAddVideoButton from '../ft-playlist-add-video-button/ft-playlist-add-video-button.vue' import { mapActions } from 'vuex' import { copyToClipboard, @@ -17,7 +18,8 @@ import debounce from 'lodash.debounce' export default defineComponent({ name: 'FtListVideo', components: { - 'ft-icon-button': FtIconButton + 'ft-icon-button': FtIconButton, + 'ft-playlist-add-video-button': FtPlaylistAddVideoButton, }, props: { data: { @@ -725,30 +727,6 @@ export default defineComponent({ this.watchProgress = 0 }, - togglePlaylistPrompt: function () { - const videoData = { - videoId: this.id, - title: this.title, - author: this.channelName, - authorId: this.channelId, - description: this.description, - viewCount: this.viewCount, - lengthSeconds: this.data.lengthSeconds, - } - - this.showAddToPlaylistPromptForManyVideos({ videos: [videoData] }) - - // Focus when prompt closed - this.addToPlaylistPromptCloseCallback = () => { - // Run once only - this.addToPlaylistPromptCloseCallback = null - - // `thumbnailLink` is a `router-link` - // `focus()` can only be called on the actual element - this.$refs.addToPlaylistIcon?.$el?.focus() - } - }, - hideChannel: function(channelName, channelId) { const hiddenChannels = JSON.parse(this.$store.getters.getChannelsHidden) hiddenChannels.push(channelId) @@ -826,7 +804,6 @@ export default defineComponent({ 'updateHistory', 'removeFromHistory', 'updateChannelsHidden', - 'showAddToPlaylistPromptForManyVideos', 'addVideos', 'updatePlaylist', 'removeVideo', diff --git a/src/renderer/components/ft-list-video/ft-list-video.vue b/src/renderer/components/ft-list-video/ft-list-video.vue index 4492b86fbb019..c2fb6913c7f52 100644 --- a/src/renderer/components/ft-list-video/ft-list-video.vue +++ b/src/renderer/components/ft-list-video/ft-list-video.vue @@ -44,16 +44,18 @@ @click="handleExternalPlayer" /> - + + + +