1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<script>
import keyBy from 'lodash/keyBy'
import * as github from '../github'
import { healthcheck, loadBehaviours } from '../api'
import { loadKeycodes } from '../keycodes'
import Loader from './loader.vue'
export default {
name: 'Initialize',
components: { Loader },
data () {
return {
keycodes: [],
behaviours: [],
indexedKeycodes: {},
indexedBehaviours: {},
repositories: [],
selectedRepository: null,
keymap: {},
layers: [],
layout: [],
tooManyRepos: false,
loadKeyboardError: null
}
},
provide() {
return {
keycodes: this.keycodes,
behaviours: this.behaviours,
indexedKeycodes: this.indexedKeycodes,
indexedBehaviours: this.indexedBehaviours
}
},
methods: {
async doReadyCheck() {
await healthcheck()
await this.loadAppData()
},
async loadAppData () {
await github.init()
const [ keycodes, behaviours ] = await Promise.all([
loadKeycodes(),
loadBehaviours()
])
this.keycodes.splice(0, this.keycodes.length, ...keycodes)
this.behaviours.splice(0, this.behaviours.length, ...behaviours)
Object.assign(this.indexedKeycodes, keyBy(this.keycodes, 'code'))
Object.assign(this.indexedBehaviours, keyBy(this.behaviours, 'code'))
}
}
}
</script>
<template>
<loader :load="doReadyCheck">
<slot
:tooManyRepos="tooManyRepos"
:loadKeyboardError="loadKeyboardError"
/>
</loader>
</template>
|