Format code.

This commit is contained in:
Paul
2021-07-06 19:29:27 +01:00
parent 1fcf4df1ed
commit 67d3fb35a4
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