diff --git a/src/components/app/MessagePanel.vue b/src/components/app/MessagePanel.vue
index 690ce9d..647146e 100644
--- a/src/components/app/MessagePanel.vue
+++ b/src/components/app/MessagePanel.vue
@@ -313,7 +313,7 @@ export default {
const tempID = this.generateNum(25);
- this.$store.dispatch("addMessage", {
+ const addMessage = {
sender: true,
channelID: this.selectedChannelID,
message: {
@@ -323,13 +323,14 @@ export default {
channelID: this.selectedChannelID,
created: new Date()
}
- });
+ };
+
+ this.$store.dispatch("addMessage", addMessage);
this.message = "";
let input = this.$refs["input-box"];
input.style.height = "1em";
-
this.$store.dispatch("updateChannelLastMessage", this.selectedChannelID);
const { ok, error, result } = await messagesService.post(
this.selectedChannelID,
@@ -349,7 +350,37 @@ export default {
});
} else {
// TODO: Error handling
- console.log(error);
+
+ this.$store.dispatch("replaceMessage", {
+ tempID: tempID,
+ message: { ...addMessage.message, status: 2, messageID: "0111" }
+ });
+ let message;
+
+ if (
+ error.response &&
+ error.response.data &&
+ error.response.data.message
+ ) {
+ message = error.response.data.message;
+ } else {
+ message = "Something went wrong while sending the message.";
+ }
+ this.$store.dispatch("addMessage", {
+ channelID: this.selectedChannelID,
+ message: {
+ creator: {
+ username: "Whoopsies!",
+ uniqueID: "12345678",
+ avatar: "default.png"
+ },
+ message: message,
+ messageID: Math.floor(Math.random() * 10999 + 0).toString(),
+ color: "#ff4d4d",
+ channelID: this.selectedChannelID,
+ created: new Date()
+ }
+ });
}
},
async updateMessage() {
@@ -732,9 +763,9 @@ export default {
this.message = this.message.replace(/<@([\d]+)>/g, test => {
const ID = test.slice(2, test.length - 1);
const member = this.members[ID];
- if (!member) return test
- return `@${member.username}:${member.tag}`
- })
+ if (!member) return test;
+ return `@${member.username}:${member.tag}`;
+ });
if (editMessage) this.customColor = editMessage.color || null;
},
onBlur() {
diff --git a/src/components/app/Popouts/Popouts/userInformationPopout.vue b/src/components/app/Popouts/Popouts/userInformationPopout.vue
index 3a2f58e..90032e3 100644
--- a/src/components/app/Popouts/Popouts/userInformationPopout.vue
+++ b/src/components/app/Popouts/Popouts/userInformationPopout.vue
@@ -57,7 +57,15 @@
person_add_disabled
Remove Friend
-
+
+
@@ -135,7 +143,8 @@ export default {
surveyItems: Object.assign({}, surveyItems),
user: null,
avatarDomain: config.domain + "/avatars/",
- badges
+ badges,
+ isBlocked: null
};
},
methods: {
@@ -156,6 +165,18 @@ export default {
async AcceptFriendButton() {
await relationshipService.put(this.uniqueID);
},
+ async blockFriendButton() {
+ const { ok } = await userService.block(this.uniqueID);
+ if (ok) {
+ this.isBlocked = true;
+ }
+ },
+ async unblockFriendButton() {
+ const { ok } = await userService.unblock(this.uniqueID);
+ if (ok) {
+ this.isBlocked = false;
+ }
+ },
async RemoveFriendButton() {
await relationshipService.delete(this.uniqueID);
},
@@ -183,6 +204,7 @@ export default {
const { ok, result } = await userService.get(this.uniqueID);
if (ok) {
this.user = result.data.user;
+ this.isBlocked = result.data.isBlocked;
}
},
computed: {
diff --git a/src/services/userService.js b/src/services/userService.js
index 34db851..68624f3 100644
--- a/src/services/userService.js
+++ b/src/services/userService.js
@@ -1,24 +1,32 @@
import { instance, wrapper } from "./Api";
-const config = require('../config.js');
+const config = require("../config.js");
let domain = "";
-if (config.serverURL) domain = config.serverURL+"/"
+if (config.serverURL) domain = config.serverURL + "/";
export default {
get(uniqueID) {
- return wrapper(instance().get(domain+`user/${uniqueID}`));
+ return wrapper(instance().get(domain + `user/${uniqueID}`));
},
update(data) {
- return wrapper(instance().patch(domain+`user`, data));
+ return wrapper(instance().patch(domain + `user`, data));
},
getSurvey() {
- return wrapper(instance().get(domain+"/user/survey"));
+ return wrapper(instance().get(domain + "/user/survey"));
},
setSurvey(data) {
- return wrapper(instance().put(domain+"/user/survey", data));
+ return wrapper(instance().put(domain + "/user/survey", data));
},
skipSurvey() {
- return wrapper(instance().delete(domain+"/user/survey/skip"));
+ return wrapper(instance().delete(domain + "/user/survey/skip"));
+ },
+ block(uniqueID) {
+ return wrapper(instance().post(domain + "/user/block", { uniqueID }));
+ },
+ unblock(uniqueID) {
+ return wrapper(
+ instance().delete(domain + "/user/block", { data: { uniqueID } })
+ );
}
};
diff --git a/src/utils/changelog.js b/src/utils/changelog.js
index 2a902e5..d50d108 100644
--- a/src/utils/changelog.js
+++ b/src/utils/changelog.js
@@ -1,4 +1,13 @@
const config = [
+ {
+ version: "1.0.4",
+ title: '"Stop DMing me!"',
+ shortTitle: "",
+ date: "27/02/2020",
+ new: [
+ "Got annoying people messaging you? Fear no more, The block button now works and blocks users."
+ ]
+ },
{
version: "1.0.3",
title: "Delete confirmation",