mirror of
https://github.com/danbulant/Nertivia-Client
synced 2026-07-03 18:10:34 +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);
|
const tempID = this.generateNum(25);
|
||||||
|
|
||||||
this.$store.dispatch("addMessage", {
|
const addMessage = {
|
||||||
sender: true,
|
sender: true,
|
||||||
channelID: this.selectedChannelID,
|
channelID: this.selectedChannelID,
|
||||||
message: {
|
message: {
|
||||||
|
|
@ -323,13 +323,14 @@ export default {
|
||||||
channelID: this.selectedChannelID,
|
channelID: this.selectedChannelID,
|
||||||
created: new Date()
|
created: new Date()
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
this.$store.dispatch("addMessage", addMessage);
|
||||||
|
|
||||||
this.message = "";
|
this.message = "";
|
||||||
|
|
||||||
let input = this.$refs["input-box"];
|
let input = this.$refs["input-box"];
|
||||||
input.style.height = "1em";
|
input.style.height = "1em";
|
||||||
|
|
||||||
this.$store.dispatch("updateChannelLastMessage", this.selectedChannelID);
|
this.$store.dispatch("updateChannelLastMessage", this.selectedChannelID);
|
||||||
const { ok, error, result } = await messagesService.post(
|
const { ok, error, result } = await messagesService.post(
|
||||||
this.selectedChannelID,
|
this.selectedChannelID,
|
||||||
|
|
@ -349,7 +350,37 @@ export default {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO: Error handling
|
// 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() {
|
async updateMessage() {
|
||||||
|
|
@ -732,9 +763,9 @@ export default {
|
||||||
this.message = this.message.replace(/<@([\d]+)>/g, test => {
|
this.message = this.message.replace(/<@([\d]+)>/g, test => {
|
||||||
const ID = test.slice(2, test.length - 1);
|
const ID = test.slice(2, test.length - 1);
|
||||||
const member = this.members[ID];
|
const member = this.members[ID];
|
||||||
if (!member) return test
|
if (!member) return test;
|
||||||
return `@${member.username}:${member.tag}`
|
return `@${member.username}:${member.tag}`;
|
||||||
})
|
});
|
||||||
if (editMessage) this.customColor = editMessage.color || null;
|
if (editMessage) this.customColor = editMessage.color || null;
|
||||||
},
|
},
|
||||||
onBlur() {
|
onBlur() {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,15 @@
|
||||||
<div class="material-icons">person_add_disabled</div>
|
<div class="material-icons">person_add_disabled</div>
|
||||||
<div>Remove Friend</div>
|
<div>Remove Friend</div>
|
||||||
</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 class="material-icons">block</div>
|
||||||
<div>Block</div>
|
<div>Block</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -135,7 +143,8 @@ export default {
|
||||||
surveyItems: Object.assign({}, surveyItems),
|
surveyItems: Object.assign({}, surveyItems),
|
||||||
user: null,
|
user: null,
|
||||||
avatarDomain: config.domain + "/avatars/",
|
avatarDomain: config.domain + "/avatars/",
|
||||||
badges
|
badges,
|
||||||
|
isBlocked: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -156,6 +165,18 @@ export default {
|
||||||
async AcceptFriendButton() {
|
async AcceptFriendButton() {
|
||||||
await relationshipService.put(this.uniqueID);
|
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() {
|
async RemoveFriendButton() {
|
||||||
await relationshipService.delete(this.uniqueID);
|
await relationshipService.delete(this.uniqueID);
|
||||||
},
|
},
|
||||||
|
|
@ -183,6 +204,7 @@ export default {
|
||||||
const { ok, result } = await userService.get(this.uniqueID);
|
const { ok, result } = await userService.get(this.uniqueID);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
this.user = result.data.user;
|
this.user = result.data.user;
|
||||||
|
this.isBlocked = result.data.isBlocked;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,32 @@
|
||||||
import { instance, wrapper } from "./Api";
|
import { instance, wrapper } from "./Api";
|
||||||
|
|
||||||
const config = require('../config.js');
|
const config = require("../config.js");
|
||||||
|
|
||||||
let domain = "";
|
let domain = "";
|
||||||
if (config.serverURL) domain = config.serverURL+"/"
|
if (config.serverURL) domain = config.serverURL + "/";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
get(uniqueID) {
|
get(uniqueID) {
|
||||||
return wrapper(instance().get(domain+`user/${uniqueID}`));
|
return wrapper(instance().get(domain + `user/${uniqueID}`));
|
||||||
},
|
},
|
||||||
update(data) {
|
update(data) {
|
||||||
return wrapper(instance().patch(domain+`user`, data));
|
return wrapper(instance().patch(domain + `user`, data));
|
||||||
},
|
},
|
||||||
getSurvey() {
|
getSurvey() {
|
||||||
return wrapper(instance().get(domain+"/user/survey"));
|
return wrapper(instance().get(domain + "/user/survey"));
|
||||||
},
|
},
|
||||||
setSurvey(data) {
|
setSurvey(data) {
|
||||||
return wrapper(instance().put(domain+"/user/survey", data));
|
return wrapper(instance().put(domain + "/user/survey", data));
|
||||||
},
|
},
|
||||||
skipSurvey() {
|
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 = [
|
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",
|
version: "1.0.3",
|
||||||
title: "Delete confirmation",
|
title: "Delete confirmation",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue