Fix: Remove padding on user profile.

Modals: Allow all modals to be closed by ESC (permitting).
Fix: Handle closing DMs properly. Stop propagation too.
This commit is contained in:
Paul
2021-06-24 16:57:12 +01:00
parent 3393795817
commit acadd8ab17
7 changed files with 27 additions and 22 deletions

View File

@@ -22,17 +22,6 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
if (attachment && attachment.metadata.type !== "Image") return null;
const client = useContext(AppContext);
useEffect(() => {
function keyDown(e: KeyboardEvent) {
if (e.key === "Escape") {
onClose();
}
}
document.body.addEventListener("keydown", keyDown);
return () => document.body.removeEventListener("keydown", keyDown);
}, []);
return (
<Modal visible={true} onClose={onClose} noBackground>
<div className={styles.viewer}>

View File

@@ -116,12 +116,11 @@ export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
const badges = (user.badges ?? 0) | (decodeTime(user._id) < 1623751765790 ? Badges.EarlyAdopter : 0);
return (
<Modal
visible
<Modal visible
border={dummy}
padding={false}
onClose={onClose}
dontModal={dummy}
>
dontModal={dummy}>
<div
className={styles.header}
data-force={

View File

@@ -19,7 +19,6 @@ export function useForceUpdate(context?: HookContext): HookContext {
updateState = u;
} else {
console.warn('Failed to construct using useState.');
console.warn(H);
updateState = ()=>{};
}
@@ -85,7 +84,7 @@ export function useDMs(context?: HookContext) {
function mutation(target: string) {
let channel = ctx.client.channels.get(target);
if (channel) {
if ((channel.channel_type === 'DirectMessage' && channel.active) || channel.channel_type === 'Group') {
if (channel.channel_type === 'DirectMessage' || channel.channel_type === 'Group') {
ctx.forceUpdate();
}
}
@@ -99,7 +98,7 @@ export function useDMs(context?: HookContext) {
return map
.toArray()
.filter(x => (x.channel_type === 'DirectMessage' && x.active) || x.channel_type === 'Group' || x.channel_type === 'SavedMessages') as (Channels.GroupChannel | Channels.DirectMessageChannel | Channels.SavedMessagesChannel)[];
.filter(x => x.channel_type === 'DirectMessage' || x.channel_type === 'Group' || x.channel_type === 'SavedMessages') as (Channels.GroupChannel | Channels.DirectMessageChannel | Channels.SavedMessagesChannel)[];
}
export function useUserPermission(id: string, context?: HookContext) {