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 May 22, 2024
2 parents 5597720 + 8a82abe commit c075058
Show file tree
Hide file tree
Showing 41 changed files with 754 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conflicts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: check if prs are dirty
uses: eps1lon/actions-label-merge-conflict@releases/2.x
uses: eps1lon/actions-label-merge-conflict@v3
with:
dirtyLabel: "PR: merge conflicts / rebase needed"
removeOnDirtyLabel: "PR: waiting for review"
Expand Down
26 changes: 26 additions & 0 deletions _scripts/mime-db-shrinking-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* electron-context-menu only needs mime-db for its save as feature.
* As we only activate save image and save as image features, we can remove all other mimetypes,
* as they will never get used.
* Which results in quite a significant reduction in file size.
* @param {string} source
*/
module.exports = function (source) {
const original = JSON.parse(source)

const reduced = {}

for (const mimeType of Object.keys(original)) {
if (mimeType.startsWith('image/') && original[mimeType].extensions &&
(!mimeType.startsWith('image/x-') || mimeType === 'image/x-icon' || mimeType === 'image/x-ms-bmp') &&
(!mimeType.startsWith('image/vnd.') || mimeType === 'image/vnd.microsoft.icon')) {

// Only the extensions field is needed, see: https://github.com/kevva/ext-list/blob/v2.2.2/index.js
reduced[mimeType] = {
extensions: original[mimeType].extensions
}
}
}

return JSON.stringify(reduced)
}
4 changes: 4 additions & 0 deletions _scripts/webpack.main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const config = {
use: 'babel-loader',
exclude: /node_modules/,
},
{
resource: path.resolve(__dirname, '../node_modules/mime-db/db.json'),
use: path.join(__dirname, 'mime-db-shrinking-loader.js')
}
],
},
// webpack defaults to only optimising the production builds, so having this here is fine
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@seald-io/nedb": "^4.0.4",
"@silvermine/videojs-quality-selector": "^1.3.1",
"autolinker": "^4.0.0",
"electron-context-menu": "^3.6.1",
"electron-context-menu": "^4.0.0",
"lodash.debounce": "^4.0.8",
"marked": "^12.0.2",
"path-browserify": "^1.0.1",
Expand Down Expand Up @@ -92,7 +92,7 @@
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.1",
"css-minimizer-webpack-plugin": "^7.0.0",
"electron": "^30.0.3",
"electron": "^30.0.6",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
8 changes: 8 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const SyncEvents = {
// Utils
const MAIN_PROFILE_ID = 'allChannels'

// Width threshold in px at which we switch to using a more heavily altered view for mobile users
const MOBILE_WIDTH_THRESHOLD = 680

// Height threshold in px at which we switch to using a more heavily altered playlist view for mobile users
const PLAYLIST_HEIGHT_FORCE_LIST_THRESHOLD = 500

// YouTube search character limit is 100 characters
const SEARCH_CHAR_LIMIT = 100

Expand All @@ -90,5 +96,7 @@ export {
DBActions,
SyncEvents,
MAIN_PROFILE_ID,
MOBILE_WIDTH_THRESHOLD,
PLAYLIST_HEIGHT_FORCE_LIST_THRESHOLD,
SEARCH_CHAR_LIMIT
}
16 changes: 5 additions & 11 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,11 @@ function runApp() {
await createWindow()

if (process.env.NODE_ENV === 'development') {
installDevTools()
try {
require('vue-devtools').install()
} catch (err) {
console.error(err)
}
}

if (isDebug) {
Expand Down Expand Up @@ -592,16 +596,6 @@ function runApp() {
}
}

async function installDevTools() {
try {
/* eslint-disable */
require('vue-devtools').install()
/* eslint-enable */
} catch (err) {
console.error(err)
}
}

async function createWindow(
{
replaceMainWindow = true,
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ export default defineComponent({
return this.$store.getters.getBaseTheme
},

isSideNavOpen: function () {
return this.$store.getters.getIsSideNavOpen
},

hideLabelsSideBar: function () {
return this.$store.getters.getHideLabelsSideBar
},

mainColor: function () {
return this.$store.getters.getMainColor
},
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
class="app"
:class="{
hideOutlines: outlinesHidden,
isLocaleRightToLeft: isLocaleRightToLeft
isLocaleRightToLeft: isLocaleRightToLeft,
isSideNavOpen: isSideNavOpen,
hideLabelsSideBar: hideLabelsSideBar && !isSideNavOpen
}"
>
<portal-target
Expand Down
46 changes: 46 additions & 0 deletions src/renderer/components/ft-element-list/ft-element-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,40 @@ export default defineComponent({
required: false,
default: '',
},
alwaysShowAddToPlaylistButton: {
type: Boolean,
default: false,
},
quickBookmarkButtonEnabled: {
type: Boolean,
default: true,
},
canMoveVideoUp: {
type: Boolean,
default: false,
},
canMoveVideoDown: {
type: Boolean,
default: false,
},
canRemoveFromPlaylist: {
type: Boolean,
default: false,
},
playlistItemsLength: {
type: Number,
default: 0
},
playlistId: {
type: String,
default: null
},
playlistType: {
type: String,
default: null
},
},
emits: ['move-video-down', 'move-video-up', 'remove-from-playlist'],
computed: {
listType: function () {
return this.$store.getters.getListType
Expand All @@ -48,5 +81,18 @@ export default defineComponent({
displayValue: function () {
return this.display === '' ? this.listType : this.display
}
},
methods: {
moveVideoUp: function(videoId, playlistItemId) {
this.$emit('move-video-up', videoId, playlistItemId)
},

moveVideoDown: function(videoId, playlistItemId) {
this.$emit('move-video-down', videoId, playlistItemId)
},

removeFromPlaylist: function(videoId, playlistItemId) {
this.$emit('remove-from-playlist', videoId, playlistItemId)
},
}
})
11 changes: 11 additions & 0 deletions src/renderer/components/ft-element-list/ft-element-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@
:show-video-with-last-viewed-playlist="showVideoWithLastViewedPlaylist"
:use-channels-hidden-preference="useChannelsHiddenPreference"
:hide-forbidden-titles="hideForbiddenTitles"
:always-show-add-to-playlist-button="alwaysShowAddToPlaylistButton"
:quick-bookmark-button-enabled="quickBookmarkButtonEnabled"
:can-move-video-up="canMoveVideoUp && index > 0"
:can-move-video-down="canMoveVideoDown && index < playlistItemsLength - 1"
:can-remove-from-playlist="canRemoveFromPlaylist"
:search-query-text="searchQueryText"
:playlist-id="playlistId"
:playlist-type="playlistType"
:playlist-item-id="result.playlistItemId"
@move-video-up="moveVideoUp(result.videoId, result.playlistItemId)"
@move-video-down="moveVideoDown(result.videoId, result.playlistItemId)"
@remove-from-playlist="removeFromPlaylist(result.videoId, result.playlistItemId)"
/>
</ft-auto-grid>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,40 @@ export default defineComponent({
required: false,
default: '',
},
playlistId: {
type: String,
default: null
},
playlistType: {
type: String,
default: null
},
playlistItemId: {
type: String,
default: null
},
alwaysShowAddToPlaylistButton: {
type: Boolean,
default: false,
},
quickBookmarkButtonEnabled: {
type: Boolean,
default: true,
},
canMoveVideoUp: {
type: Boolean,
default: false,
},
canMoveVideoDown: {
type: Boolean,
default: false,
},
canRemoveFromPlaylist: {
type: Boolean,
default: false,
},
},
emits: ['move-video-down', 'move-video-up', 'remove-from-playlist'],
data: function () {
return {
visible: this.firstScreen
Expand Down Expand Up @@ -160,7 +193,17 @@ export default defineComponent({
methods: {
onVisibilityChanged: function (visible) {
this.visible = visible
}
},
moveVideoUp: function() {
this.$emit('move-video-up')
},

moveVideoDown: function() {
this.$emit('move-video-down')
},

removeFromPlaylist: function() {
this.$emit('remove-from-playlist')
},
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@
v-if="finalDataType === 'video' || finalDataType === 'shortVideo'"
:appearance="appearance"
:data="data"
:playlist-id="playlistId"
:playlist-type="playlistType"
:playlist-item-id="playlistItemId"
:show-video-with-last-viewed-playlist="showVideoWithLastViewedPlaylist"
:always-show-add-to-playlist-button="alwaysShowAddToPlaylistButton"
:quick-bookmark-button-enabled="quickBookmarkButtonEnabled"
:can-move-video-up="canMoveVideoUp"
:can-move-video-down="canMoveVideoDown"
:can-remove-from-playlist="canRemoveFromPlaylist"
@move-video-up="moveVideoUp"
@move-video-down="moveVideoDown"
@remove-from-playlist="removeFromPlaylist"
/>
<ft-list-channel
v-else-if="finalDataType === 'channel'"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/components/ft-list-video/ft-list-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export default defineComponent({
return this.$store.getters.getListType
},

effectiveListTypeIsList: function () {
return (this.listType === 'list' || this.forceListType === 'list') && this.forceListType !== 'grid'
},

thumbnailPreference: function () {
return this.$store.getters.getThumbnailPreference
},
Expand Down
11 changes: 5 additions & 6 deletions src/renderer/components/ft-list-video/ft-list-video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div
class="ft-list-video ft-list-item"
:class="{
list: (listType === 'list' || forceListType === 'list') && forceListType !== 'grid',
grid: (listType === 'grid' || forceListType === 'list') && forceListType !== 'list',
list: effectiveListTypeIsList,
grid: !effectiveListTypeIsList,
[appearance]: true,
watched: addWatchedStyle
}"
Expand Down Expand Up @@ -72,7 +72,7 @@
<ft-icon-button
v-if="inUserPlaylist && canMoveVideoUp"
:title="$t('User Playlists.Move Video Up')"
:icon="['fas', 'arrow-up']"
:icon="effectiveListTypeIsList ? ['fas', 'arrow-up'] : ['fas', 'arrow-left']"
class="upArrowIcon"
:padding="appearance === `watchPlaylistItem` ? 5 : 6"
:size="appearance === `watchPlaylistItem` ? 14 : 18"
Expand All @@ -81,7 +81,7 @@
<ft-icon-button
v-if="inUserPlaylist && canMoveVideoDown"
:title="$t('User Playlists.Move Video Down')"
:icon="['fas', 'arrow-down']"
:icon="effectiveListTypeIsList ? ['fas', 'arrow-down'] : ['fas', 'arrow-right']"
class="downArrowIcon"
:padding="appearance === `watchPlaylistItem` ? 5 : 6"
:size="appearance === `watchPlaylistItem` ? 14 : 18"
Expand Down Expand Up @@ -157,8 +157,7 @@
@click="handleOptionsClick"
/>
<p
v-if="description && ((listType === 'list' || forceListType === 'list') && forceListType !== 'grid') &&
appearance === 'result'"
v-if="description && effectiveListTypeIsList && appearance === 'result'"
class="description"
v-html="description"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export default defineComponent({
}
},
emits: ['click'],
computed: {
isSideNavOpen: function () {
return this.$store.getters.getIsSideNavOpen
}
},
methods: {
click: function() {
this.$emit('click')
Expand Down
Loading

0 comments on commit c075058

Please sign in to comment.