Skip to content

Commit

Permalink
fix: remote pairing code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelin committed Jun 1, 2020
1 parent 4596d29 commit e095212
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 569 deletions.
18 changes: 0 additions & 18 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ const routes = [
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
}
// {
// Removed as all was moved into Settings
// path: '/choose-edge-connection',
// name: 'choose-edge-connection',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
// component: () => import(/* webpackChunkName: "choose-edge-connection" */ '../views/ChooseEdgeConnection.vue')
// },
// {
// Also removed as everything was moved into Settings
// path: '/remote-edge-connection',
// name: 'remote-edge-connection',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
// component: () => import(/* webpackChunkName: "remote-edge-connection" */ '../views/RemoteEdgeConnection.vue')
// }
]

const router = new VueRouter({
Expand Down
1 change: 0 additions & 1 deletion src/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ export const NEW_PEER_ID = 'NEW_PEER_ID'
export const NEW_REMOTE_PEER_ID = 'NEW_REMOTE_PEER_ID'
export const REMOTE_PEER_ID_REMOVED = 'REMOTE_PEER_ID_REMOVED'
export const PEER_FETCH = 'PEER_FETCH'
export const REMOTE_PEER_ID_CHANGED = 'REMOTE_PEER_ID_CHANGED'
export const UPDATE_AVAILABLE = 'UPDATE_AVAILABLE'
34 changes: 10 additions & 24 deletions src/store/pnp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
NEW_PEER_ID,
NEW_REMOTE_PEER_ID,
REMOTE_PEER_ID_REMOVED,
PEER_FETCH,
REMOTE_PEER_ID_CHANGED
PEER_FETCH
} from './mutation-types.js'
import {
INITIALIZE_PNP,
Expand Down Expand Up @@ -77,11 +76,7 @@ const state = {
/**
PeerFetch instance
*/
peerFetch: PeerFetch,
/**
Edgeroom ID when connecting to remote network
*/
edgeRoom: undefined
peerFetch: PeerFetch
}

const mutations = {
Expand Down Expand Up @@ -138,11 +133,6 @@ const mutations = {
[PEER_FETCH] (state, peerFetch) {
console.debug('Setting PeerFetch instance.')
state.peerFetch = peerFetch
},
[REMOTE_PEER_ID_CHANGED] (state, newRemotePeerId) {
state.edgeRoom = newRemotePeerId
state.remotePeerId = null
window.localStorage.removeItem(`${STORAGE_KEY}.remotePeerId`)
}
}

Expand All @@ -156,9 +146,6 @@ const mutations = {
async function discoverRemotePeerId ({ peer, state, commit }) {
// first see if we got a remote Edge ID entered to connect to
console.log(state)
if (state.edgeRoom !== undefined) {
return state.edgeRoom
}
if (state.remotePeerId) {
return state.remotePeerId
} else {
Expand Down Expand Up @@ -495,18 +482,17 @@ const actions = {
// console.debug('peerFetch.get returned response', { request2, response2 })
},
/**
* @param {*} edgeAddress The Edge PeerJS address that UI will connect too
* Update Edge Address for the remote Ambianic Edge you want to connect to
* Perhaps your parents are isolated, then it would be nixe to connect to
* @param {*} remotePeerId The Ambianic Edge PeerJS ID
* that the Ambianic UI will pair with.
*
* Update Ambianic Edge Peer ID for the remote Ambianic Edge you want to pair with.
* Perhaps your parents are isolated, then it would be nice to connect to
* them or let them connect to you.
* When connecting to a remote network, edgeAddress will be the PeerJS ID
* from the remote Edge, and when connecting back to local network, it will be
* undefined.
*/
async [CHANGE_REMOTE_PEER_ID] ({ state, commit, dispatch }, edgeAddress) {
commit(REMOTE_PEER_ID_CHANGED, edgeAddress)
async [CHANGE_REMOTE_PEER_ID] ({ state, commit, dispatch }, remotePeerId) {
commit(NEW_REMOTE_PEER_ID, remotePeerId)
commit(PEER_DISCONNECTED)
dispatch(PEER_DISCOVER)
dispatch(PEER_CONNECT, remotePeerId)
},
/**
* Remove remote peer id from local store.
Expand Down
156 changes: 0 additions & 156 deletions src/views/ChooseEdgeConnection.vue

This file was deleted.

Loading

0 comments on commit e095212

Please sign in to comment.