mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-23 22:22:07 -05:00
Handle permissions in message box.
This commit is contained in:
parent
d090e2b573
commit
47f6404f44
4 changed files with 33 additions and 13 deletions
2
external/lang
vendored
2
external/lang
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 47182fb7112f82efa61ffe2856f25ca19c78b8c5
|
||||
Subproject commit 456777fcf68daaa3d1a5ceb6442f222cdc9e415d
|
|
@ -77,7 +77,7 @@
|
|||
"react-scroll": "^1.8.2",
|
||||
"react-tippy": "^1.4.0",
|
||||
"redux": "^4.1.0",
|
||||
"revolt.js": "4.3.2-patch.1",
|
||||
"revolt.js": "4.3.3-alpha.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"sass": "^1.35.1",
|
||||
"shade-blend-color": "^1.0.0",
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
import { ulid } from "ulid";
|
||||
import { Text } from "preact-i18n";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled from "styled-components";
|
||||
import { defer } from "../../../lib/defer";
|
||||
import IconButton from "../../ui/IconButton";
|
||||
import { Send } from '@styled-icons/feather';
|
||||
import { Send, X } from '@styled-icons/feather';
|
||||
import { debounce } from "../../../lib/debounce";
|
||||
import Axios, { CancelTokenSource } from "axios";
|
||||
import { useTranslation } from "../../../lib/i18n";
|
||||
import { Reply } from "../../../redux/reducers/queue";
|
||||
import { connectState } from "../../../redux/connector";
|
||||
import { SoundContext } from "../../../context/Settings";
|
||||
import { WithDispatcher } from "../../../redux/reducers";
|
||||
import { takeError } from "../../../context/revoltjs/util";
|
||||
import TextAreaAutoSize from "../../../lib/TextAreaAutoSize";
|
||||
import AutoComplete, { useAutoComplete } from "../AutoComplete";
|
||||
import { ChannelPermission } from "revolt.js/dist/api/permissions";
|
||||
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
||||
import { useChannelPermission } from "../../../context/revoltjs/hooks";
|
||||
import { isTouchscreenDevice } from "../../../lib/isTouchscreenDevice";
|
||||
import { internalEmit, internalSubscribe } from "../../../lib/eventEmitter";
|
||||
import { useCallback, useContext, useEffect, useState } from "preact/hooks";
|
||||
|
@ -22,8 +27,6 @@ import { SingletonMessageRenderer, SMOOTH_SCROLL_ON_RECEIVE } from "../../../lib
|
|||
|
||||
import ReplyBar from "./bars/ReplyBar";
|
||||
import FilePreview from './bars/FilePreview';
|
||||
import AutoComplete, { useAutoComplete } from "../AutoComplete";
|
||||
import { SoundContext } from "../../../context/Settings";
|
||||
|
||||
type Props = WithDispatcher & {
|
||||
channel: Channel;
|
||||
|
@ -48,6 +51,14 @@ const Base = styled.div`
|
|||
}
|
||||
`;
|
||||
|
||||
const Blocked = styled.div`
|
||||
padding: 15px 0;
|
||||
line-height: 20px;
|
||||
user-select: none;
|
||||
font-size: .875rem;
|
||||
color: var(--tertiary-foreground);
|
||||
`;
|
||||
|
||||
const Action = styled.div`
|
||||
display: grid;
|
||||
place-items: center;
|
||||
|
@ -65,6 +76,15 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
|||
const client = useContext(AppContext);
|
||||
const translate = useTranslation();
|
||||
|
||||
const permissions = useChannelPermission(channel._id);
|
||||
if (!(permissions & ChannelPermission.SendMessage)) {
|
||||
return (
|
||||
<Base>
|
||||
<Blocked><Text id="app.main.channel.misc.no_sending" /></Blocked>
|
||||
</Base>
|
||||
)
|
||||
}
|
||||
|
||||
function setMessage(content?: string) {
|
||||
if (content) {
|
||||
dispatcher({
|
||||
|
@ -272,7 +292,7 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
|||
}} />
|
||||
<ReplyBar channel={channel._id} replies={replies} setReplies={setReplies} />
|
||||
<Base>
|
||||
<Action>
|
||||
{ (permissions & ChannelPermission.UploadFiles) ? <Action>
|
||||
<FileUploader
|
||||
size={24}
|
||||
behaviour='multi'
|
||||
|
@ -296,7 +316,7 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
|||
}
|
||||
}}
|
||||
/>
|
||||
</Action>
|
||||
</Action> : undefined }
|
||||
<TextAreaAutoSize
|
||||
autoFocus
|
||||
hideBorder
|
||||
|
@ -338,11 +358,11 @@ function MessageBox({ channel, draft, dispatcher }: Props) {
|
|||
}}
|
||||
onFocus={onFocus}
|
||||
onBlur={onBlur} />
|
||||
<Action>
|
||||
{ isTouchscreenDevice && <Action>
|
||||
<IconButton onClick={send}>
|
||||
<Send size={20} />
|
||||
</IconButton>
|
||||
</Action>
|
||||
</Action> }
|
||||
</Base>
|
||||
</>
|
||||
)
|
||||
|
|
|
@ -3412,10 +3412,10 @@ reusify@^1.0.4:
|
|||
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
|
||||
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
|
||||
|
||||
revolt.js@4.3.2-patch.1:
|
||||
version "4.3.2-patch.1"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-4.3.2-patch.1.tgz#0c4190f0a640951636c6f2577c9298418b06917f"
|
||||
integrity sha512-XAu2JeYc2+OFLM56WktGT/4tAyvjibmNL5oGc5pPZEjl0DnoIxPE96CZPe+35ZCX9bEiuoX378Fwfmfe3uN7sw==
|
||||
revolt.js@4.3.3-alpha.1:
|
||||
version "4.3.3-alpha.1"
|
||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-4.3.3-alpha.1.tgz#b60a18e5cbe9f2c569e7f46974450931826e10d4"
|
||||
integrity sha512-MxjTOWqg83cLYdpuqLCl3nOTD+jFxSSjrnvczuijam1YjeZ3IB27C6G4Qar3BwMn7B+zH8MgEDecW3YBmKBpIw==
|
||||
dependencies:
|
||||
"@insertish/mutable" "1.1.0"
|
||||
axios "^0.19.2"
|
||||
|
|
Loading…
Reference in a new issue