ConversationView: Improve types
This commit is contained in:
parent
c765d3202c
commit
dcf29078f4
21 changed files with 1101 additions and 941 deletions
|
@ -73,28 +73,55 @@ export type DownloadedAttachmentType = AttachmentType & {
|
|||
data: ArrayBuffer;
|
||||
};
|
||||
|
||||
type BaseAttachmentDraftType = {
|
||||
export type BaseAttachmentDraftType = {
|
||||
blurHash?: string;
|
||||
contentType: MIME.MIMEType;
|
||||
fileName: string;
|
||||
path: string;
|
||||
screenshotContentType?: string;
|
||||
screenshotSize?: number;
|
||||
size: number;
|
||||
};
|
||||
|
||||
export type InMemoryAttachmentDraftType = {
|
||||
data?: ArrayBuffer;
|
||||
screenshotData?: ArrayBuffer;
|
||||
} & BaseAttachmentDraftType;
|
||||
export type InMemoryAttachmentDraftType =
|
||||
| ({
|
||||
data?: ArrayBuffer;
|
||||
pending: false;
|
||||
screenshotData?: ArrayBuffer;
|
||||
} & BaseAttachmentDraftType)
|
||||
| {
|
||||
contentType: MIME.MIMEType;
|
||||
fileName: string;
|
||||
path: string;
|
||||
pending: true;
|
||||
};
|
||||
|
||||
export type OnDiskAttachmentDraftType = {
|
||||
path?: string;
|
||||
screenshotPath?: string;
|
||||
} & BaseAttachmentDraftType;
|
||||
export type OnDiskAttachmentDraftType =
|
||||
| ({
|
||||
caption?: string;
|
||||
pending: false;
|
||||
screenshotPath?: string;
|
||||
} & BaseAttachmentDraftType)
|
||||
| {
|
||||
contentType: MIME.MIMEType;
|
||||
fileName: string;
|
||||
path: string;
|
||||
pending: true;
|
||||
};
|
||||
|
||||
export type AttachmentDraftType = {
|
||||
url: string;
|
||||
} & BaseAttachmentDraftType;
|
||||
export type AttachmentDraftType =
|
||||
| ({
|
||||
url: string;
|
||||
screenshotPath?: string;
|
||||
caption?: string;
|
||||
pending: false;
|
||||
} & BaseAttachmentDraftType)
|
||||
| {
|
||||
contentType: MIME.MIMEType;
|
||||
fileName: string;
|
||||
path: string;
|
||||
pending: true;
|
||||
};
|
||||
|
||||
export type ThumbnailType = {
|
||||
height: number;
|
||||
|
|
|
@ -69,9 +69,13 @@ export function findLinks(text: string, caretLocation?: number): Array<string> {
|
|||
);
|
||||
}
|
||||
|
||||
export function getDomain(href: string): string | undefined {
|
||||
export function getDomain(href: string): string {
|
||||
const url = maybeParseUrl(href);
|
||||
return url ? url.hostname : undefined;
|
||||
if (!url || !url.hostname) {
|
||||
throw new Error('getDomain: Unable to extract hostname from href');
|
||||
}
|
||||
|
||||
return url.hostname;
|
||||
}
|
||||
|
||||
// See <https://tools.ietf.org/html/rfc3986>.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue