msg: Fix report confirmation
parent
a46eb557e3
commit
2d99547b85
|
@ -200,7 +200,7 @@ final class Report(
|
||||||
env.user.repo named data.username flatMap {
|
env.user.repo named data.username flatMap {
|
||||||
_ ?? { user =>
|
_ ?? { user =>
|
||||||
if (user == me) BadRequest.fuccess
|
if (user == me) BadRequest.fuccess
|
||||||
else api.commFlag(Reporter(me), Suspect(user), data.resource, data.text) inject Ok
|
else api.commFlag(Reporter(me), Suspect(user), data.resource, data.text) inject jsonOkResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -57,16 +57,4 @@ object form {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def flag(username: String, resource: String, text: String) =
|
|
||||||
postForm(action := routes.Report.flag, cls := "comm-flag")(
|
|
||||||
form3.hidden("username", username),
|
|
||||||
form3.hidden("resource", resource),
|
|
||||||
form3.hidden("text", text take 140),
|
|
||||||
submitButton(
|
|
||||||
cls := "button button-empty button-red confirm",
|
|
||||||
dataIcon := "",
|
|
||||||
title := "Report spam or offensive language"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,11 +177,18 @@ export default class MsgCtrl {
|
||||||
report = () => {
|
report = () => {
|
||||||
const user = this.data.convo?.user;
|
const user = this.data.convo?.user;
|
||||||
if (user) {
|
if (user) {
|
||||||
const text = this.data.convo?.msgs.find(m => m.user != this.data.me.id)?.text.slice(0, 140);
|
const text = this.reportableMsg()?.text.slice(0, 140);
|
||||||
if (text) network.report(user.name, text).then(_ => alert('Your report has been sent.'));
|
if (text)
|
||||||
|
network
|
||||||
|
.report(user.name, text)
|
||||||
|
.then(_ => alert('Your report has been sent.'))
|
||||||
|
.catch(err => alert('Failed to send report: ' + err));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reportableMsg = (): Msg | undefined =>
|
||||||
|
this.data.convo?.msgs.find(m => m.user != this.data.me.id && m.text.length > 2);
|
||||||
|
|
||||||
block = () => {
|
block = () => {
|
||||||
const userId = this.data.convo?.user.id;
|
const userId = this.data.convo?.user.id;
|
||||||
if (userId) network.block(userId).then(() => this.openConvo(userId));
|
if (userId) network.block(userId).then(() => this.openConvo(userId));
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default function renderActions(ctrl: MsgCtrl, convo: Convo): VNode[] {
|
||||||
hook: bind('click', withConfirm(ctrl.delete)),
|
hook: bind('click', withConfirm(ctrl.delete)),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (convo.msgs[0])
|
if (ctrl.reportableMsg())
|
||||||
nodes.push(
|
nodes.push(
|
||||||
h(`button.${cls}.bad`, {
|
h(`button.${cls}.bad`, {
|
||||||
key: 'report',
|
key: 'report',
|
||||||
|
|
Loading…
Reference in New Issue