Skip to content

Commit

Permalink
fix: pairing progress UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelin committed Jan 17, 2020
1 parent 28d189f commit 9b8a502
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/store/pnp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ const mutations = {
and reused until explicitly reset by the user.
*/
async function discoverRemotePeerId ({ peer, state, commit }) {
if (!state.remotePeerId) {
if (state.remotePeerId) {
return state.remotePeerId
} else {
// first try to find the remote peer ID in the same room
const myRoom = new PeerRoom(peer)
console.log('Fetching room members', myRoom)
Expand All @@ -120,11 +122,10 @@ async function discoverRemotePeerId ({ peer, state, commit }) {
// ask user for help
commit(USER_MESSAGE,
`Still looking.
Please make sure you are are on the same local network.
Please make sure you are on the same local network
as the Ambianic Edge device.
`)
}
} else {
return state.remotePeerId
}
}

Expand Down
52 changes: 33 additions & 19 deletions src/views/EdgeConnect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,29 +135,50 @@
</template>
<script>
import AppFrame from '@/components/AppFrame.vue'
import { settingsDB } from '@/store/db'
// import { settingsDB } from '@/store/db'
import { testConnection, EdgeConnectionStatus } from '@/remote/edgeAPI'
import { mapState } from 'vuex'
import { PEER_CONNECTION_ERROR } from '@/store/mutation-types'
import {
PEER_DISCONNECTED,
PEER_CONNECTING,
PEER_CONNECTED,
PEER_CONNECTION_ERROR
} from '@/store/mutation-types.js'
export default {
data: function () {
return {
edgeAddress: '',
// edgeAddress: '',
connectionStatus: '',
connectionTip: '',
testInProgress: false,
testDone: true,
statusColor: 'info',
connectStep: 0,
discoveryProgressValue: 0
statusColor: 'info'
}
},
computed: {
peerConnectionError: function () {
console.log('this.$store.state.pnp.peerConnectionStatus', this.$store.state.pnp.peerConnectionStatus)
return this.$store.state.pnp.peerConnectionStatus === PEER_CONNECTION_ERROR
},
connectStep: function () {
let step = 0
switch (this.$store.state.pnp.peerConnectionStatus) {
case PEER_DISCONNECTED:
case PEER_CONNECTION_ERROR:
step = 0
break
case PEER_CONNECTING:
step = 1
break
case PEER_CONNECTED:
step = 2
break
default:
break
}
return step
},
...mapState([
'peerConnectionStatus',
// map this.edgeConnected to this.$store.state.edgeConnected
Expand All @@ -169,26 +190,19 @@ export default {
},
mounted () {
this.loadSettings()
this.interval = setInterval(() => {
if (this.discoveryProgressValue === 100) {
return (this.discoveryProgressValue = 0)
}
this.discoveryProgressValue += 3
}, 1000)
},
beforeDestroy () {
clearInterval(this.interval)
},
methods: {
loadSettings () {
settingsDB.get('ambanic-edge-address').then(
(address) => {
this.edgeAddress = address
}
)
// settingsDB.get('ambanic-edge-address').then(
// (address) => {
// this.edgeAddress = address
// }
// )
},
saveSettings () {
settingsDB.set('ambanic-edge-address', this.edgeAddress)
// settingsDB.set('ambanic-edge-address', this.edgeAddress)
},
cancel () {
this.testInProgress = false
Expand Down

0 comments on commit 9b8a502

Please sign in to comment.