Format code.

This commit is contained in:
Paul
2021-07-06 19:29:27 +01:00
parent fd23fdb206
commit fb0ae130e9
27 changed files with 188 additions and 116 deletions

View File

@@ -3,11 +3,12 @@ import { decodeTime } from "ulid";
import { Text } from "preact-i18n";
import { useDictionary } from "../../../lib/i18n";
import { dayjs } from "../../../context/Locale";
import { MessageObject } from "../../../context/revoltjs/util";
import Tooltip from "../Tooltip";
import { useDictionary } from "../../../lib/i18n";
import { dayjs } from "../../../context/Locale";
export interface BaseMessageProps {
head?: boolean;
@@ -179,7 +180,9 @@ export function MessageDetail({
<>
<time className="copyTime">
<i className="copyBracket">[</i>
{dayjs(decodeTime(message._id)).format(dict.dayjs.timeFormat)}
{dayjs(decodeTime(message._id)).format(
dict.dayjs.timeFormat,
)}
<i className="copyBracket">]</i>
</time>
<span className="edited">
@@ -194,7 +197,9 @@ export function MessageDetail({
<>
<time>
<i className="copyBracket">[</i>
{dayjs(decodeTime(message._id)).format(dict.dayjs.timeFormat)}
{dayjs(decodeTime(message._id)).format(
dict.dayjs.timeFormat,
)}
<i className="copyBracket">]</i>
</time>
</>

View File

@@ -1,4 +1,5 @@
import { Send, HappyAlt, ShieldX } from "@styled-icons/boxicons-solid";
import { Styleshare } from "@styled-icons/simple-icons";
import Axios, { CancelTokenSource } from "axios";
import { Channel } from "revolt.js";
import { ChannelPermission } from "revolt.js/dist/api/permissions";
@@ -39,7 +40,6 @@ import AutoComplete, { useAutoComplete } from "../AutoComplete";
import { PermissionTooltip } from "../Tooltip";
import FilePreview from "./bars/FilePreview";
import ReplyBar from "./bars/ReplyBar";
import { Styleshare } from "@styled-icons/simple-icons";
type Props = {
channel: Channel;
@@ -111,7 +111,7 @@ const Action = styled.div`
export const CAN_UPLOAD_AT_ONCE = 4;
export default function MessageBox({ channel }: Props) {
const [draft, setDraft] = useState(getState().drafts[channel._id] ?? '');
const [draft, setDraft] = useState(getState().drafts[channel._id] ?? "");
const [uploadState, setUploadState] = useState<UploadState>({
type: "none",
@@ -144,8 +144,8 @@ export default function MessageBox({ channel }: Props) {
}
function setMessage(content?: string) {
setDraft(content ?? '');
setDraft(content ?? "");
if (content) {
dispatch({
type: "SET_DRAFT",
@@ -475,15 +475,15 @@ export default function MessageBox({ channel }: Props) {
placeholder={
channel.channel_type === "DirectMessage"
? translate("app.main.channel.message_who", {
person: client.users.get(
client.channels.getRecipient(channel._id),
)?.username,
})
person: client.users.get(
client.channels.getRecipient(channel._id),
)?.username,
})
: channel.channel_type === "SavedMessages"
? translate("app.main.channel.message_saved")
: translate("app.main.channel.message_where", {
channel_name: channel.name,
})
channel_name: channel.name,
})
}
disabled={
uploadState.type === "uploading" ||

View File

@@ -100,14 +100,16 @@ export default function AttachmentActions({ attachment }: Props) {
<File size={24} className={styles.iconType} />
<span className={styles.filename}>{filename}</span>
<span className={styles.filesize}>{filesize}</span>
{ metadata.type === 'Text' && <a
href={open_url}
target="_blank"
className={styles.externalType}>
<IconButton>
<LinkExternal size={24} />
</IconButton>
</a> }
{metadata.type === "Text" && (
<a
href={open_url}
target="_blank"
className={styles.externalType}>
<IconButton>
<LinkExternal size={24} />
</IconButton>
</a>
)}
<a
href={download_url}
className={styles.downloadIcon}

View File

@@ -1,4 +1,5 @@
import { Reply, File } from "@styled-icons/boxicons-regular";
import { SYSTEM_USER_ID } from "revolt.js";
import styled, { css } from "styled-components";
import { Text } from "preact-i18n";
@@ -9,7 +10,6 @@ import { useUser } from "../../../../context/revoltjs/hooks";
import Markdown from "../../../markdown/Markdown";
import UserShort from "../../user/UserShort";
import { SYSTEM_USER_ID } from "revolt.js";
import { SystemMessage } from "../SystemMessage";
interface Props {
@@ -86,13 +86,14 @@ export function MessageReply({ index, channel, id }: Props) {
{message.attachments && message.attachments.length > 0 && (
<File size={16} />
)}
{ message.author === SYSTEM_USER_ID ?
<SystemMessage message={message} /> :
{message.author === SYSTEM_USER_ID ? (
<SystemMessage message={message} />
) : (
<Markdown
disallowBigEmoji
content={(message.content as string).replace(/\n/g, " ")}
/>
}
)}
</ReplyBase>
);
}

View File

@@ -31,7 +31,9 @@ export default function TextFile({ attachment }: Props) {
if (loading) return;
if (attachment.size > 20_000) {
setContent('This file is > 20 KB, for your sake I did not load it.\nSee tracking issue here for previews: https://gitlab.insrt.uk/revolt/revite/-/issues/2');
setContent(
"This file is > 20 KB, for your sake I did not load it.\nSee tracking issue here for previews: https://gitlab.insrt.uk/revolt/revite/-/issues/2",
);
return;
}

View File

@@ -4,6 +4,7 @@ import {
File,
XCircle,
} from "@styled-icons/boxicons-regular";
import { SYSTEM_USER_ID } from "revolt.js";
import styled from "styled-components";
import { Text } from "preact-i18n";
@@ -20,9 +21,8 @@ import IconButton from "../../../ui/IconButton";
import Markdown from "../../../markdown/Markdown";
import UserShort from "../../user/UserShort";
import { ReplyBase } from "../attachments/MessageReply";
import { SystemMessage } from "../SystemMessage";
import { SYSTEM_USER_ID } from "revolt.js";
import { ReplyBase } from "../attachments/MessageReply";
interface Props {
channel: string;
@@ -102,13 +102,16 @@ export default function ReplyBar({ channel, replies, setReplies }: Props) {
message.attachments.length > 0 && (
<File size={16} />
)}
{ message.author === SYSTEM_USER_ID ?
<SystemMessage message={message} /> :
{message.author === SYSTEM_USER_ID ? (
<SystemMessage message={message} />
) : (
<Markdown
disallowBigEmoji
content={(message.content as string).replace(/\n/g, " ")}
content={(
message.content as string
).replace(/\n/g, " ")}
/>
}
)}
</ReplyBase>
<span class="actions">
<IconButton

View File

@@ -233,18 +233,18 @@ export function ServerMemberSidebar({
<GenericSidebarBase>
<GenericSidebarList>
<ChannelDebugInfo id={channel._id} />
<div>
{!members && <Preloader type="ring" />}
</div>
{ members && <Category
variant="uniform"
text={
<span>
<Text id="app.main.categories.members" /> {" "}
{users.length}
</span>
}
/> }
<div>{!members && <Preloader type="ring" />}</div>
{members && (
<Category
variant="uniform"
text={
<span>
<Text id="app.main.categories.members" /> {" "}
{users.length}
</span>
}
/>
)}
{members && users.length === 0 && <img src={placeholderSVG} />}
{users.map(
(user) =>

View File

@@ -8,7 +8,8 @@ interface Props {
readonly error?: boolean;
}
export type ButtonProps = Props & Omit<JSX.HTMLAttributes<HTMLButtonElement>, 'as'>;
export type ButtonProps = Props &
Omit<JSX.HTMLAttributes<HTMLButtonElement>, "as">;
export default styled.button<Props>`
z-index: 1;
@@ -18,7 +19,7 @@ export default styled.button<Props>`
align-items: center;
justify-content: center;
padding: 2px 16px;
font-size: .875rem;
font-size: 0.875rem;
font-family: inherit;
font-weight: 500;
@@ -69,7 +70,7 @@ export default styled.button<Props>`
&:disabled {
cursor: not-allowed;
opacity: .5;
opacity: 0.5;
}
&:active {

View File

@@ -2,8 +2,8 @@ import { Check } from "@styled-icons/boxicons-regular";
import { Palette } from "@styled-icons/boxicons-solid";
import styled, { css } from "styled-components";
import { useRef } from "preact/hooks";
import { RefObject } from "preact";
import { useRef } from "preact/hooks";
interface Props {
value: string;

View File

@@ -10,7 +10,7 @@ export default styled.select`
border: none;
outline: 2px solid transparent;
transition: outline-color 0.2s ease-in-out;
transition: box-shadow .2s ease-in-out;
transition: box-shadow 0.2s ease-in-out;
cursor: pointer;
width: 100%;

View File

@@ -1,5 +1,5 @@
import styled, { css } from "styled-components";
import { dayjs } from "../../context/Locale";
const Base = styled.div<{ unread?: boolean }>`

View File

@@ -49,9 +49,11 @@ export default styled.div<Props>`
}
`}
${(props) => props.rotate && css`
svg {
transform: rotateZ(${props.rotate});
}
` }
${(props) =>
props.rotate &&
css`
svg {
transform: rotateZ(${props.rotate});
}
`}
`;

View File

@@ -18,7 +18,7 @@ export default styled.input<Props>`
border: none;
outline: 2px solid transparent;
transition: outline-color 0.2s ease-in-out;
transition: box-shadow .2s ease-in-out;
transition: box-shadow 0.2s ease-in-out;
&:hover {
background: var(--secondary-background);

View File

@@ -99,10 +99,10 @@ const ModalActions = styled.div`
background: var(--secondary-background);
`;
export type Action = Omit<ButtonProps, 'onClick'> & {
export type Action = Omit<ButtonProps, "onClick"> & {
confirmation?: boolean;
onClick: () => void;
}
};
interface Props {
children?: Children;
@@ -177,9 +177,9 @@ export default function Modal(props: Props) {
{content}
{props.actions && (
<ModalActions>
{props.actions.map((x) =>
{props.actions.map((x) => (
<Button {...x} disabled={props.disabled} />
)}
))}
</ModalActions>
)}
</ModalContainer>

View File

@@ -17,8 +17,9 @@ export default styled.textarea<TextAreaProps>`
display: block;
color: var(--foreground);
background: var(--secondary-background);
padding: ${(props) => (props.padding) ?? 'var(--textarea-padding)'};
line-height: ${(props) => (props.lineHeight) ?? 'var(--textarea-line-height)'};
padding: ${(props) => props.padding ?? "var(--textarea-padding)"};
line-height: ${(props) =>
props.lineHeight ?? "var(--textarea-line-height)"};
${(props) =>
props.hideBorder &&