stash
This commit is contained in:
parent
58ad51fc5c
commit
d288c70e6a
3 changed files with 50 additions and 35 deletions
|
@ -6,7 +6,7 @@ class ServerSet {
|
||||||
if (!unreachable_neighbors || typeof unreachable_neighbors.queryUnreachable !== 'function' || typeof unreachable_neighbors.unreachable !== 'function') {
|
if (!unreachable_neighbors || typeof unreachable_neighbors.queryUnreachable !== 'function' || typeof unreachable_neighbors.unreachable !== 'function') {
|
||||||
throw new Error('no unreachable_neighbors')
|
throw new Error('no unreachable_neighbors')
|
||||||
}
|
}
|
||||||
this.servers = [... new Set(servers)] // deduplicate
|
this.servers = [...new Set(servers)] // deduplicate
|
||||||
this.unreachable_neighbors = unreachable_neighbors;
|
this.unreachable_neighbors = unreachable_neighbors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,11 +188,27 @@ class ServerSetUnion {
|
||||||
this.serverSets.push(serverset)
|
this.serverSets.push(serverset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async get(auth, target) {
|
||||||
|
try {
|
||||||
|
const ret = await this.serverSets.reduce(async (acc, serverset) => {
|
||||||
|
return acc.then(async (acc) => {
|
||||||
|
return acc.concat(await serverset.get(auth, target))
|
||||||
|
})
|
||||||
|
}, Promise.resolve([]))
|
||||||
|
return ret
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('all servers failed')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async post(auth, target, data) {
|
async post(auth, target, data) {
|
||||||
try {
|
try {
|
||||||
return await this.serverSets.reduce(async (acc, serverset) => {
|
const ret = await this.serverSets.reduce(async (acc, serverset) => {
|
||||||
return await serverset.post(auth, target, data)
|
return acc.then(async (acc) => {
|
||||||
}, Promise.resolve())
|
return acc.concat(await serverset.post(auth, target, data))
|
||||||
|
})
|
||||||
|
}, Promise.resolve([]))
|
||||||
|
return ret
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('all servers failed')
|
throw new Error('all servers failed')
|
||||||
}
|
}
|
||||||
|
@ -200,29 +216,12 @@ class ServerSetUnion {
|
||||||
|
|
||||||
async patch(auth, target, data) {
|
async patch(auth, target, data) {
|
||||||
try {
|
try {
|
||||||
return await this.serverSets.reduce(async (acc, serverset) => {
|
const ret = await this.serverSets.reduce(async (acc, serverset) => {
|
||||||
return await serverset.patch(auth, target, data)
|
return acc.then(async (acc) => {
|
||||||
}, Promise.resolve())
|
return acc.concat(await serverset.patch(auth, target, data))
|
||||||
} catch (e) {
|
})
|
||||||
throw new Error('all servers failed')
|
}, Promise.resolve([]))
|
||||||
}
|
return ret
|
||||||
}
|
|
||||||
|
|
||||||
async get(auth, target) {
|
|
||||||
try {
|
|
||||||
return await this.serverSets.reduce(async (acc, serverset) => {
|
|
||||||
return await serverset.get(auth, target)
|
|
||||||
}, Promise.resolve())
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('all servers failed')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(auth, target) {
|
|
||||||
try {
|
|
||||||
return await this.serverSets.reduce(async (acc, serverset) => {
|
|
||||||
return await serverset.delete(auth, target)
|
|
||||||
}, Promise.resolve())
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('all servers failed')
|
throw new Error('all servers failed')
|
||||||
}
|
}
|
||||||
|
@ -230,9 +229,25 @@ class ServerSetUnion {
|
||||||
|
|
||||||
async put(auth, target, data) {
|
async put(auth, target, data) {
|
||||||
try {
|
try {
|
||||||
return await this.serverSets.reduce(async (acc, serverset) => {
|
const ret = await this.serverSets.reduce(async (acc, serverset) => {
|
||||||
return await serverset.put(auth, target, data)
|
return acc.then(async (acc) => {
|
||||||
}, Promise.resolve())
|
return acc.concat(await serverset.put(auth, target, data))
|
||||||
|
})
|
||||||
|
}, Promise.resolve([]))
|
||||||
|
return ret
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('all servers failed')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(auth, target) {
|
||||||
|
try {
|
||||||
|
const ret = await this.serverSets.reduce(async (acc, serverset) => {
|
||||||
|
return acc.then(async (acc) => {
|
||||||
|
return acc.concat(await serverset.delete(auth, target))
|
||||||
|
})
|
||||||
|
}, Promise.resolve([]))
|
||||||
|
return ret
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('all servers failed')
|
throw new Error('all servers failed')
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ export default createStore({
|
||||||
if (domain === 'localhost')
|
if (domain === 'localhost')
|
||||||
return ['127.0.0.1:8000'];
|
return ['127.0.0.1:8000'];
|
||||||
if (domain === 'example.com')
|
if (domain === 'example.com')
|
||||||
return ['10.23.42.128:8000','10.23.42.128:8000'];
|
return ['10.23.42.128:8000', '10.23.42.128:8000'];
|
||||||
if (domain === 'example.jedi')
|
if (domain === 'example.jedi')
|
||||||
return ['10.23.42.128:8000'];
|
return ['10.23.42.128:8000'];
|
||||||
if (domain === 'example2.com')
|
if (domain === 'example2.com')
|
||||||
|
@ -153,6 +153,8 @@ export default createStore({
|
||||||
const s = await dispatch('lookupServer', {username: friend.username})
|
const s = await dispatch('lookupServer', {username: friend.username})
|
||||||
servers.add(new ServerSet(s, state.unreachable_neighbors))
|
servers.add(new ServerSet(s, state.unreachable_neighbors))
|
||||||
}
|
}
|
||||||
|
const home = await dispatch('getHomeServers')
|
||||||
|
servers.add(home)
|
||||||
return servers
|
return servers
|
||||||
})()
|
})()
|
||||||
commit('setAllFriendsServers', promise)
|
commit('setAllFriendsServers', promise)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<SearchBox @change="filterResults" />
|
<SearchBox @change="" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
@ -78,12 +78,10 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['fetchSearchResults']),
|
...mapActions(['fetchSearchResults']),
|
||||||
filterResults(query) {
|
|
||||||
this.localQuery = query;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.fetchSearchResults({query: this.query}).then((results) => {
|
this.fetchSearchResults({query: this.query}).then((results) => {
|
||||||
|
console.log(results);
|
||||||
this.search_results = results;
|
this.search_results = results;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue