-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix Update Subscription Details function when channel name is null #3884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
FreeTubeBot
merged 2 commits into
FreeTubeApp:development
from
ChunkyProgrammer:use-option-chaining-for-sort
Aug 15, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import FtFlexBox from '../../components/ft-flex-box/ft-flex-box.vue' | |
| import FtChannelBubble from '../../components/ft-channel-bubble/ft-channel-bubble.vue' | ||
| import FtButton from '../../components/ft-button/ft-button.vue' | ||
| import FtPrompt from '../../components/ft-prompt/ft-prompt.vue' | ||
| import { showToast } from '../../helpers/utils' | ||
| import { deepCopy, showToast } from '../../helpers/utils' | ||
| import { youtubeImageUrlToInvidious } from '../../helpers/api/invidious' | ||
|
|
||
| export default defineComponent({ | ||
|
|
@@ -64,48 +64,38 @@ export default defineComponent({ | |
| this.$t('Yes'), | ||
| this.$t('No') | ||
| ] | ||
| } | ||
| }, | ||
| locale: function () { | ||
| return this.$i18n.locale.replace('_', '-') | ||
| }, | ||
| }, | ||
| watch: { | ||
| profile: function () { | ||
| this.subscriptions = JSON.parse(JSON.stringify(this.profile.subscriptions)).sort((a, b) => { | ||
| const nameA = a.name.toLowerCase() | ||
| const nameB = b.name.toLowerCase() | ||
| if (nameA < nameB) { | ||
| return -1 | ||
| } | ||
| if (nameA > nameB) { | ||
| return 1 | ||
| } | ||
| return 0 | ||
| }).map((channel) => { | ||
| const subscriptions = deepCopy(this.profile.subscriptions).sort((a, b) => { | ||
| return a.name?.toLowerCase().localeCompare(b.name?.toLowerCase(), this.locale) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm conditionally checking the name as there is a chance it is null due to the previous bug |
||
| }) | ||
| subscriptions.forEach((channel) => { | ||
| if (this.backendPreference === 'invidious') { | ||
| channel.thumbnail = youtubeImageUrlToInvidious(channel.thumbnail, this.currentInvidiousInstance) | ||
| } | ||
| channel.selected = false | ||
| return channel | ||
| }) | ||
|
|
||
| this.subscriptions = subscriptions | ||
| } | ||
| }, | ||
| mounted: function () { | ||
| if (typeof this.profile.subscriptions !== 'undefined') { | ||
| this.subscriptions = JSON.parse(JSON.stringify(this.profile.subscriptions)).sort((a, b) => { | ||
| const nameA = a.name.toLowerCase() | ||
| const nameB = b.name.toLowerCase() | ||
| if (nameA < nameB) { | ||
| return -1 | ||
| } | ||
| if (nameA > nameB) { | ||
| return 1 | ||
| } | ||
| return 0 | ||
| }).map((channel) => { | ||
| const subscriptions = deepCopy(this.profile.subscriptions).sort((a, b) => { | ||
| return a.name?.toLowerCase().localeCompare(b.name?.toLowerCase(), this.locale) | ||
| }) | ||
| subscriptions.forEach((channel) => { | ||
| if (this.backendPreference === 'invidious') { | ||
| channel.thumbnail = youtubeImageUrlToInvidious(channel.thumbnail, this.currentInvidiousInstance) | ||
| } | ||
| channel.selected = false | ||
| return channel | ||
| }) | ||
| this.subscriptions = subscriptions | ||
| } | ||
| }, | ||
| methods: { | ||
|
|
@@ -129,7 +119,7 @@ export default defineComponent({ | |
| }) | ||
|
|
||
| this.profileList.forEach((x) => { | ||
| const profile = JSON.parse(JSON.stringify(x)) | ||
| const profile = deepCopy(x) | ||
| profile.subscriptions = profile.subscriptions.filter((channel) => { | ||
| const index = channelsToRemove.findIndex((y) => { | ||
| return y.id === channel.id | ||
|
|
@@ -143,7 +133,7 @@ export default defineComponent({ | |
| showToast(this.$t('Profile.Profile has been updated')) | ||
| this.selectNone() | ||
| } else { | ||
| const profile = JSON.parse(JSON.stringify(this.profile)) | ||
| const profile = deepCopy(this.profile) | ||
|
|
||
| this.subscriptions = this.subscriptions.filter((channel) => { | ||
| return !channel.selected | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated all references of
JSON.parse(JSON.stringifyto use deepCopy to make the code more consistent