mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-06-18 14:01:12 +00:00
added block functionality.
This commit is contained in:
parent
ffc29b1ee0
commit
183353d2e2
4 changed files with 86 additions and 16 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,15 @@
|
|||
<div class="material-icons">person_add_disabled</div>
|
||||
<div>Remove Friend</div>
|
||||
</div>
|
||||
<div class="button warn">
|
||||
<div
|
||||
class="button warn"
|
||||
v-if="isBlocked"
|
||||
@click="unblockFriendButton"
|
||||
>
|
||||
<div class="material-icons">block</div>
|
||||
<div>Unblock</div>
|
||||
</div>
|
||||
<div class="button warn" v-else @click="blockFriendButton">
|
||||
<div class="material-icons">block</div>
|
||||
<div>Block</div>
|
||||
</div>
|
||||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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 } })
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue