Skip to content

Commit

Permalink
Merge branch 'development' into custom-builds/current
Browse files Browse the repository at this point in the history
* development: (60 commits)
  check for 204 error (FreeTubeApp#5259)
  Translated using Weblate (Turkish)
  ! Fix error when fetching deleted comment replies in local API (FreeTubeApp#5255)
  Optical enhancement - Improved spacing on the about page FreeTubeApp#5210 (FreeTubeApp#5257)
  Translated using Weblate (Czech)
  Translated using Weblate (Hungarian)
  Translated using Weblate (Estonian)
  Translated using Weblate (German)
  Update playlist page to add remove duplicate videos button for user playlists (FreeTubeApp#5191)
  Respect playlist sort order in `watch-video-playlist` (FreeTubeApp#5013)
  Translated using Weblate (Serbian)
  Translated using Weblate (Chinese (Simplified))
  Translated using Weblate (Chinese (Traditional))
  Translated using Weblate (Arabic)
  Translated using Weblate (Polish)
  Translated using Weblate (Italian)
  Translated using Weblate (Turkish)
  Translated using Weblate (Croatian)
  Translated using Weblate (Dutch)
  Translated using Weblate (Spanish)
  ...
  • Loading branch information
PikachuEXE committed Jun 13, 2024
2 parents 7b90488 + d56731e commit c6720d2
Show file tree
Hide file tree
Showing 44 changed files with 1,393 additions and 909 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ module.exports = {
ignoreText: ['-', '•', '/', 'YouTube', 'Invidious', 'FreeTube']
}
],
// Only applicable when we upgrade to Vue 3 and vue-i18n 9+
'@intlify/vue-i18n/no-deprecated-tc': 'off',

'vue/require-explicit-emits': 'error',
'vue/no-unused-emit-declarations': 'error',
},
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@
"vue-observe-visibility": "^1.0.0",
"vue-router": "^3.6.5",
"vuex": "^3.6.2",
"youtubei.js": "^9.4.0"
"youtubei.js": "^10.0.0"
},
"devDependencies": {
"@babel/core": "^7.24.6",
"@babel/eslint-parser": "^7.24.6",
"@babel/core": "^7.24.7",
"@babel/eslint-parser": "^7.24.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-env": "^7.24.6",
"@babel/preset-env": "^7.24.7",
"@double-great/stylelint-a11y": "^3.0.2",
"@intlify/eslint-plugin-vue-i18n": "^2.0.0",
"@intlify/eslint-plugin-vue-i18n": "^3.0.0",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
Expand All @@ -99,7 +99,7 @@
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-n": "^17.8.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-unicorn": "^53.0.0",
Expand Down
13 changes: 9 additions & 4 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const IpcChannels = {
OPEN_URL: 'open-url',
CHANGE_VIEW: 'change-view',

HISTORY_BACK: 'history-back',
HISTORY_FORWARD: 'history-forward',

DB_SETTINGS: 'db-settings',
DB_HISTORY: 'db-history',
DB_PROFILES: 'db-profiles',
Expand Down Expand Up @@ -116,12 +113,20 @@ const PLAYLIST_HEIGHT_FORCE_LIST_THRESHOLD = 500
// YouTube search character limit is 100 characters
const SEARCH_CHAR_LIMIT = 100

// Displayed on the about page and used in the main.js file to only allow bitcoin URLs with this wallet address to be opened
const ABOUT_BITCOIN_ADDRESS = '1Lih7Ho5gnxb1CwPD4o59ss78pwo2T91eS'

// Displayed on the about page and used in the main.js file to only allow monero URLs with this wallet address to be opened
const ABOUT_MONERO_ADDRESS = '48WyAPdjwc6VokeXACxSZCFeKEXBiYPV6GjfvBsfg4CrUJ95LLCQSfpM9pvNKy5GE5H4hNaw99P8RZyzmaU9kb1pD7kzhCB'

export {
IpcChannels,
DBActions,
SyncEvents,
MAIN_PROFILE_ID,
MOBILE_WIDTH_THRESHOLD,
PLAYLIST_HEIGHT_FORCE_LIST_THRESHOLD,
SEARCH_CHAR_LIMIT
SEARCH_CHAR_LIMIT,
ABOUT_BITCOIN_ADDRESS,
ABOUT_MONERO_ADDRESS
}
48 changes: 39 additions & 9 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
import path from 'path'
import cp from 'child_process'

import { IpcChannels, DBActions, SyncEvents } from '../constants'
import {
IpcChannels,
DBActions,
SyncEvents,
ABOUT_BITCOIN_ADDRESS,
ABOUT_MONERO_ADDRESS
} from '../constants'
import * as baseHandlers from '../datastores/handlers/base'
import { extractExpiryTimestamp, ImageCache } from './ImageCache'
import { existsSync } from 'fs'
Expand Down Expand Up @@ -855,8 +861,36 @@ function runApp() {
session.defaultSession.closeAllConnections()
})

ipcMain.on(IpcChannels.OPEN_EXTERNAL_LINK, (_, url) => {
if (typeof url === 'string') shell.openExternal(url)
ipcMain.handle(IpcChannels.OPEN_EXTERNAL_LINK, (_, url) => {
if (typeof url === 'string') {
let parsedURL

try {
parsedURL = new URL(url)
} catch {
// If it's not a valid URL don't open it
return false
}

if (
parsedURL.protocol === 'http:' || parsedURL.protocol === 'https:' ||

// Email address on the about page and Autolinker detects and links email addresses
parsedURL.protocol === 'mailto:' ||

// Autolinker detects and links phone numbers
parsedURL.protocol === 'tel:' ||

// Donation links on the about page
(parsedURL.protocol === 'bitcoin:' && parsedURL.pathname === ABOUT_BITCOIN_ADDRESS) ||
(parsedURL.protocol === 'monero:' && parsedURL.pathname === ABOUT_MONERO_ADDRESS)
) {
shell.openExternal(url)
return true
}
}

return false
})

ipcMain.handle(IpcChannels.GET_SYSTEM_LOCALE, () => {
Expand Down Expand Up @@ -1543,9 +1577,7 @@ function runApp() {
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) { return }

browserWindow.webContents.send(
IpcChannels.HISTORY_BACK
)
browserWindow.webContents.goBack()
},
type: 'normal',
},
Expand All @@ -1555,9 +1587,7 @@ function runApp() {
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) { return }

browserWindow.webContents.send(
IpcChannels.HISTORY_FORWARD
)
browserWindow.webContents.goForward()
},
type: 'normal',
},
Expand Down
15 changes: 0 additions & 15 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export default defineComponent({
ipcRenderer = require('electron').ipcRenderer
this.setupListenersToSyncWindows()
this.activateKeyboardShortcuts()
this.activateIPCListeners()
this.openAllLinksExternally()
this.enableSetSearchQueryText()
this.enableOpenUrl()
Expand All @@ -200,10 +199,6 @@ export default defineComponent({
}, 500)
})

this.$router.afterEach((to, from) => {
this.$refs.topNav?.navigateHistory()
})

this.$router.onReady(() => {
if (this.$router.currentRoute.path === '/') {
this.$router.replace({ path: this.landingPage })
Expand Down Expand Up @@ -335,16 +330,6 @@ export default defineComponent({
})
},

activateIPCListeners: function () {
// handle menu event updates from main script
ipcRenderer.on(IpcChannels.HISTORY_BACK, (_event) => {
this.$refs.topNav.historyBack()
})
ipcRenderer.on(IpcChannels.HISTORY_FORWARD, (_event) => {
this.$refs.topNav.historyForward()
})
},

handleKeyboardShortcuts: function (event) {
if (event.altKey) {
switch (event.key) {
Expand Down
75 changes: 47 additions & 28 deletions src/renderer/components/ft-subscribe-button/ft-subscribe-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineComponent } from 'vue'
import { mapActions } from 'vuex'

import FtButton from '../../components/ft-button/ft-button.vue'
import FtPrompt from '../../components/ft-prompt/ft-prompt.vue'

import { MAIN_PROFILE_ID } from '../../../constants'
import { deepCopy, showToast } from '../../helpers/utils'
Expand All @@ -11,7 +12,8 @@ import { getFirstCharacter } from '../../helpers/strings'
export default defineComponent({
name: 'FtSubscribeButton',
components: {
'ft-button': FtButton
'ft-button': FtButton,
'ft-prompt': FtPrompt
},
props: {
channelId: {
Expand Down Expand Up @@ -42,7 +44,8 @@ export default defineComponent({
},
data: function () {
return {
isProfileDropdownOpen: false
isProfileDropdownOpen: false,
showUnsubscribePopupForProfile: null
}
},
computed: {
Expand Down Expand Up @@ -108,34 +111,14 @@ export default defineComponent({
return
}

const currentProfile = deepCopy(profile)

if (this.isProfileSubscribed(profile)) {
currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => {
return channel.id !== this.channelId
})

this.updateProfile(currentProfile)
showToast(this.$t('Channel.Channel has been removed from your subscriptions'))

if (profile._id === MAIN_PROFILE_ID) {
// Check if a subscription exists in a different profile.
// Remove from there as well.
let duplicateSubscriptions = 0

this.profileList.forEach((profileInList) => {
if (profileInList._id === MAIN_PROFILE_ID) {
return
}
duplicateSubscriptions += this.unsubscribe(profileInList, this.channelId)
})

if (duplicateSubscriptions > 0) {
const message = this.$t('Channel.Removed subscription from {count} other channel(s)', { count: duplicateSubscriptions })
showToast(message)
}
if (this.$store.getters.getUnsubscriptionPopupStatus) {
this.showUnsubscribePopupForProfile = profile
} else {
this.handleUnsubscription(profile)
}
} else {
const currentProfile = deepCopy(profile)
const subscription = {
id: this.channelId,
name: this.channelName,
Expand Down Expand Up @@ -173,10 +156,46 @@ export default defineComponent({
}
},

toggleProfileDropdown: function() {
toggleProfileDropdown: function () {
this.isProfileDropdownOpen = !this.isProfileDropdownOpen
},

handleUnsubscribeConfirmation: async function (value) {
const profile = this.showUnsubscribePopupForProfile
this.showUnsubscribePopupForProfile = null
if (value === 'yes') {
this.handleUnsubscription(profile)
}
},

handleUnsubscription: function (profile) {
const currentProfile = deepCopy(profile)
currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => {
return channel.id !== this.channelId
})

this.updateProfile(currentProfile)
showToast(this.$t('Channel.Channel has been removed from your subscriptions'))

if (profile._id === MAIN_PROFILE_ID) {
// Check if a subscription exists in a different profile.
// Remove from there as well.
let duplicateSubscriptions = 0

this.profileList.forEach((profileInList) => {
if (profileInList._id === MAIN_PROFILE_ID) {
return
}
duplicateSubscriptions += this.unsubscribe(profileInList, this.channelId)
})

if (duplicateSubscriptions > 0) {
const message = this.$t('Channel.Removed subscription from {count} other channel(s)', { count: duplicateSubscriptions })
showToast(message)
}
}
},

isActiveProfile: function (profile) {
return profile._id === this.activeProfile._id
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
text-color="var(--text-with-main-color)"
@click="handleSubscription"
/>
<ft-prompt
v-if="showUnsubscribePopupForProfile !== null"
:label="$t('Channels.Unsubscribe Prompt', { channelName: channelName })"
:option-names="[$t('Yes'), $t('No')]"
:option-values="['yes', 'no']"
:autosize="true"
@click="handleUnsubscribeConfirmation"
/>
<ft-button
v-if="isProfileDropdownEnabled"
:no-border="true"
Expand Down
Loading

0 comments on commit c6720d2

Please sign in to comment.