Skip to content

Commit 25fbb96

Browse files
authored
Merge pull request #247 from KenEucker/develop
3.3.4
2 parents 497c17c + 3e1d742 commit 25fbb96

File tree

11 files changed

+103
-46
lines changed

11 files changed

+103
-46
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Node
1919
uses: actions/setup-node@v3
2020
with:
21-
node-version: 18
21+
node-version: 20
2222
- name: Reconfigure git to use HTTP authentication
2323
run: >
2424
git config --global url."https://github.com/".insteadOf

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "biketag-vue",
3-
"version": "3.3.3",
3+
"version": "3.3.4",
44
"license": "AGPL-3.0-or-later",
55
"author": "Ken Eucker",
66
"bugs": {
@@ -31,7 +31,7 @@
3131
"@vueuse/head": "^2.0.0",
3232
"ajv": "^8.12.0",
3333
"autoprefixer": "^10.4.17",
34-
"biketag": "^3.3.3",
34+
"biketag": "^3.3.4",
3535
"bootstrap": "^5.3.2",
3636
"bootstrap-vue-next": "^0.15.5",
3737
"crypto-js": "^4.2.0",
@@ -119,7 +119,7 @@
119119
"workbox-window": "^7.0.0"
120120
},
121121
"engines": {
122-
"node": ">=18"
122+
"node": ">=20"
123123
},
124124
"lint-staged": {
125125
"*.ts": [

src/App.vue

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ function checkForNewBikeTagPost() {
136136
137137
// created
138138
async function created() {
139-
const initResults = []
140139
/// Set it first thing
141140
await router.isReady()
142141
const _gameIsSet = store.gameName?.length !== 0
@@ -151,8 +150,6 @@ async function created() {
151150
gameIsSet.value = true
152151
const routeIsHome = routeIsRoot ? true : router.currentRoute.value?.name === 'Home'
153152
154-
initResults.push(await store.fetchCurrentBikeTag())
155-
156153
if (game && routeIsHome) {
157154
const tagnumber =
158155
router.currentRoute.value.path.length > 1
@@ -161,15 +158,7 @@ async function created() {
161158
const params = { tagnumber }
162159
await router.push({ name: 'Home', params })
163160
}
164-
165-
initResults.push(store.fetchTags())
166-
initResults.push(store.fetchPlayers())
167-
initResults.push(store.fetchLeaderboard())
168-
initResults.push(await store.fetchCredentials())
169-
initResults.push(store.fetchQueuedTags())
170-
initResults.push(store.fetchAllGames())
171-
172-
await Promise.allSettled(initResults)
161+
await store.FetchAllData({ currentBikeTagSync: true, credentialsSync: true })
173162
174163
checkForNewBikeTagPost()
175164
} else if (!_gameIsSet) {

src/common/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ export interface AmbassadorProfile extends Profile {
7373
}
7474
export type BikeTagProfile = Partial<Profile> & Partial<AmbassadorProfile>
7575
export interface BikeTagStoreState {
76-
dataLoaded: boolean
76+
fetchingData: boolean
77+
dataFetched: boolean
7778
game: Game
7879
allGames: Game[]
7980
achievements: Achievement[]

src/store/index.ts

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export const initBikeTagStore = () => {
6262

6363
export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
6464
state: (): BikeTagStoreState => ({
65-
dataLoaded: false,
65+
fetchingData: false,
66+
dataFetched: false,
6667
gameName,
6768
gameNameProper: gameName?.length ? gameName[0].toUpperCase() + gameName.slice(1) : '',
6869
game: {} as Game,
@@ -83,6 +84,22 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
8384
}),
8485

8586
actions: {
87+
async isReady() {
88+
if (this.dataFetched) {
89+
return Promise.resolve() // Data is already loaded, resolve immediately
90+
}
91+
92+
return new Promise((resolve) => {
93+
const checkIsDataLoaded = () => {
94+
if (this.dataFetched) {
95+
clearInterval(intervalId) // Stop checking when isDataLoaded becomes true
96+
resolve(true)
97+
}
98+
}
99+
const intervalId = setInterval(checkIsDataLoaded, 100) // Check every 100 milliseconds (adjust as needed)
100+
checkIsDataLoaded() // Check immediately
101+
})
102+
},
86103
// eslint-disable-next-line no-empty-pattern
87104
async getRegionPolygon(region: any) {
88105
try {
@@ -162,7 +179,7 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
162179
async setGame(newGameName?: string) {
163180
newGameName = newGameName ?? this.gameName
164181
if (this.game?.name !== newGameName || !this.game?.mainhash) {
165-
this.dataLoaded = false
182+
this.fetchingData = false
166183
return client.getGame({ game: newGameName }, biketagGameOpts as any).then(async (r) => {
167184
if (r.success) {
168185
const game = r.data as Game
@@ -204,8 +221,65 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
204221
this.credentialsFetched = true
205222
}
206223
},
224+
async FetchAllData(
225+
opts: {
226+
currentBikeTagSync?: boolean
227+
skipCurrentBikeTag?: boolean
228+
tagsSync?: boolean
229+
skipTags?: boolean
230+
playersSync?: boolean
231+
skipPlayers?: boolean
232+
leaderboardSync?: boolean
233+
skipLeaderboard?: boolean
234+
credentialsSync?: boolean
235+
skipCredentials?: boolean
236+
queuedTagsSync?: boolean
237+
skipQueuedTags?: boolean
238+
allGamesSync?: boolean
239+
skipAllGames?: boolean
240+
} = {},
241+
) {
242+
const initResults: any[] = []
243+
this.fetchingData = true
244+
245+
if (!opts.skipCurrentBikeTag) {
246+
if (opts.currentBikeTagSync) initResults.push(await this.fetchCurrentBikeTag())
247+
else initResults.push(this.fetchCurrentBikeTag())
248+
}
249+
if (!opts.skipTags) {
250+
if (opts.tagsSync) initResults.push(await this.fetchTags())
251+
else initResults.push(this.fetchTags())
252+
}
253+
if (!opts.skipPlayers) {
254+
if (opts.playersSync) initResults.push(await this.fetchPlayers())
255+
else initResults.push(this.fetchPlayers())
256+
}
257+
if (!opts.skipLeaderboard) {
258+
if (opts.leaderboardSync) initResults.push(await this.fetchLeaderboard())
259+
else initResults.push(this.fetchLeaderboard())
260+
}
261+
if (!opts.skipCredentials) {
262+
if (opts.credentialsSync) initResults.push(await this.fetchCredentials())
263+
else initResults.push(await this.fetchCredentials())
264+
}
265+
if (!opts.skipQueuedTags) {
266+
if (opts.queuedTagsSync) initResults.push(await this.fetchQueuedTags())
267+
else initResults.push(this.fetchQueuedTags())
268+
}
269+
if (!opts.skipAllGames) {
270+
if (opts.allGamesSync) initResults.push(await this.fetchAllGames())
271+
else initResults.push(this.fetchAllGames())
272+
}
273+
274+
Promise.allSettled(initResults).then((results) => {
275+
this.dataFetched = true
276+
this.fetchingData = false
277+
})
278+
279+
return initResults
280+
},
207281
fetchAllGames(cached = true) {
208-
this.dataLoaded = false
282+
this.fetchingData = false
209283
const biketagClient = new BikeTagClient({ ...biketagClientOpts, game: undefined, cached })
210284
return biketagClient
211285
.getGame(
@@ -572,7 +646,7 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
572646
SET_GAME(game: any) {
573647
const oldState = this.game
574648
this.game = game
575-
this.dataLoaded = true
649+
this.fetchingData = true
576650

577651
if (oldState?.name !== game?.name) {
578652
debug(`${BikeTagDefaults.store}::game`, { game })
@@ -583,7 +657,7 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
583657
SET_ALL_GAMES(allGames: any) {
584658
const oldState = this.allGames
585659
this.allGames = allGames
586-
this.dataLoaded = true
660+
this.fetchingData = true
587661

588662
if (oldState?.length !== allGames?.length) {
589663
debug(`${BikeTagDefaults.store}::allGames`, { allGames })
@@ -849,9 +923,6 @@ export const useBikeTagStore = defineStore(BikeTagDefaults.store, {
849923
getQueuedTagState: (state) => {
850924
return getQueuedTagState(state.playerTag)
851925
},
852-
getDataLoaded(state) {
853-
return state.dataLoaded
854-
},
855926
getGame(state) {
856927
return state.game
857928
},

src/views/Approve.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ async function onApproveSubmit(newTagSubmission) {
159159
160160
// mounted
161161
onMounted(async () => {
162+
await store.isReady()
162163
await store.fetchQueuedTags(true)
163164
await store.fetchCredentials()
164165

src/views/Leaderboard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<template>
33
<div class="container">
44
<div class="player-list">
5-
<div v-for="player in playersList" :key="player.name" class="p-lg-1 p-md-1 mb-1">
5+
<div v-for="player in playersList" :key="player.name" class="mb-1 p-lg-1 p-md-1">
66
<player size="md" :player="player" />
77
</div>
88
</div>
@@ -19,7 +19,7 @@ import Player from '@/components/BikeTagPlayer.vue'
1919
// data
2020
const store = useBikeTagStore()
2121
22-
store.fetchLeaderboardPlayersProfiles()
22+
store.isReady().then(() => store.fetchLeaderboardPlayersProfiles())
2323
2424
// computed
2525
const playersList = computed(() => store.getLeaderboard)

src/views/Play.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ async function onQueueSubmit(newTagSubmission) {
236236
237237
// created
238238
const created = async () => {
239+
await store.isReady()
239240
await store.fetchCurrentBikeTag()
240241
await store.fetchQueuedTags(true)
241242
}

src/views/Player.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</div>
1717
</b-modal>
1818
<div v-if="player" class="container biketag-player">
19-
<div class="social mb-2">
19+
<div class="mb-2 social">
2020
<div class="mt-5 mr-2" @click="showBikeDex">
2121
<img
2222
v-if="bikedex?.length"
@@ -67,7 +67,7 @@
6767
</div>
6868
</div>
6969
<b-form-group>
70-
<select v-model="perPage" class="form-select mb-2 m-auto" @change="resetCurrentPage">
70+
<select v-model="perPage" class="m-auto mb-2 form-select" @change="resetCurrentPage">
7171
<option v-for="i in 3" :key="Math.pow(10, i)" :value="Math.pow(10, i)">
7272
{{ Math.pow(10, i) }}
7373
</option>
@@ -130,8 +130,6 @@ const modal = ref(false)
130130
const playerName = ref(decodeURIComponent(encodeURIComponent(route.params.name)))
131131
const player = computed(() => store.getPlayers.find((p) => p.name === playerName.value))
132132
133-
store.fetchAllAchievements()
134-
135133
// computed
136134
const bikedex = computed(() => [])
137135
const achievements = computed(() => player.value?.achievements?.map(store.getBikeTagAchievement))
@@ -180,6 +178,8 @@ watch(
180178
181179
// mounted
182180
onMounted(async () => {
181+
await store.isReady()
182+
store.fetchAllAchievements()
183183
await store.fetchPlayers() // ensure the players are set before fetching THIS player's additional profile info
184184
store.fetchPlayerProfile(playerName.value)
185185
})

0 commit comments

Comments
 (0)