Skip to content

Commit dc67aa5

Browse files
committed
solve glitch user chatting with itself
1 parent ab6e6e9 commit dc67aa5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

frontend/src/views/app/Matches.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,19 @@ export default {
8989
const { matches } = matchesRequest.data;
9090
for (let i = 0; i < matches.length; i += 1) {
9191
if (!this.messages.length) {
92-
const userRequest = await this.$http.get(`/users/${matches[i].user_1}`);
93-
this.matches.push(userRequest.data);
92+
if (this.$store.getters.getLoggedInUser.id === matches[i].user_1) {
93+
const userRequest = await this.$http.get(`/users/${matches[i].user_2}`);
94+
this.matches.push(userRequest.data);
95+
} else {
96+
const userRequest = await this.$http.get(`/users/${matches[i].user_1}`);
97+
this.matches.push(userRequest.data);
98+
}
9499
} else {
95100
for (let j = 0; j < this.messages.length; j += 1) {
96-
if (this.messages[j][0].to_id !== matches[i].user_1) {
101+
if (this.$store.getters.getLoggedInUser.id === matches[i].user_1) {
102+
const userRequest = await this.$http.get(`/users/${matches[i].user_2}`);
103+
this.matches.push(userRequest.data);
104+
} else {
97105
const userRequest = await this.$http.get(`/users/${matches[i].user_1}`);
98106
this.matches.push(userRequest.data);
99107
}

0 commit comments

Comments
 (0)