|
|
@@ -5,7 +5,10 @@ main.view--home
|
|
5
|
5
|
w-spinner(bounce)
|
|
6
|
6
|
|
|
7
|
7
|
template(v-else-if='!isLoading && cards.length > 0')
|
|
8
|
|
- ProfileCardList(:cards='cards')
|
|
|
8
|
+ ProfileCardList(
|
|
|
9
|
+ :cards='cards'
|
|
|
10
|
+ @loadMore='onLoadMore'
|
|
|
11
|
+ )
|
|
9
|
12
|
|
|
10
|
13
|
template(v-else-if='cards.length === 0')
|
|
11
|
14
|
p No profiles in match_queue.
|
|
|
@@ -21,7 +24,7 @@ import PairingButton from '../components/PairingButton.vue'
|
|
21
|
24
|
|
|
22
|
25
|
import { Card } from '../entities'
|
|
23
|
26
|
|
|
24
|
|
-import { currentProfile } from '../services'
|
|
|
27
|
+import { currentProfile, fetchQueueByProfileId } from '../services'
|
|
25
|
28
|
import { mixins } from '../utils'
|
|
26
|
29
|
|
|
27
|
30
|
const notificationOpts = {
|
|
|
@@ -60,12 +63,25 @@ export default {
|
|
60
|
63
|
PairingButton,
|
|
61
|
64
|
},
|
|
62
|
65
|
mixins: [mixins.profileMixin],
|
|
|
66
|
+ data(){
|
|
|
67
|
+ return {
|
|
|
68
|
+ fetchedCards: [],
|
|
|
69
|
+ offset: 0
|
|
|
70
|
+ }
|
|
|
71
|
+ },
|
|
63
|
72
|
computed: {
|
|
64
|
73
|
cards() {
|
|
65
|
|
- return currentProfile.queue.map(qProfile => convertToCard(qProfile))
|
|
|
74
|
+ let initialCards = currentProfile.queue.map(qProfile => convertToCard(qProfile))
|
|
|
75
|
+ if(this.fetchedCards.length === 0) return initialCards
|
|
|
76
|
+ return [...initialCards,...this.fetchedCards.map(qProfile => convertToCard(qProfile))]
|
|
66
|
77
|
},
|
|
67
|
78
|
},
|
|
68
|
79
|
methods: {
|
|
|
80
|
+ async onLoadMore(){
|
|
|
81
|
+ this.offset += 5 // fetch next batch with updated offset
|
|
|
82
|
+ let newQueue = await fetchQueueByProfileId(currentProfile.id._value, 5, this.offset)
|
|
|
83
|
+ this.fetchedCards.push(...newQueue) // update fetchedCards => recalculate cards
|
|
|
84
|
+ },
|
|
69
|
85
|
// this can be placed in utils/notification.js
|
|
70
|
86
|
notify(payload) {
|
|
71
|
87
|
notificationOpts.message = payload
|