1
+ import { computed } from "vue" ;
2
+
1
3
import { mapState } from "pinia" ;
2
4
import { useKumiteStore } from "./store.js" ;
3
5
import { useUserStore } from "./store-user.js" ;
@@ -7,12 +9,16 @@ import KumiteContestHeader from "./kumite-contest-header.js";
7
9
8
10
import KumiteBoardOverviewInner from "./kumite-board-overview-inner.js" ;
9
11
12
+ import KumiteBoardNotReady from "./kumite-board-notready.js" ;
13
+ import { isReady } from "./kumite-board-notready.js" ;
14
+
10
15
export default {
11
16
components : {
12
17
KumiteGameHeader,
13
18
KumiteContestHeader,
14
19
15
20
KumiteBoardOverviewInner,
21
+ KumiteBoardNotReady,
16
22
} ,
17
23
props : {
18
24
contestId : {
@@ -26,18 +32,6 @@ export default {
26
32
} ,
27
33
computed : {
28
34
...mapState ( useUserStore , [ "playingPlayerId" ] ) ,
29
- ...mapState ( useKumiteStore , [ "nbGameFetching" , "nbContestFetching" , "nbBoardFetching" ] ) ,
30
- ...mapState ( useKumiteStore , {
31
- game ( store ) {
32
- return store . games [ this . gameId ] || { error : "not_loaded" } ;
33
- } ,
34
- contest ( store ) {
35
- return store . contests [ this . contestId ] || { error : "not_loaded" } ;
36
- } ,
37
- board ( store ) {
38
- return store . contests [ this . contestId ] ?. board || { error : "not_loaded" } ;
39
- } ,
40
- } ) ,
41
35
} ,
42
36
setup ( props ) {
43
37
const store = useKumiteStore ( ) ;
@@ -47,25 +41,23 @@ export default {
47
41
userStore
48
42
. loadCurrentAccountPlayers ( )
49
43
. then ( ( ) => {
50
- return store . loadBoard ( props . gameId , props . contestId , userStore . playingPlayerId ) ;
44
+ if ( userStore . playingPlayerId ) {
45
+ return store . loadBoard ( props . gameId , props . contestId , userStore . playingPlayerId ) ;
46
+ } else {
47
+ console . log ( "Skip loading board as seemingly not logged-in" ) ;
48
+ }
51
49
} )
52
50
. then ( ( board ) => {
53
51
console . log ( "We loaded board" , board ) ;
54
52
} ) ;
55
53
56
- return { } ;
54
+ const weAreReady = computed ( ( ) => isReady ( props . gameId , props . contestId ) ) ;
55
+
56
+ return { weAreReady } ;
57
57
} ,
58
58
// https://stackoverflow.com/questions/7717929/how-do-i-get-pre-style-overflow-scroll-height-150px-to-display-at-parti
59
59
template : /* HTML */ `
60
- <div v-if="(!game || !contest || !board)">
61
- <div class="spinner-border" role="status" v-if="(nbGameFetching > 0 || nbContestFetching > 0 || nbBoardFetching > 0)">
62
- <span class="visually-hidden">Loading board for contestId={{contestId}}</span>
63
- </div>
64
- <div v-else>
65
- <span>Issue loading board for contestId={{contestId}}</span>
66
- </div>
67
- </div>
68
- <div v-else-if="game.error || contest.error || board.error">{{game.error || contest.error || board.error}}</div>
60
+ <KumiteBoardNotReady v-if="!weAreReady" :gameId="gameId" :contestId="contestId" />
69
61
<div v-else class="container">
70
62
<KumiteGameHeader class="row" :gameId="gameId" />
71
63
<KumiteContestHeader class="row" :gameId="gameId" :contestId="contestId" />
0 commit comments