Fix and prettier incoming changes from PR #119.

Cherry pick PR #130: don't show add friend button on banned / deleted accounts.
Also account for this in context menu.
This commit is contained in:
Paul 2021-09-03 10:43:48 +01:00
parent a08ad7aa0b
commit a1cb72046c
3 changed files with 34 additions and 14 deletions

View file

@ -196,6 +196,8 @@ export const UserProfile = observer(
</IconButton> </IconButton>
)} )}
{!user.bot && {!user.bot &&
flags != 2 &&
flags != 4 &&
(user.relationship === (user.relationship ===
RelationshipStatus.Incoming || RelationshipStatus.Incoming ||
user.relationship === user.relationship ===
@ -315,10 +317,14 @@ export const UserProfile = observer(
content={ content={
<Text id="app.special.popovers.user_profile.badges.translator" /> <Text id="app.special.popovers.user_profile.badges.translator" />
}> }>
<img src="/assets/badges/translator.svg" <img
onClick={() => { src="/assets/badges/translator.svg"
window.open("https://weblate.insrt.uk/projects/revolt/web-app/", "_blank") onClick={() => {
}} window.open(
"https://weblate.insrt.uk/projects/revolt/web-app/",
"_blank",
);
}}
/> />
</Tooltip> </Tooltip>
) : ( ) : (
@ -343,7 +349,10 @@ export const UserProfile = observer(
size={32} size={32}
color="#efab44" color="#efab44"
onClick={() => { onClick={() => {
window.open("https://insrt.uk/donate", "_blank") window.open(
"https://insrt.uk/donate",
"_blank",
);
}} }}
/> />
</Tooltip> </Tooltip>

View file

@ -619,7 +619,14 @@ function ContextMenus(props: Props) {
break; break;
case RelationshipStatus.None: case RelationshipStatus.None:
default: default:
actions = ["add_friend", "block_user"]; if (
(user.flags && 2) ||
(user.flags && 4)
) {
actions = ["block_user"];
} else {
actions = ["add_friend", "block_user"];
}
} }
if (userPermissions & UserPermission.ViewProfile) { if (userPermissions & UserPermission.ViewProfile) {

View file

@ -1,8 +1,12 @@
import { Form } from "./Form";
import { detect } from "detect-browser"; import { detect } from "detect-browser";
import { useHistory } from "react-router-dom";
import { useContext } from "preact/hooks"; import { useContext } from "preact/hooks";
import { OperationsContext } from "../../../context/revoltjs/RevoltClient"; import { OperationsContext } from "../../../context/revoltjs/RevoltClient";
import { Form } from "./Form";
export function FormLogin() { export function FormLogin() {
const { login } = useContext(OperationsContext); const { login } = useContext(OperationsContext);
const history = useHistory(); const history = useHistory();
@ -10,7 +14,7 @@ export function FormLogin() {
return ( return (
<Form <Form
page="login" page="login"
callback={async data => { callback={async (data) => {
const browser = detect(); const browser = detect();
let device_name; let device_name;
if (browser) { if (browser) {
@ -19,12 +23,12 @@ export function FormLogin() {
if (window.isNative) { if (window.isNative) {
device_name = `Revolt Desktop on ${os}`; device_name = `Revolt Desktop on ${os}`;
} else { } else {
if(name === "ios") { if (name === "ios") {
name = "safari"; name = "safari";
}else if(name === "fxios") { } else if (name === "fxios") {
name = "firefox"; name = "firefox";
} }
device_name = `${name} on ${os}`; device_name = `${name} on ${os}`;
} }
} else { } else {
device_name = "Unknown Device"; device_name = "Unknown Device";