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 b724b9aec2
commit 2d9d3c489c
7 changed files with 27 additions and 22 deletions

View File

@@ -12,6 +12,7 @@ import { attachContextMenu } from 'preact-context-menu';
import { Channels, Users } from "revolt.js/dist/api/objects";
import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice";
import { useIntermediate } from '../../../context/intermediate/Intermediate';
import { stopPropagation } from '../../../lib/stopPropagation';
interface CommonProps {
active?: boolean
@@ -70,9 +71,8 @@ export function UserButton({ active, alert, alertCount, user, context, channel }
)}
{alert && <div className={styles.alert} data-style={alert}>{ alertCount }</div>}
{ !isTouchscreenDevice && channel &&
<IconButton
className={styles.icon}
onClick={() => openScreen({ id: 'special_prompt', type: 'close_dm', target: channel })}>
<IconButton className={styles.icon}
onClick={e => stopPropagation(e) && openScreen({ id: 'special_prompt', type: 'close_dm', target: channel })}>
<X size={24} />
</IconButton>
}

View File

@@ -117,8 +117,11 @@ function HomeSidebar(props: Props) {
{channelsArr.map(x => {
let user;
if (x.channel_type === 'DirectMessage') {
if (!x.active) return null;
let recipient = client.channels.getRecipient(x._id);
user = users.find(x => x?._id === recipient);
if (!user) {
console.warn(`Skipped DM ${x._id} because user was missing.`);
return null;