fix(ios): try to accept all content types

for #477
feat/draggable-server-list
Paul Makles 2022-03-05 12:07:57 +00:00
parent 4692dda8f3
commit 3e045cf8a8
1 changed files with 37 additions and 25 deletions

View File

@ -20,33 +20,39 @@ type BehaviourType =
| { behaviour: "ask"; onChange: (file: File) => void } | { behaviour: "ask"; onChange: (file: File) => void }
| { behaviour: "upload"; onUpload: (id: string) => Promise<void> } | { behaviour: "upload"; onUpload: (id: string) => Promise<void> }
| { | {
behaviour: "multi"; behaviour: "multi";
onChange: (files: File[]) => void; onChange: (files: File[]) => void;
append?: (files: File[]) => void; append?: (files: File[]) => void;
} };
type StyleType = type StyleType =
| { | {
style: "icon" | "banner"; style: "icon" | "banner";
width?: number; width?: number;
height?: number; height?: number;
previewURL?: string; previewURL?: string;
defaultPreview?: string; defaultPreview?: string;
desaturateDefault?: boolean desaturateDefault?: boolean;
} }
| { | {
style: "attachment"; style: "attachment";
attached: boolean; attached: boolean;
uploading: boolean; uploading: boolean;
cancel: () => void; cancel: () => void;
size?: number; size?: number;
} };
type Props = BehaviourType & StyleType & { type Props = BehaviourType &
fileType: "backgrounds" | "icons" | "avatars" | "attachments" | "banners"; StyleType & {
maxFileSize: number; fileType:
remove: () => Promise<void>; | "backgrounds"
} | "icons"
| "avatars"
| "attachments"
| "banners";
maxFileSize: number;
remove: () => Promise<void>;
};
export async function uploadFile( export async function uploadFile(
autumnURL: string, autumnURL: string,
@ -75,6 +81,7 @@ export function grabFiles(
) { ) {
const input = document.createElement("input"); const input = document.createElement("input");
input.type = "file"; input.type = "file";
input.accept = "*";
input.multiple = multiple ?? false; input.multiple = multiple ?? false;
input.onchange = async (e) => { input.onchange = async (e) => {
@ -226,14 +233,19 @@ export function FileUploader(props: Props) {
})} })}
data-uploading={uploading}> data-uploading={uploading}>
<div <div
className={classNames(styles.image, props.desaturateDefault && previewURL == null && styles.desaturate)} className={classNames(
styles.image,
props.desaturateDefault &&
previewURL == null &&
styles.desaturate,
)}
style={{ style={{
backgroundImage: backgroundImage:
style === "icon" style === "icon"
? `url('${previewURL ?? defaultPreview}')` ? `url('${previewURL ?? defaultPreview}')`
: previewURL : previewURL
? `linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('${previewURL}')` ? `linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('${previewURL}')`
: "none", : "none",
width, width,
height, height,
}} }}