sort songs by date added by yours truly
This commit is contained in:
parent
5ad4752795
commit
c1e3e73b37
3 changed files with 18 additions and 8 deletions
|
@ -72,6 +72,7 @@
|
||||||
"term.sortBy.genre": "Genre",
|
"term.sortBy.genre": "Genre",
|
||||||
"term.sortBy.releaseDate": "Release Date",
|
"term.sortBy.releaseDate": "Release Date",
|
||||||
"term.sortBy.duration": "Duration",
|
"term.sortBy.duration": "Duration",
|
||||||
|
"term.sortBy.dateAdded": "Date Added",
|
||||||
"term.sortOrder": "A-Z",
|
"term.sortOrder": "A-Z",
|
||||||
"term.sortOrder.ascending": "Ascending",
|
"term.sortOrder.ascending": "Ascending",
|
||||||
"term.sortOrder.descending": "Descending",
|
"term.sortOrder.descending": "Descending",
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
"term.sortBy.genre": "Dòng nhạc",
|
"term.sortBy.genre": "Dòng nhạc",
|
||||||
"term.sortBy.releaseDate": "Ngày ra mắt",
|
"term.sortBy.releaseDate": "Ngày ra mắt",
|
||||||
"term.sortBy.duration": "Thời lượng",
|
"term.sortBy.duration": "Thời lượng",
|
||||||
|
"term.sortBy.dateAdded": "Ngày thêm vào",
|
||||||
"term.sortOrder": "A-Z",
|
"term.sortOrder": "A-Z",
|
||||||
"term.sortOrder.ascending": "Tăng dần",
|
"term.sortOrder.ascending": "Tăng dần",
|
||||||
"term.sortOrder.descending": "Giảm dần",
|
"term.sortOrder.descending": "Giảm dần",
|
||||||
|
|
|
@ -113,7 +113,8 @@ const app = new Vue({
|
||||||
"name": "0",
|
"name": "0",
|
||||||
"genre": "0",
|
"genre": "0",
|
||||||
"releaseDate": "0",
|
"releaseDate": "0",
|
||||||
"durationInMillis": "0"
|
"durationInMillis": "0",
|
||||||
|
"dateAdded": "0"
|
||||||
},
|
},
|
||||||
sorting: "name",
|
sorting: "name",
|
||||||
sortOrder: "asc",
|
sortOrder: "asc",
|
||||||
|
@ -334,7 +335,8 @@ const app = new Vue({
|
||||||
"name": app.getLz('term.sortBy.name'),
|
"name": app.getLz('term.sortBy.name'),
|
||||||
"genre": app.getLz('term.sortBy.genre'),
|
"genre": app.getLz('term.sortBy.genre'),
|
||||||
"releaseDate": app.getLz('term.sortBy.releaseDate'),
|
"releaseDate": app.getLz('term.sortBy.releaseDate'),
|
||||||
"durationInMillis": app.getLz('term.sortBy.duration')
|
"durationInMillis": app.getLz('term.sortBy.duration'),
|
||||||
|
"dateAdded": app.getLz('term.sortBy.dateAdded')
|
||||||
}
|
}
|
||||||
|
|
||||||
app.$data.library.albums.sortingOptions = {
|
app.$data.library.albums.sortingOptions = {
|
||||||
|
@ -1333,7 +1335,7 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getNowPlayingItemDetailed(target) {
|
async getNowPlayingItemDetailed(target) {
|
||||||
let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], {"include[songs]": "albums,artists", l : this.mklang});
|
let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], {"include[songs]": "albums,artists", l : app.mklang});
|
||||||
app.searchAndNavigate(u.data.data[0], target)
|
app.searchAndNavigate(u.data.data[0], target)
|
||||||
},
|
},
|
||||||
async searchAndNavigate(item, target) {
|
async searchAndNavigate(item, target) {
|
||||||
|
@ -1567,17 +1569,23 @@ const app = new Vue({
|
||||||
searchLibrarySongs() {
|
searchLibrarySongs() {
|
||||||
let self = this
|
let self = this
|
||||||
let prefs = this.cfg.libraryPrefs.songs
|
let prefs = this.cfg.libraryPrefs.songs
|
||||||
|
let albumAdded = self.library?.albums?.listing?.map(function(i){return {[i.id]: i.attributes?.dateAdded}})
|
||||||
function sortSongs() {
|
function sortSongs() {
|
||||||
// sort this.library.songs.displayListing by song.attributes[self.library.songs.sorting] in descending or ascending order based on alphabetical order and numeric order
|
// sort this.library.songs.displayListing by song.attributes[self.library.songs.sorting] in descending or ascending order based on alphabetical order and numeric order
|
||||||
// check if song.attributes[self.library.songs.sorting] is a number and if so, sort by number if not, sort by alphabetical order ignoring case
|
// check if song.attributes[self.library.songs.sorting] is a number and if so, sort by number if not, sort by alphabetical order ignoring case
|
||||||
self.library.songs.displayListing.sort((a, b) => {
|
self.library.songs.displayListing.sort((a, b) => {
|
||||||
let aa = a.attributes[prefs.sort]
|
let aa = a.attributes[prefs.sort]
|
||||||
let bb = b.attributes[prefs.sort]
|
let bb = b.attributes[prefs.sort]
|
||||||
if (self.library.songs.sorting == "genre") {
|
if (prefs.sort == "genre") {
|
||||||
aa = a.attributes.genreNames[0]
|
aa = a.attributes.genreNames[0]
|
||||||
bb = b.attributes.genreNames[0]
|
bb = b.attributes.genreNames[0]
|
||||||
}
|
}
|
||||||
|
if (prefs.sort == "dateAdded"){
|
||||||
|
let albumida = a.relationships?.albums?.data[0]?.id ?? '1970-01-01T00:01:01Z'
|
||||||
|
let albumidb = b.relationships?.albums?.data[0]?.id ?? '1970-01-01T00:01:01Z'
|
||||||
|
aa = new Date(((albumAdded.find(i => i[albumida]))?? [])[albumida] ?? '1970-01-01T00:01:01Z').getTime()
|
||||||
|
bb = new Date(((albumAdded.find(i => i[albumidb]))?? [])[albumidb] ?? '1970-01-01T00:01:01Z').getTime()
|
||||||
|
}
|
||||||
if (aa == null) {
|
if (aa == null) {
|
||||||
aa = ""
|
aa = ""
|
||||||
}
|
}
|
||||||
|
@ -1829,7 +1837,7 @@ const app = new Vue({
|
||||||
"fields[catalog]": "artistUrl,albumUrl",
|
"fields[catalog]": "artistUrl,albumUrl",
|
||||||
"fields[songs]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
"fields[songs]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
||||||
limit: 100,
|
limit: 100,
|
||||||
l: this.mklang
|
l: self.mklang
|
||||||
}
|
}
|
||||||
const safeparams = {
|
const safeparams = {
|
||||||
"platform": "web",
|
"platform": "web",
|
||||||
|
@ -1933,7 +1941,7 @@ const app = new Vue({
|
||||||
"fields[catalog]": "artistUrl,albumUrl",
|
"fields[catalog]": "artistUrl,albumUrl",
|
||||||
"fields[albums]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
"fields[albums]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
||||||
limit: 100,
|
limit: 100,
|
||||||
l: this.mklang
|
l: self.mklang
|
||||||
}
|
}
|
||||||
const safeparams = {
|
const safeparams = {
|
||||||
platform: "web",
|
platform: "web",
|
||||||
|
@ -2043,7 +2051,7 @@ const app = new Vue({
|
||||||
// "fields[catalog]": "artistUrl,albumUrl",
|
// "fields[catalog]": "artistUrl,albumUrl",
|
||||||
// "fields[artists]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
// "fields[artists]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,name,playParams,releaseDate,url",
|
||||||
limit: 100,
|
limit: 100,
|
||||||
l: this.mklang
|
l: self.mklang
|
||||||
}
|
}
|
||||||
const safeparams = {
|
const safeparams = {
|
||||||
include: "catalog",
|
include: "catalog",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue