1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2025-01-30 17:15:16 +01:00

Merge pull request #5138 from h3poteto/pixelfed/validation

Validate attachments when sns is pixelfed
This commit is contained in:
AkiraFukushima 2025-01-08 00:32:33 +09:00 committed by GitHub
commit e7b10e0e73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 9 deletions

View File

@ -145,7 +145,8 @@
"alert": {
"validation": {
"attachment_type": "You can attach only images or videos",
"attachment_length": "You can't attach over {limit} files"
"attachment_length": "You can't attach over {limit} files",
"attachment_required": "Please attache images or videos"
},
"upload_error": "Failed to upload the file",
"compose": {

View File

@ -33,10 +33,12 @@ import {
Switch,
Textarea
} from '@material-tailwind/react'
import { Account } from '@/db'
type Props = {
client: MegalodonInterface
in_reply_to?: Entity.Status
account: Account
}
type Poll = {
@ -102,7 +104,11 @@ export default function Compose(props: Props) {
}, [maxCharacters, body, spoiler])
const post = async () => {
if (body.length === 0) return
if (props.account.sns !== 'pixelfed' && body.length === 0) return
if (props.account.sns === 'pixelfed' && attachments.length === 0) {
showToast({ text: formatMessage({ id: 'alert.validation.attachment_required' }), type: 'failure' })
return
}
let options = { visibility: visibility }
if (props.in_reply_to) {
options = Object.assign({}, options, {

View File

@ -64,7 +64,7 @@ export default function Reply(props: Props) {
)}
/>
<div ref={composeRef}>
<Compose client={props.client} in_reply_to={status} />
<Compose client={props.client} in_reply_to={status} account={props.account} />
</div>
</div>
)

View File

@ -278,10 +278,13 @@ export default function Timeline(props: Props) {
<section className={`h-full ${timelineClass()}`}>
<div className="w-full theme-bg theme-text-primary p-2 flex justify-between">
<div className="text-lg font-bold cursor-pointer" onClick={() => backToTop()}>
{
props.timeline.match(/list_(\d+)/) ? <>{list && list.title}</> :
(props.timeline.match(/tag_(\w+)/) ? <>{tag && `# ${tag.name}`}</> :
<FormattedMessage id={`timeline.${props.timeline}`} />)}
{props.timeline.match(/list_(\d+)/) ? (
<>{list && list.title}</>
) : props.timeline.match(/tag_(\w+)/) ? (
<>{tag && `# ${tag.name}`}</>
) : (
<FormattedMessage id={`timeline.${props.timeline}`} />
)}
</div>
<div className="w-64 text-xs">
<form onSubmit={ev => search(ev)}>
@ -326,7 +329,7 @@ export default function Timeline(props: Props) {
)}
<div ref={composeRef}>
<Compose client={props.client} />
<Compose client={props.client} account={props.account} />
</div>
</div>
</section>

View File

@ -11,7 +11,7 @@ export type Account = {
refresh_token: string | null
url: string
domain: string
sns: 'mastodon' | 'pleroma' | 'friendica' | 'firefish'
sns: 'mastodon' | 'pleroma' | 'friendica' | 'firefish' | 'pixelfed'
}
export class SubClassedDexie extends Dexie {