Fix kind sorting differently on client and build

This commit is contained in:
Sam Carlton 2020-11-26 17:01:10 -06:00
parent e659bbd6e4
commit 9f2a499e26
4 changed files with 37 additions and 21 deletions

View file

@ -37,30 +37,14 @@
import Search from '~/components/search.vue'
import LinkButton from '~/components/link-button.vue'
import { byTimeThenNull } from '~/helpers/sort-list.js'
import appList from '~/static/app-list.json'
import gameList from '~/game-list.json'
// console.log('appList.length', appList.length)
// console.log('gameList.length', gameList.length)
function byTimeThenNull (appA, appB) {
// console.log('appA.lastUpdated', appA.lastUpdated)
// equal items sort equally
if (appA.lastUpdated === appB.lastUpdated) {
return 0;
}
// nulls sort after anything else
else if (appA.lastUpdated === null) {
return 1;
}
else if (appB.lastUpdated === null) {
return -1;
}
return appB.lastUpdated.timestamp - appA.lastUpdated.timestamp
}
const sortedAppList = appList.sort(byTimeThenNull)
const mergedList = [

View file

@ -41,14 +41,16 @@
import Search from '~/components/search.vue'
import LinkButton from '~/components/link-button.vue'
import { byTimeThenNull } from '~/helpers/sort-list.js'
import appList from '~/static/app-list.json'
export default {
async asyncData ({ params: { slug } }) {
// Maybe I could import() here to reduce client script size
return {
slug,
app: appList.find(app => (app.slug === slug))
// app: appList.find(app => (app.slug === slug))
}
},
components: {
@ -67,9 +69,14 @@ export default {
}).section
},
sectionAppList () {
return appList.filter(app => {
const list = appList.filter(app => {
return app.section.slug === this.slug
})
const sortedList = list.sort(byTimeThenNull)
return sortedList
},
supportedAppList () {
return this.sectionAppList.filter(app => {