Skip to content

Commit

Permalink
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
Browse files Browse the repository at this point in the history
…at/add-page-bookmarking
  • Loading branch information
kommunarr committed Jun 15, 2024
2 parents b162507 + 74d01f8 commit 13ba73e
Show file tree
Hide file tree
Showing 37 changed files with 630 additions and 182 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"electron": "^30.0.9",
"electron": "^31.0.1",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/ft-checkbox-list/ft-checkbox-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default defineComponent({
this.selectedValues = this.initialValues
},
methods: {
removeSelectedValues: function() {
this.selectedValues = []
setSelectedValues: function(arr) {
this.selectedValues = arr
},
change: function(event) {
const targ = event.target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:disabled="disabled"
class="checkbox"
type="checkbox"
:checked="initialValues.includes(values[index]) ?? null"
:checked="selectedValues.includes(values[index]) ?? null"
@change="change"
>
<label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,45 @@ export default defineComponent({
newPlaylistVideoObject: function () {
return this.$store.getters.getNewPlaylistVideoObject
},

playlistNameEmpty() {
return this.playlistName === ''
},
playlistNameBlank() {
return !this.playlistNameEmpty && this.playlistName.trim() === ''
},
playlistWithNameExists() {
// Don't show the message with no name input
const playlistName = this.playlistName
if (this.playlistName === '') { return false }

return this.allPlaylists.some((playlist) => {
return playlist.playlistName === playlistName
})
},
playlistPersistenceDisabled() {
return this.playlistNameEmpty || this.playlistNameBlank || this.playlistWithNameExists
},
},
mounted: function () {
this.playlistName = this.newPlaylistVideoObject.title
// Faster to input required playlist name
nextTick(() => this.$refs.playlistNameInput.focus())
},
methods: {
createNewPlaylist: function () {
if (this.playlistName === '') {
showToast(this.$t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]'))
handlePlaylistNameInput(input) {
if (input.trim() === '') {
// Need to show message for blank input
this.playlistName = input
return
}

const nameExists = this.allPlaylists.findIndex((playlist) => {
return playlist.playlistName === this.playlistName
})
if (nameExists !== -1) {
showToast(this.$t('User Playlists.CreatePlaylistPrompt.Toast["There is already a playlist with this name. Please pick a different name."]'))
return
}
this.playlistName = input.trim()
},

createNewPlaylist: function () {
// Still possible to attempt to create via pressing enter
if (this.playlistPersistenceDisabled) { return }

const playlistObject = {
playlistName: this.playlistName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@
:value="playlistName"
:maxlength="255"
class="playlistNameInput"
@input="(input) => playlistName = input"
@input="handlePlaylistNameInput"
@click="createNewPlaylist"
/>
</ft-flex-box>
<ft-flex-box v-if="playlistNameBlank">
<p>
{{ $t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]') }}
</p>
</ft-flex-box>
<ft-flex-box v-if="playlistWithNameExists">
<p>
{{ $t('User Playlists.CreatePlaylistPrompt.Toast["There is already a playlist with this name. Please pick a different name."]') }}
</p>
</ft-flex-box>
<ft-flex-box>
<ft-button
:label="$t('User Playlists.CreatePlaylistPrompt.Create')"
:disabled="playlistPersistenceDisabled"
@click="createNewPlaylist"
/>
<ft-button
Expand Down
28 changes: 8 additions & 20 deletions src/renderer/components/ft-list-video/ft-list-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default defineComponent({
lengthSeconds: 0,
duration: '',
description: '',
watchProgress: 0,
published: undefined,
isLive: false,
is4k: false,
Expand All @@ -119,6 +118,14 @@ export default defineComponent({
return typeof this.historyEntry !== 'undefined'
},

watchProgress: function () {
if (!this.historyEntryExists || !this.saveWatchedProgress) {
return 0
}

return this.historyEntry.watchProgress
},

listType: function () {
return this.$store.getters.getListType
},
Expand Down Expand Up @@ -494,9 +501,6 @@ export default defineComponent({
},
},
watch: {
historyEntry() {
this.checkIfWatched()
},
showAddToPlaylistPrompt(value) {
if (value) { return }
// Execute on prompt close
Expand All @@ -507,7 +511,6 @@ export default defineComponent({
},
created: function () {
this.parseVideoData()
this.checkIfWatched()

if ((this.useDeArrowTitles || this.useDeArrowThumbnails) && !this.deArrowCache) {
this.fetchDeArrowData()
Expand Down Expand Up @@ -697,19 +700,6 @@ export default defineComponent({
}
},

checkIfWatched: function () {
if (this.historyEntryExists) {
const historyEntry = this.historyEntry

if (this.saveWatchedProgress) {
// For UX consistency, no progress reading if writing disabled
this.watchProgress = historyEntry.watchProgress
}
} else {
this.watchProgress = 0
}
},

markAsWatched: function () {
const videoData = {
videoId: this.id,
Expand All @@ -733,8 +723,6 @@ export default defineComponent({
this.removeFromHistory(this.id)

showToast(this.$t('Video.Video has been removed from your history'))

this.watchProgress = 0
},

togglePlaylistPrompt: function () {
Expand Down
19 changes: 15 additions & 4 deletions src/renderer/components/ft-search-filters/ft-search-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export default defineComponent({
'location',
'hdr',
'vr180'
],
notAllowedForMoviesFeatures: [
'live',
'subtitles',
'3d',
'creative_commons'
]
}
},
Expand Down Expand Up @@ -164,9 +170,9 @@ export default defineComponent({
},

updateFeatures: function(value) {
if (!this.isVideoOrMovieOrAll(this.searchSettings.type)) {
const featuresCheck = this.$refs.featuresCheck
featuresCheck.removeSelectedValues()
if (!this.isVideoOrMovieOrAll(this.searchSettings.type) || this.notAllowedForMoviesFeatures.some(item => value.includes(item))) {
const typeRadio = this.$refs.typeRadio
typeRadio.updateSelectedValue('all')
this.$store.commit('setSearchType', 'all')
}

Expand All @@ -183,11 +189,16 @@ export default defineComponent({
timeRadio.updateSelectedValue('')
durationRadio.updateSelectedValue('')
sortByRadio.updateSelectedValue(this.sortByValues[0])
featuresCheck.removeSelectedValues()
featuresCheck.setSelectedValues([])
this.$store.commit('setSearchTime', '')
this.$store.commit('setSearchDuration', '')
this.$store.commit('setSearchFeatures', [])
this.$store.commit('setSearchSortBy', this.sortByValues[0])
} else if (value === 'movie') {
const featuresCheck = this.$refs.featuresCheck
const filteredFeatures = this.searchSettings.features.filter(e => !this.notAllowedForMoviesFeatures.includes(e))
featuresCheck.setSelectedValues([...filteredFeatures])
this.$store.commit('setSearchFeatures', filteredFeatures)
}
this.$store.commit('setSearchType', value)
this.$store.commit('setSearchFilterValueChanged', this.searchFilterValueChanged)
Expand Down
Loading

0 comments on commit 13ba73e

Please sign in to comment.