From c14762e20bd05b152cf9fcb32e28f2807bdbe992 Mon Sep 17 00:00:00 2001 From: jedi Date: Sun, 14 May 2023 00:55:57 +0200 Subject: [PATCH] stash --- frontend/src/store.js | 10 +++++ frontend/src/views/Friends.vue | 73 ++++++++++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/frontend/src/store.js b/frontend/src/store.js index d14b2f5..2faa2aa 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -203,6 +203,16 @@ export default createStore({ }) console.log('ext_reply', ext_reply) return true; + }, + async acceptFriend({state, dispatch}, args) { + console.log('accepting friend ' + args) + }, + async declineFriend({state, dispatch}, args) { + console.log('declining friend ' + args) + }, + async fetchFriendRequests({state, dispatch}) { + const requests = await dispatch('apiLocalGet', {target: '/api/friendrequests/'}) + return requests } }, getters: { diff --git a/frontend/src/views/Friends.vue b/frontend/src/views/Friends.vue index 6bd72a7..1a0c5b1 100644 --- a/frontend/src/views/Friends.vue +++ b/frontend/src/views/Friends.vue @@ -13,10 +13,10 @@ - + -
NameName Server - + + Refresh @@ -55,6 +55,45 @@
+
+
+
+
Requests
+
Bar baz.
+
+ + + + + + + + + + + + + + + +
NameKey + + + Refresh + +
{{ request.befriender }} + {{ request.befriender_public_key.slice(0,32) }}... +   + +
+
+
@@ -76,7 +115,8 @@ export default { return { friends: {}, show_newfriend: false, - newfriend: "" + newfriend: "", + requests: [] } }, computed: { @@ -93,8 +133,8 @@ export default { } }, methods: { - ...mapActions(['getFriends', "getFriendServer", "requestFriend"]), - fetchFriends() { + ...mapActions(['getFriends', "getFriendServer", "requestFriend", "acceptFriend", "fetchFriendRequests", "declineFriend"]), + fetchContent() { this.getFriends().then((friends) => { friends.map((friend) => { this.getFriendServer({username: friend}).then((server) => { @@ -102,6 +142,9 @@ export default { }) }) }) + this.fetchFriendRequests().then((requests) => { + this.requests = requests + }) }, showNewFriend() { this.show_newfriend = true @@ -111,13 +154,27 @@ export default { if (ok) { this.show_newfriend = false this.newfriend = "" - this.fetchFriends() + this.fetchContent() + } + }).catch(() => {}) + }, + tryAcceptFriend(friend) { + this.acceptFriend({username: friend}).then((ok) => { + if (ok) { + this.fetchContent() + } + }).catch(() => {}) + }, + tryRejectFriend(friend) { + this.declineFriend({username: friend}).then((ok) => { + if (ok) { + this.fetchContent() } }).catch(() => {}) } }, mounted() { - this.fetchFriends() + this.fetchContent() } }