Add sort filters for feed.

Closes #315
This commit is contained in:
FireMasterK 2021-07-27 23:34:27 +05:30
parent dcf6e672a9
commit c1a2aef8e3
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -6,6 +6,15 @@
<br />
<router-link to="/subscriptions" class="uk-text-center">View Subscriptions</router-link>
<br />
Sort by:
<select class="uk-select uk-width-auto" v-model="selectedSort" @change="onChange()">
<option value="descending">Most Recent</option>
<option value="ascending">Least Recent</option>
<option value="channel_ascending">Channel Name (A-Z)</option>
<option value="channel_descending">Channel Name (Z-A)</option>
</select>
<div class="uk-align-right">
<a :href="getRssUrl"><font-awesome-icon icon="rss"></font-awesome-icon></a>
</div>
@ -31,6 +40,7 @@ export default {
data() {
return {
videos: [],
selectedSort: "descending",
};
},
mounted() {
@ -45,6 +55,22 @@ export default {
authToken: this.getAuthToken(),
});
},
onChange() {
switch (this.selectedSort) {
case "ascending":
this.videos.sort((a, b) => a.uploaded - b.uploaded);
break;
case "descending":
this.videos.sort((a, b) => b.uploaded - a.uploaded);
break;
case "channel_ascending":
this.videos.sort((a, b) => a.uploaderName.localeCompare(b.uploaderName));
break;
case "channel_descending":
this.videos.sort((a, b) => b.uploaderName.localeCompare(a.uploaderName));
break;
}
},
},
computed: {
getRssUrl(_this) {