Skip to content

Commit 4b54372

Browse files
committed
blocking functionality
1 parent b48bdde commit 4b54372

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

frontend/src/components/app/users/UserProfile.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<h1 v-if="!reported" v-on:click="makeReport()" class="onboarding-sub-container-content-button-outline mx-auto">Report</h1>
7474
<h1 v-else class="onboarding-sub-container-content-button-outline cursor-default text-green-500 border-green-500 mx-auto">Thank you</h1>
7575
</div>
76-
<div v-if="user.blocks.length === 0 && blocked === false" class="text-center p-8">
76+
<div v-if="blocked === false" class="text-center p-8">
7777
<h1 v-on:click="block()"
7878
class="onboarding-sub-container-content-button-outline text-red-500 mt-0 border-red-500 mx-auto">Block</h1>
7979
<h1 class="mx-auto mt-2 text-sm text-gray-600">Don't suggest this user and stop notifications</h1>
@@ -184,10 +184,14 @@ export default {
184184
async block() {
185185
await this.$http.post(`/profile/block/${this.user.id}`);
186186
this.blocked = true;
187+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
188+
await this.$store.dispatch('login', user.data);
187189
},
188190
async unblock() {
189191
await this.$http.post(`/profile/unblock/${this.user.id}`);
190192
this.blocked = false;
193+
const user = await this.$http.get(`/users/${this.$store.getters.getLoggedInUser.id}`);
194+
await this.$store.dispatch('login', user.data);
191195
},
192196
checkIfUserIsLiked() {
193197
const likes = this.$store.getters.getLoggedInUser.likes.sent;
@@ -202,9 +206,19 @@ export default {
202206
}
203207
}
204208
},
209+
checkIfUserIsBlocked() {
210+
const { blocks } = this.$store.getters.getLoggedInUser;
211+
for (let i = 0; i < blocks.length; i += 1) {
212+
if (blocks[i].blocked_id === this.user.id) {
213+
this.blocked = true;
214+
return;
215+
}
216+
}
217+
},
205218
},
206219
async beforeMount() {
207220
this.checkIfUserIsLiked();
221+
this.checkIfUserIsBlocked();
208222
const sliderRangesRequest = await this.$http.get('/search/values');
209223
const maxScore = sliderRangesRequest.data.search_minmax.max_score;
210224
const sliderScore = document.getElementById('sliderScore');

0 commit comments

Comments
 (0)