merge: branch 'master' into production

This commit is contained in:
Paul Makles 2022-07-15 21:51:24 +01:00
commit 176c7883c8
7 changed files with 102 additions and 43 deletions

2
external/lang vendored

@ -1 +1 @@
Subproject commit 5af7326c286f729ac6dd4cabff9dfdf7c480b631 Subproject commit 58a9fb697de00f570d445be4d12e3ce4a5e3522e

View file

@ -141,7 +141,7 @@
"remark-math": "^5.1.1", "remark-math": "^5.1.1",
"remark-parse": "^10.0.1", "remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0", "remark-rehype": "^10.1.0",
"revolt.js": "^6.0.6", "revolt.js": "6.0.9",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sass": "^1.35.1", "sass": "^1.35.1",
"semver": "^7.3.7", "semver": "^7.3.7",

View file

@ -9,6 +9,7 @@ import {
EditAlt, EditAlt,
Edit, Edit,
MessageSquareEdit, MessageSquareEdit,
Key,
} from "@styled-icons/boxicons-solid"; } from "@styled-icons/boxicons-solid";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Message, API } from "revolt.js"; import { Message, API } from "revolt.js";
@ -18,6 +19,7 @@ import { useTriggerEvents } from "preact-context-menu";
import { TextReact } from "../../../lib/i18n"; import { TextReact } from "../../../lib/i18n";
import Markdown from "../../markdown/Markdown";
import UserShort from "../user/UserShort"; import UserShort from "../user/UserShort";
import MessageBase, { MessageDetail, MessageInfo } from "./MessageBase"; import MessageBase, { MessageDetail, MessageInfo } from "./MessageBase";
@ -67,12 +69,15 @@ const iconDictionary = {
channel_renamed: EditAlt, channel_renamed: EditAlt,
channel_description_changed: Edit, channel_description_changed: Edit,
channel_icon_changed: MessageSquareEdit, channel_icon_changed: MessageSquareEdit,
channel_ownership_changed: Key,
text: InfoCircle, text: InfoCircle,
}; };
export const SystemMessage = observer( export const SystemMessage = observer(
({ attachContext, message, highlight, hideInfo }: Props) => { ({ attachContext, message, highlight, hideInfo }: Props) => {
const data = message.asSystemMessage; const data = message.asSystemMessage;
if (!data) return null;
const SystemMessageIcon = const SystemMessageIcon =
iconDictionary[data.type as API.SystemMessage["type"]] ?? iconDictionary[data.type as API.SystemMessage["type"]] ??
InfoCircle; InfoCircle;
@ -130,6 +135,22 @@ export const SystemMessage = observer(
/> />
); );
break; break;
case "channel_ownership_changed":
children = (
<TextReact
id={`app.main.channel.system.channel_ownership_changed`}
fields={{
from: <UserShort user={data.from} />,
to: <UserShort user={data.to} />,
}}
/>
);
break;
case "text":
if (message.system?.type === "text") {
children = <Markdown content={message.system?.content} />;
}
break;
} }
return ( return (

View file

@ -26,7 +26,10 @@ const BotBadge = styled.div`
border-radius: calc(var(--border-radius) / 2); border-radius: calc(var(--border-radius) / 2);
`; `;
type UsernameProps = JSX.HTMLAttributes<HTMLElement> & { type UsernameProps = Omit<
JSX.HTMLAttributes<HTMLElement>,
"children" | "as"
> & {
user?: User; user?: User;
prefixAt?: boolean; prefixAt?: boolean;
masquerade?: API.Masquerade; masquerade?: API.Masquerade;
@ -35,6 +38,13 @@ type UsernameProps = JSX.HTMLAttributes<HTMLElement> & {
innerRef?: Ref<any>; innerRef?: Ref<any>;
}; };
const Name = styled.span<{ colour?: string | null }>`
background: ${(props) => props.colour ?? "var(--foreground)"};
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
`;
export const Username = observer( export const Username = observer(
({ ({
user, user,
@ -45,7 +55,7 @@ export const Username = observer(
...otherProps ...otherProps
}: UsernameProps) => { }: UsernameProps) => {
let username = user?.username; let username = user?.username;
let color; let color = masquerade?.colour;
if (user && showServerIdentity) { if (user && showServerIdentity) {
const { server } = useParams<{ server?: string }>(); const { server } = useParams<{ server?: string }>();
@ -65,15 +75,10 @@ export const Username = observer(
} }
} }
if (member.roles && member.roles.length > 0) { if (!color) {
const srv = client.servers.get(member._id.server); for (const [_, { colour }] of member.orderedRoles) {
if (srv?.roles) { if (colour) {
for (const role of member.roles) { color = colour;
const c = srv.roles[role]?.colour;
if (c) {
color = c;
continue;
}
} }
} }
} }
@ -81,14 +86,19 @@ export const Username = observer(
} }
} }
if (user?.bot) { const el = (
return ( <Name {...otherProps} ref={innerRef} colour={color}>
<> {prefixAt ? "@" : undefined}
<span {...otherProps} ref={innerRef} style={{ color }}>
{masquerade?.name ?? username ?? ( {masquerade?.name ?? username ?? (
<Text id="app.main.channel.unknown_user" /> <Text id="app.main.channel.unknown_user" />
)} )}
</span> </Name>
);
if (user?.bot) {
return (
<>
{el}
<BotBadge> <BotBadge>
{masquerade ? ( {masquerade ? (
<Text id="app.main.channel.bridge" /> <Text id="app.main.channel.bridge" />
@ -100,14 +110,7 @@ export const Username = observer(
); );
} }
return ( return el;
<span {...otherProps} ref={innerRef} style={{ color }}>
{prefixAt ? "@" : undefined}
{masquerade?.name ?? username ?? (
<Text id="app.main.channel.unknown_user" />
)}
</span>
);
}, },
); );

View file

@ -23,6 +23,11 @@ const List = styled.div`
span { span {
user-select: text; user-select: text;
} }
i {
opacity: 0;
position: absolute;
}
`; `;
/** /**
@ -73,8 +78,10 @@ export default function MFARecovery({
onClose={onClose} onClose={onClose}
signal={signal}> signal={signal}>
<List> <List>
{known.map((code) => ( {known.map((code, index) => (
<span key={code}>{code}</span> <span key={code}>
{code} {index !== known.length && <i>{","}</i>}
</span>
))} ))}
</List> </List>
</Modal> </Modal>

View file

@ -69,6 +69,7 @@ type Action =
| { action: "copy_file_link"; attachment: API.File } | { action: "copy_file_link"; attachment: API.File }
| { action: "open_link"; link: string } | { action: "open_link"; link: string }
| { action: "copy_link"; link: string } | { action: "copy_link"; link: string }
| { action: "make_owner"; channel: Channel; user: User }
| { action: "remove_member"; channel: Channel; user: User } | { action: "remove_member"; channel: Channel; user: User }
| { action: "kick_member"; target: Member } | { action: "kick_member"; target: Member }
| { action: "ban_member"; target: Member } | { action: "ban_member"; target: Member }
@ -307,6 +308,15 @@ export default function ContextMenus() {
} }
break; break;
case "make_owner":
{
// FIXME: add a modal for this
data.channel.edit({
owner: data.user._id,
});
}
break;
case "remove_member": case "remove_member":
{ {
data.channel.removeMember(data.user._id); data.channel.removeMember(data.user._id);
@ -667,11 +677,29 @@ export default function ContextMenus() {
contextualChannel.owner_id === userId && contextualChannel.owner_id === userId &&
userId !== uid userId !== uid
) { ) {
generateAction({ generateAction(
{
action: "make_owner",
channel: contextualChannel,
user: user!,
},
undefined,
false,
undefined,
"var(--error)",
);
generateAction(
{
action: "remove_member", action: "remove_member",
channel: contextualChannel, channel: contextualChannel,
user: user!, user: user!,
}); },
undefined,
false,
undefined,
"var(--error)",
);
} }
} }

View file

@ -3696,7 +3696,7 @@ __metadata:
remark-math: ^5.1.1 remark-math: ^5.1.1
remark-parse: ^10.0.1 remark-parse: ^10.0.1
remark-rehype: ^10.1.0 remark-rehype: ^10.1.0
revolt.js: ^6.0.6 revolt.js: 6.0.9
rimraf: ^3.0.2 rimraf: ^3.0.2
sass: ^1.35.1 sass: ^1.35.1
semver: ^7.3.7 semver: ^7.3.7
@ -7879,20 +7879,20 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"revolt-api@npm:0.5.4": "revolt-api@npm:0.5.5":
version: 0.5.4 version: 0.5.5
resolution: "revolt-api@npm:0.5.4" resolution: "revolt-api@npm:0.5.5"
dependencies: dependencies:
"@insertish/oapi": 0.1.16 "@insertish/oapi": 0.1.16
axios: ^0.26.1 axios: ^0.26.1
lodash.defaultsdeep: ^4.6.1 lodash.defaultsdeep: ^4.6.1
checksum: bd40acabac1b6c5848b1d6e555297de5aa3e0950a4de67523c4cf986a8037380e3addc5e16babebc8dfa6570cd1d1957efe9a3aaa6a206b9286e5b7f5941d699 checksum: 38fa78e3f731a8753916da58347ac930ff911f7a45d67f9d3e55bdaf56be5eb11c8568803209a76d9a40e6d5faa4a5adfc80aa6377528df499080f5e3b75cd2d
languageName: node languageName: node
linkType: hard linkType: hard
"revolt.js@npm:^6.0.6": "revolt.js@npm:6.0.9":
version: 6.0.6 version: 6.0.9
resolution: "revolt.js@npm:6.0.6" resolution: "revolt.js@npm:6.0.9"
dependencies: dependencies:
"@insertish/exponential-backoff": 3.1.0-patch.2 "@insertish/exponential-backoff": 3.1.0-patch.2
"@insertish/isomorphic-ws": ^4.0.1 "@insertish/isomorphic-ws": ^4.0.1
@ -7903,10 +7903,10 @@ __metadata:
lodash.isequal: ^4.5.0 lodash.isequal: ^4.5.0
long: ^5.2.0 long: ^5.2.0
mobx: ^6.3.2 mobx: ^6.3.2
revolt-api: 0.5.4 revolt-api: 0.5.5
ulid: ^2.3.0 ulid: ^2.3.0
ws: ^8.2.2 ws: ^8.2.2
checksum: 079bdb983c650233378a617b771d7ff64396ce96fbd822fea20e9897fa14c2e589869e4a66f749dc74ce08218af425f97ab42fcaca7a3ab0f68f38f163484260 checksum: a3ea924a6793f6a4aa5f62e660b249bd76bbe2f0048d9b374a449f064ee6d65df1b8e4e3af1d15267707ea6d35b6a3101349b0bf41fa323cb5c298ab98de8d45
languageName: node languageName: node
linkType: hard linkType: hard