This commit is contained in:
j3d1 2023-05-31 22:30:23 +02:00
parent 5c6d560680
commit cecc03a820
3 changed files with 49 additions and 34 deletions

View file

@ -245,11 +245,27 @@ class ServerSetUnion {
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) {
try {
return await this.serverSets.reduce(async (acc, serverset) => {
return await serverset.post(auth, target, data)
}, Promise.resolve())
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.post(auth, target, data))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}
@ -257,29 +273,12 @@ class ServerSetUnion {
async patch(auth, target, data) {
try {
return await this.serverSets.reduce(async (acc, serverset) => {
return await serverset.patch(auth, target, data)
}, Promise.resolve())
} catch (e) {
throw new Error('all servers failed')
}
}
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())
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
return acc.concat(await serverset.patch(auth, target, data))
})
}, Promise.resolve([]))
return ret
} catch (e) {
throw new Error('all servers failed')
}
@ -287,9 +286,25 @@ class ServerSetUnion {
async put(auth, target, data) {
try {
return await this.serverSets.reduce(async (acc, serverset) => {
return await serverset.put(auth, target, data)
}, Promise.resolve())
const ret = await this.serverSets.reduce(async (acc, serverset) => {
return acc.then(async (acc) => {
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) {
throw new Error('all servers failed')
}

View file

@ -127,7 +127,7 @@ export default createStore({
if (domain === 'localhost')
return ['127.0.0.1:8000'];
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')
return ['10.23.42.128:8000'];
if (domain === 'example2.com')
@ -156,6 +156,8 @@ export default createStore({
const s = await dispatch('lookupServer', {username: friend.username})
servers.add(new ServerSet(s, state.unreachable_neighbors))
}
const home = await dispatch('getHomeServers')
servers.add(home)
return servers
})()
commit('setAllFriendsServers', promise)

View file

@ -6,7 +6,7 @@
<div class="row">
<div class="col-md-3">
<div class="card">
<SearchBox @change="filterResults" />
<SearchBox @change="" />
</div>
</div>
<div class="col-12">
@ -78,12 +78,10 @@ export default {
},
methods: {
...mapActions(['fetchSearchResults']),
filterResults(query) {
this.localQuery = query;
}
},
async mounted() {
this.fetchSearchResults({query: this.query}).then((results) => {
console.log(results);
this.search_results = results;
});
}