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 /> <br />
<router-link to="/subscriptions" class="uk-text-center">View Subscriptions</router-link> <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"> <div class="uk-align-right">
<a :href="getRssUrl"><font-awesome-icon icon="rss"></font-awesome-icon></a> <a :href="getRssUrl"><font-awesome-icon icon="rss"></font-awesome-icon></a>
</div> </div>
@ -31,6 +40,7 @@ export default {
data() { data() {
return { return {
videos: [], videos: [],
selectedSort: "descending",
}; };
}, },
mounted() { mounted() {
@ -45,6 +55,22 @@ export default {
authToken: this.getAuthToken(), 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: { computed: {
getRssUrl(_this) { getRssUrl(_this) {