Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
compact
@change="updateUnsubscriptionPopupStatus"
/>
<FtToggleSwitch
:label="$t('Settings.Subscription Settings.Randomize Order')"
:default-value="randomizeSubscriptionOrder"
compact
@change="updateRandomizeSubscriptionOrder"
/>
</div>
<div class="switchColumn">
<FtToggleSwitch
Expand Down Expand Up @@ -87,6 +93,16 @@ function updateUnsubscriptionPopupStatus(value) {
store.dispatch('updateUnsubscriptionPopupStatus', value)
}

/** @type {import('vue').ComputedRef<boolean>} */
const randomizeSubscriptionOrder = computed(() => store.getters.getRandomizeSubscriptionOrder)

/**
* @param {boolean} value
*/
function updateRandomizeSubscriptionOrder(value) {
store.dispatch('updateRandomizeSubscriptionOrder', value)
}

/** @type {import('vue').ComputedRef<boolean>} */
const onlyShowLatestFromChannel = computed(() => store.getters.getOnlyShowLatestFromChannel)

Expand Down
13 changes: 9 additions & 4 deletions src/renderer/helpers/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ export function updateVideoListAfterProcessing(videos) {
})
}

videoList.sort((a, b) => {
return b.published - a.published
})

if (store.getters.getRandomizeSubscriptionOrder) {
const shuffled = videoList.map(value => ({ value, sort: Math.random() }))
shuffled.sort((a, b) => a.sort - b.sort)
videoList = shuffled.map(item => item.value)
} else {
videoList.sort((a, b) => {
return b.published - a.published
})
}
return videoList
}

Expand Down
1 change: 1 addition & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ const state = {
maxVideoPlaybackRate: 3,
onlyShowLatestFromChannel: false,
onlyShowLatestFromChannelNumber: 1,
randomizeSubscriptionOrder: false,
openDeepLinksInNewWindow: false,
playNextVideo: false,
proxyHostname: '127.0.0.1',
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ Settings:
'Limit the number of videos displayed for each channel': 'Limit the number of videos displayed for each channel'
To: To
Confirm Before Unsubscribing: Confirm Before Unsubscribing
Randomize Order: Randomize Order
Distraction Free Settings:
Distraction Free Settings: Distraction Free
Sections:
Expand Down
Loading