Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/renderer/components/FtElementList/FtElementList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
@drag-video-end="afterDrag"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
@move-video-to-the-top="moveVideoToTheTop"
@move-video-to-the-bottom="moveVideoToTheBottom"
@remove-from-playlist="removeFromPlaylist"
/>
</FtAutoGrid>
Expand Down Expand Up @@ -129,7 +131,7 @@ const props = defineProps({
},
})

const emit = defineEmits(['move-dragged-video', 'move-video-down', 'move-video-up', 'remove-from-playlist', 'drag-video', 'drag-video-end'])
const emit = defineEmits(['move-dragged-video', 'move-video-down', 'move-video-up', 'move-video-to-the-top', 'move-video-to-the-bottom', 'remove-from-playlist', 'drag-video', 'drag-video-end'])
Comment thread
caetano-dev marked this conversation as resolved.
Outdated

/** @type {import('vue').ComputedRef<'grid' | 'list'>} */
const listType = computed(() => {
Expand Down Expand Up @@ -157,6 +159,22 @@ function moveVideoDown(videoId, playlistItemId) {
emit('move-video-down', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheTop(videoId, playlistItemId) {
emit('move-video-to-the-top', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheBottom(videoId, playlistItemId) {
emit('move-video-to-the-bottom', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
Expand Down
20 changes: 19 additions & 1 deletion src/renderer/components/FtListLazyWrapper/FtListLazyWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
:show-grab-bar="isDraggable && layout === 'grid'"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
@move-video-to-the-top="moveVideoToTheTop"
@move-video-to-the-bottom="moveVideoToTheBottom"
@remove-from-playlist="removeFromPlaylist"
/>
<FtListChannel
Expand Down Expand Up @@ -162,7 +164,7 @@ const props = defineProps({
},
})

const emit = defineEmits(['move-dragged-video', 'move-video-down', 'move-video-up', 'remove-from-playlist', 'drag-video', 'drag-video-end'])
const emit = defineEmits(['move-dragged-video', 'move-video-down', 'move-video-up', 'move-video-to-the-top', 'move-video-to-the-bottom', 'remove-from-playlist', 'drag-video', 'drag-video-end'])
Comment thread
caetano-dev marked this conversation as resolved.
Outdated

const inUserPlaylist = props.playlistType === 'user'
const isDraggable = computed(() => inUserPlaylist && props.isSortOrderCustom && (props.canMoveVideoUp || props.canMoveVideoDown))
Expand Down Expand Up @@ -328,6 +330,22 @@ function moveVideoDown(videoId, playlistItemId) {
emit('move-video-down', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheTop(videoId, playlistItemId) {
emit('move-video-to-the-top', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheBottom(videoId, playlistItemId) {
emit('move-video-to-the-bottom', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
Expand Down
35 changes: 33 additions & 2 deletions src/renderer/components/FtListVideo/FtListVideo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const props = defineProps({
},
})

const emit = defineEmits(['move-video-down', 'move-video-up', 'pause-player', 'remove-from-playlist'])
const emit = defineEmits(['move-video-down', 'move-video-up', 'move-video-to-the-top', 'move-video-to-the-bottom', 'pause-player', 'remove-from-playlist'])
Comment thread
caetano-dev marked this conversation as resolved.
Outdated

const { locale, t } = useI18n()
const route = useRoute()
Expand Down Expand Up @@ -486,8 +486,25 @@ const dropdownOptions = computed(() => {
? t('Video.Remove From History')
: t('Video.Mark As Watched'),
value: 'history'
}
},
]
if (inUserPlaylist.value && (props.canMoveVideoUp || props.canMoveVideoDown)) {
options.push({
type: 'divider'
})
}
if (props.canMoveVideoUp && inUserPlaylist.value) {
options.push({
label: t('User Playlists.Move Video to the Top'),
value: 'moveVideoTop'
})
}
if (props.canMoveVideoDown && inUserPlaylist.value) {
options.push({
label: t('User Playlists.Move Video to the Bottom'),
value: 'moveVideoBottom'
})
}
Comment thread
caetano-dev marked this conversation as resolved.
Outdated
if (!hideSharingActions.value) {
options.push(
{
Expand Down Expand Up @@ -614,6 +631,12 @@ function handleOptionsClick(option) {
markAsWatched()
}
break
case 'moveVideoTop':
moveVideoToTheTop()
break
case 'moveVideoBottom':
moveVideoToTheBottom()
break
case 'copyYoutube': {
let videoUrl = `https://youtu.be/${id.value}`

Expand Down Expand Up @@ -1054,6 +1077,14 @@ function removeFromWatched() {
showToast(t('Video.Video has been removed from your history'))
}

function moveVideoToTheTop() {
emit('move-video-to-the-top', id.value, props.playlistItemId)
}

function moveVideoToTheBottom() {
emit('move-video-to-the-bottom', id.value, props.playlistItemId)
}

function togglePlaylistPrompt() {
const videoData = {
videoId: id.value,
Expand Down
20 changes: 19 additions & 1 deletion src/renderer/components/FtListVideoLazy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
:can-move-video-up="canMoveVideoUp"
:can-move-video-down="canMoveVideoDown"
:can-remove-from-playlist="canRemoveFromPlaylist"
@move-video-to-the-top="moveVideoToTheTop"
@move-video-to-the-bottom="moveVideoToTheBottom"
@pause-player="pausePlayer"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
Expand Down Expand Up @@ -158,12 +160,28 @@ function onVisibilityChanged(isVisible) {
}
}

const emit = defineEmits(['pause-player', 'move-video-up', 'move-video-down', 'remove-from-playlist'])
const emit = defineEmits(['pause-player', 'move-video-up', 'move-video-down', 'move-video-to-the-top', 'move-video-to-the-bottom', 'remove-from-playlist'])

function pausePlayer() {
emit('pause-player')
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheTop(videoId, playlistItemId) {
emit('move-video-to-the-top', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheBottom(videoId, playlistItemId) {
emit('move-video-to-the-bottom', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
@pause-player="pausePlayer"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
@move-video-to-the-top="moveVideoToTheTop"
@move-video-to-the-bottom="moveVideoToTheBottom"
@remove-from-playlist="removeFromPlaylist"
/>
</template>
Expand Down Expand Up @@ -155,7 +157,7 @@ const props = defineProps({
}
})

const emit = defineEmits(['move-dragged-video', 'move-video-down', 'move-video-up', 'pause-player', 'remove-from-playlist', 'drag-video', 'drag-video-end'])
const emit = defineEmits(['move-dragged-video', 'move-video-down', 'move-video-up', 'move-video-to-the-top', 'move-video-to-the-bottom', 'pause-player', 'remove-from-playlist', 'drag-video', 'drag-video-end'])
const visible = ref(props.initialVisibleState)

const inUserPlaylist = props.playlistType === 'user'
Expand Down Expand Up @@ -217,6 +219,22 @@ function moveVideoDown(videoId, playlistItemId) {
emit('move-video-down', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheTop(videoId, playlistItemId) {
emit('move-video-to-the-top', videoId, playlistItemId)
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheBottom(videoId, playlistItemId) {
emit('move-video-to-the-bottom', videoId, playlistItemId)
}

function onDragVideo(event) {
// Only allow dragging via the drag bar
if (!event.target.classList.contains('draggable')) { return }
Expand Down
94 changes: 94 additions & 0 deletions src/renderer/views/Playlist/Playlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
@move-dragged-video="moveDraggedVideoTemporarilyThrottled"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
@move-video-to-the-top="moveVideoToTheTop"
@move-video-to-the-bottom="moveVideoToTheBottom"
@remove-from-playlist="removeVideoFromPlaylist"
/>
<TransitionGroup
Expand Down Expand Up @@ -129,6 +131,8 @@
@move-dragged-video="moveDraggedVideoTemporarilyThrottled"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
@move-video-to-the-top="moveVideoToTheTop"
@move-video-to-the-bottom="moveVideoToTheBottom"
@remove-from-playlist="removeVideoFromPlaylist"
/>
</TransitionGroup>
Expand Down Expand Up @@ -714,6 +718,10 @@ function moveVideoUp(videoId, playlistItemId) {
return video.videoId === videoId && video.playlistItemId === playlistItemId
})

if (index === -1) {
return
}

if (index === 0) {
showToast(t('User Playlists.SinglePlaylistView.Toast["This video cannot be moved up."]'))
return
Expand Down Expand Up @@ -749,6 +757,10 @@ function moveVideoDown(videoId, playlistItemId) {
return video.videoId === videoId && video.playlistItemId === playlistItemId
})

if (index === -1) {
return
}

if (index + 1 >= playlistItems_.length) {
showToast(t('User Playlists.SinglePlaylistView.Toast["This video cannot be moved down."]'))
return
Expand All @@ -773,6 +785,88 @@ function moveVideoDown(videoId, playlistItemId) {
}
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheTop(videoId, playlistItemId) {
const playlistItems_ = playlistItems.value.slice()

const index = playlistItems_.findIndex((video) => {
return video.videoId === videoId && video.playlistItemId === playlistItemId
})

if (index === -1) {
return
}

if (index === 0) {
showToast(t('User Playlists.SinglePlaylistView.Toast["This video cannot be moved to the top."]'))
Comment thread
caetano-dev marked this conversation as resolved.
Outdated
return
}

const videoObject = playlistItems_[index]
playlistItems_.splice(index, 1)
playlistItems_.unshift(videoObject)

const playlist = {
playlistName: playlistTitle.value,
protected: selectedUserPlaylist.value.protected,
description: playlistDescription.value,
videos: deepCopy(playlistItems_),
_id: playlistId.value
}

try {
store.dispatch('updatePlaylist', playlist)
playlistItems.value = playlistItems_
} catch (e) {
showToast(t('User Playlists.SinglePlaylistView.Toast["There was an issue with updating this playlist."]'))
console.error(e)
}
}

/**
* @param {string} videoId
* @param {string} playlistItemId
*/
function moveVideoToTheBottom(videoId, playlistItemId) {
const playlistItems_ = playlistItems.value.slice()

const index = playlistItems_.findIndex((video) => {
return video.videoId === videoId && video.playlistItemId === playlistItemId
})

if (index === -1) {
return
}

if (index === playlistItems_.length - 1) {
showToast(t('User Playlists.SinglePlaylistView.Toast["This video cannot be moved to the bottom."]'))
return
}

const videoObject = playlistItems_[index]
playlistItems_.splice(index, 1)
playlistItems_.push(videoObject)

const playlist = {
playlistName: playlistTitle.value,
protected: selectedUserPlaylist.value.protected,
description: playlistDescription.value,
videos: deepCopy(playlistItems_),
_id: playlistId.value
}

try {
store.dispatch('updatePlaylist', playlist)
playlistItems.value = playlistItems_
} catch (e) {
showToast(t('User Playlists.SinglePlaylistView.Toast["There was an issue with updating this playlist."]'))
console.error(e)
}
}

/**
* @param {VideoData} video
*/
Expand Down
4 changes: 4 additions & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ User Playlists:
Add to Favorites: Add to {playlistName}
Remove from Favorites: Remove from {playlistName}

Move Video to the Top: Move Video to the Top
Move Video to the Bottom: Move Video to the Bottom
Move Video Up: Move Video Up
Move Video Down: Move Video Down
Remove from Playlist: Remove from Playlist
Expand Down Expand Up @@ -208,6 +210,8 @@ User Playlists:
Toast:
This video cannot be moved up.: This video cannot be moved up.
This video cannot be moved down.: This video cannot be moved down.
This video cannot be moved to the top.: This video cannot be moved to the top.
This video cannot be moved to the bottom.: This video cannot be moved to the bottom.
Video has been removed: Video has been removed
Video has been removed. Click here to undo.: Video has been removed. Click here to undo.
There was a problem with removing this video: There was a problem with removing this video
Expand Down