Skip to content

Commit a8c2048

Browse files
committed
Update to use getIconForSortPreference util function with all arrows pointing down
1 parent 82b9c89 commit a8c2048

File tree

10 files changed

+54
-64
lines changed

10 files changed

+54
-64
lines changed

src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import FtSelect from '../../components/ft-select/ft-select.vue'
1010
import FtToggleSwitch from '../../components/ft-toggle-switch/ft-toggle-switch.vue'
1111
import {
1212
showToast,
13+
getIconForSortPreference
1314
} from '../../helpers/utils'
1415

1516
const SORT_BY_VALUES = {
@@ -154,19 +155,6 @@ export default defineComponent({
154155
sortBySelectValues() {
155156
return Object.values(SORT_BY_VALUES)
156157
},
157-
sortIcon: function () {
158-
switch (this.sortBy) {
159-
case SORT_BY_VALUES.NameDescending:
160-
case SORT_BY_VALUES.LatestCreatedFirst:
161-
case SORT_BY_VALUES.LatestUpdatedFirst:
162-
return ['fas', 'arrow-down-short-wide']
163-
case SORT_BY_VALUES.NameAscending:
164-
case SORT_BY_VALUES.EarliestCreatedFirst:
165-
case SORT_BY_VALUES.EarliestUpdatedFirst:
166-
default:
167-
return ['fas', 'arrow-up-wide-short']
168-
}
169-
}
170158
},
171159
watch: {
172160
allPlaylistsLength(val, oldVal) {
@@ -282,6 +270,8 @@ export default defineComponent({
282270
this.query = query
283271
},
284272

273+
getIconForSortPreference: (s) => getIconForSortPreference(s),
274+
285275
...mapActions([
286276
'addVideos',
287277
'updatePlaylist',

src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
:select-names="sortBySelectNames"
4141
:select-values="sortBySelectValues"
4242
:placeholder="$t('User Playlists.Sort By.Sort By')"
43-
:icon="sortIcon"
43+
:icon="getIconForSortPreference(sortBy)"
4444
@change="sortBy = $event"
4545
/>
4646
</div>

src/renderer/helpers/utils.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@ function currentLocale () {
1515
return i18n.locale.replace('_', '-')
1616
}
1717

18+
export function getIconForSortPreference(sortPreference) {
19+
switch (sortPreference) {
20+
case 'name_descending':
21+
case 'author_descending':
22+
case 'video_title_descending':
23+
return ['fas', 'sort-alpha-down-alt']
24+
case 'name_ascending':
25+
case 'author_ascending':
26+
case 'video_title_ascending':
27+
return ['fas', 'sort-alpha-down']
28+
case 'latest_updated_first':
29+
case 'latest_created_first':
30+
case 'latest_played_first':
31+
case 'date_added_descending':
32+
case 'last':
33+
case 'newest':
34+
case 'popular':
35+
case 'custom':
36+
return ['fas', 'arrow-down-wide-short']
37+
case 'earliest_updated_first':
38+
case 'earliest_created_first':
39+
case 'earliest_played_first':
40+
case 'date_added_ascending':
41+
case 'oldest':
42+
default:
43+
return ['fas', 'arrow-down-short-wide']
44+
}
45+
}
46+
1847
/**
1948
* @param {string} publishedText
2049
* @param {boolean} isLive

src/renderer/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import {
1515
faAngleUp,
1616
faArrowDown,
1717
faArrowDownShortWide,
18+
faArrowDownWideShort,
1819
faArrowLeft,
1920
faArrowRight,
2021
faArrowUp,
21-
faArrowUpWideShort,
2222
faBars,
2323
faBookmark,
2424
faCheck,
@@ -74,6 +74,8 @@ import {
7474
faServer,
7575
faShareAlt,
7676
faSlidersH,
77+
faSortAlphaDown,
78+
faSortAlphaDownAlt,
7779
faSortDown,
7880
faStepBackward,
7981
faStepForward,
@@ -106,10 +108,10 @@ library.add(
106108
faAngleUp,
107109
faArrowDown,
108110
faArrowDownShortWide,
111+
faArrowDownWideShort,
109112
faArrowLeft,
110113
faArrowRight,
111114
faArrowUp,
112-
faArrowUpWideShort,
113115
faBars,
114116
faBookmark,
115117
faCheck,
@@ -166,6 +168,8 @@ library.add(
166168
faServer,
167169
faShareAlt,
168170
faSlidersH,
171+
faSortAlphaDown,
172+
faSortAlphaDownAlt,
169173
faSortDown,
170174
faStepBackward,
171175
faStepForward,

src/renderer/views/Channel/Channel.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
copyToClipboard,
1919
extractNumberFromString,
2020
formatNumber,
21-
showToast
21+
showToast,
22+
getIconForSortPreference
2223
} from '../../helpers/utils'
2324
import { isNullOrEmpty } from '../../helpers/strings'
2425
import packageDetails from '../../../../package.json'
@@ -1950,17 +1951,7 @@ export default defineComponent({
19501951
})
19511952
},
19521953

1953-
sortIconFor: function (sortPreference) {
1954-
switch (sortPreference) {
1955-
case 'last':
1956-
case 'newest':
1957-
case 'popular':
1958-
return ['fas', 'arrow-down-short-wide']
1959-
case 'oldest':
1960-
default:
1961-
return ['fas', 'arrow-up-wide-short']
1962-
}
1963-
},
1954+
getIconForSortPreference: (s) => getIconForSortPreference(s),
19641955

19651956
...mapActions([
19661957
'showOutlines',

src/renderer/views/Channel/Channel.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
:select-names="videoLiveShortSelectNames"
238238
:select-values="videoLiveShortSelectValues"
239239
:placeholder="$t('Search Filters.Sort By.Sort By')"
240-
:icon="sortIconFor(videoSortBy)"
240+
:icon="getIconForSortPreference(videoSortBy)"
241241
@change="videoSortBy = $event"
242242
/>
243243
<ft-select
@@ -247,7 +247,7 @@
247247
:select-names="videoLiveShortSelectNames"
248248
:select-values="videoLiveShortSelectValues"
249249
:placeholder="$t('Search Filters.Sort By.Sort By')"
250-
:icon="sortIconFor(shortSortBy)"
250+
:icon="getIconForSortPreference(shortSortBy)"
251251
@change="shortSortBy = $event"
252252
/>
253253
<ft-select
@@ -257,7 +257,7 @@
257257
:select-names="videoLiveShortSelectNames"
258258
:select-values="videoLiveShortSelectValues"
259259
:placeholder="$t('Search Filters.Sort By.Sort By')"
260-
:icon="sortIconFor(liveSortBy)"
260+
:icon="getIconForSortPreference(liveSortBy)"
261261
@change="liveSortBy = $event"
262262
/>
263263
<ft-select
@@ -267,7 +267,7 @@
267267
:select-names="playlistSelectNames"
268268
:select-values="playlistSelectValues"
269269
:placeholder="$t('Search Filters.Sort By.Sort By')"
270-
:icon="sortIconFor(playlistSortBy)"
270+
:icon="getIconForSortPreference(playlistSortBy)"
271271
@change="playlistSortBy = $event"
272272
/>
273273
</div>

src/renderer/views/Playlist/Playlist.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
getLocalPlaylistContinuation,
1515
parseLocalPlaylistVideo,
1616
} from '../../helpers/api/local'
17-
import { extractNumberFromString, setPublishedTimestampsInvidious, showToast } from '../../helpers/utils'
17+
import { extractNumberFromString, getIconForSortPreference, setPublishedTimestampsInvidious, showToast } from '../../helpers/utils'
1818
import { invidiousGetPlaylistInfo, youtubeImageUrlToInvidious } from '../../helpers/api/invidious'
1919

2020
const SORT_BY_VALUES = {
@@ -241,20 +241,6 @@ export default defineComponent({
241241
sortBySelectValues() {
242242
return this.sortByValues
243243
},
244-
sortIcon: function () {
245-
switch (this.sortOrder) {
246-
case SORT_BY_VALUES.DateAddedNewest:
247-
case SORT_BY_VALUES.VideoTitleDescending:
248-
case SORT_BY_VALUES.AuthorDescending:
249-
return ['fas', 'arrow-down-short-wide']
250-
case SORT_BY_VALUES.DateAddedOldest:
251-
case SORT_BY_VALUES.VideoTitleAscending:
252-
case SORT_BY_VALUES.AuthorAscending:
253-
case SORT_BY_VALUES.Custom:
254-
default:
255-
return ['fas', 'arrow-up-wide-short']
256-
}
257-
}
258244
},
259245
watch: {
260246
$route () {
@@ -571,6 +557,8 @@ export default defineComponent({
571557
}
572558
},
573559

560+
getIconForSortPreference: (s) => getIconForSortPreference(s),
561+
574562
...mapActions([
575563
'updateSubscriptionDetails',
576564
'updatePlaylist',

src/renderer/views/Playlist/Playlist.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
:select-names="sortBySelectNames"
5151
:select-values="sortBySelectValues"
5252
:placeholder="$t('Playlist.Sort By.Sort By')"
53-
:icon="sortIcon"
53+
:icon="getIconForSortPreference(sortOrder)"
5454
@change="updateUserPlaylistSortOrder"
5555
/>
5656
<template

src/renderer/views/UserPlaylists/UserPlaylists.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import FtInput from '../../components/ft-input/ft-input.vue'
1212
import FtIconButton from '../../components/ft-icon-button/ft-icon-button.vue'
1313
import FtToggleSwitch from '../../components/ft-toggle-switch/ft-toggle-switch.vue'
1414
import FtAutoLoadNextPageWrapper from '../../components/ft-auto-load-next-page-wrapper/ft-auto-load-next-page-wrapper.vue'
15+
import { getIconForSortPreference } from '../../helpers/utils'
1516

1617
const SORT_BY_VALUES = {
1718
NameAscending: 'name_ascending',
@@ -164,21 +165,6 @@ export default defineComponent({
164165
sortBySelectValues() {
165166
return Object.values(SORT_BY_VALUES)
166167
},
167-
sortIcon: function () {
168-
switch (this.sortBy) {
169-
case SORT_BY_VALUES.NameDescending:
170-
case SORT_BY_VALUES.LatestCreatedFirst:
171-
case SORT_BY_VALUES.LatestUpdatedFirst:
172-
case SORT_BY_VALUES.LatestPlayedFirst:
173-
return ['fas', 'arrow-down-short-wide']
174-
case SORT_BY_VALUES.NameAscending:
175-
case SORT_BY_VALUES.EarliestCreatedFirst:
176-
case SORT_BY_VALUES.EarliestPlayedFirst:
177-
case SORT_BY_VALUES.EarliestUpdatedFirst:
178-
default:
179-
return ['fas', 'arrow-up-wide-short']
180-
}
181-
}
182168
},
183169
watch: {
184170
lowerCaseQuery() {
@@ -257,6 +243,8 @@ export default defineComponent({
257243
})
258244
},
259245

246+
getIconForSortPreference: (s) => getIconForSortPreference(s),
247+
260248
...mapActions([
261249
'showCreatePlaylistPrompt'
262250
])

src/renderer/views/UserPlaylists/UserPlaylists.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
:select-names="sortBySelectNames"
5050
:select-values="sortBySelectValues"
5151
:placeholder="$t('User Playlists.Sort By.Sort By')"
52-
:icon="sortIcon"
52+
:icon="getIconForSortPreference(sortBy)"
5353
@change="sortBy = $event"
5454
/>
5555
</div>

0 commit comments

Comments
 (0)