From 3a9593adec2c56c93cc6bd0abef7f8255d6ce292 Mon Sep 17 00:00:00 2001 From: querwurzel <> Date: Tue, 7 Nov 2023 20:12:46 +0100 Subject: [PATCH] lazy load linkify on Read --- frontend/src/api/model/PasteCreateCmd.ts | 2 +- frontend/src/api/model/PasteListView.ts | 4 ++-- frontend/src/api/model/PasteView.ts | 2 +- frontend/src/components/CreatePaste/CreatePaste.tsx | 10 +++++++--- frontend/src/components/Footer/Footer.tsx | 1 - frontend/src/components/Header/Header.tsx | 1 - frontend/src/components/ReadPaste/ReadPaste.tsx | 7 ++++--- frontend/src/pages/404.tsx | 1 - frontend/src/pages/Search.tsx | 1 - 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/frontend/src/api/model/PasteCreateCmd.ts b/frontend/src/api/model/PasteCreateCmd.ts index b3e7ee7..6cadbd2 100644 --- a/frontend/src/api/model/PasteCreateCmd.ts +++ b/frontend/src/api/model/PasteCreateCmd.ts @@ -1,5 +1,5 @@ -export interface PasteCreateCmd { +export type PasteCreateCmd = { title?: string content: string isEncrypted?: boolean diff --git a/frontend/src/api/model/PasteListView.ts b/frontend/src/api/model/PasteListView.ts index b52a8cc..4ef1f6c 100644 --- a/frontend/src/api/model/PasteListView.ts +++ b/frontend/src/api/model/PasteListView.ts @@ -1,5 +1,5 @@ -export interface PasteListView { +export type PasteListView = { id: string title?: string sizeInBytes: number @@ -8,6 +8,6 @@ export interface PasteListView { dateOfExpiry?: string } -export interface PasteList { +export type = PasteList { pastes: Array } diff --git a/frontend/src/api/model/PasteView.ts b/frontend/src/api/model/PasteView.ts index eca5d45..0705723 100644 --- a/frontend/src/api/model/PasteView.ts +++ b/frontend/src/api/model/PasteView.ts @@ -1,5 +1,5 @@ -export interface PasteView { +export type PasteView = { id: string title?: string content: string diff --git a/frontend/src/components/CreatePaste/CreatePaste.tsx b/frontend/src/components/CreatePaste/CreatePaste.tsx index 56e44ed..a238e76 100644 --- a/frontend/src/components/CreatePaste/CreatePaste.tsx +++ b/frontend/src/components/CreatePaste/CreatePaste.tsx @@ -5,17 +5,21 @@ import {encrypt} from "../../crypto/CryptoUtil"; import {Copy} from '../../assets/Vectors'; import styles from "./createPaste.module.css"; -export interface PasteClone { +export type PasteClone = { title?: string content: string } -interface CreatePasteProps { +type CreatePasteProps = { onCreatePaste: (paste: PasteCreateCmd) => Promise initialPaste?: PasteClone } -interface FormModel extends Omit { +type FormModel = { + title?: string + content: string + expiry?: 'ONE_HOUR' | 'ONE_DAY' | 'ONE_WEEK' | 'ONE_MONTH' | 'THREE_MONTHS' | 'ONE_YEAR' | 'NEVER' + exposure?: 'PUBLIC' | 'UNLISTED' | 'ONCE' password: string } diff --git a/frontend/src/components/Footer/Footer.tsx b/frontend/src/components/Footer/Footer.tsx index 7dba624..289164c 100644 --- a/frontend/src/components/Footer/Footer.tsx +++ b/frontend/src/components/Footer/Footer.tsx @@ -1,7 +1,6 @@ import {JSX} from 'solid-js'; const Footer: () => JSX.Element = () => { - return (
© 2023 diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header/Header.tsx index 8379691..9db47f9 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -2,7 +2,6 @@ import {A} from '@solidjs/router'; import {JSX} from 'solid-js'; const Header: () => JSX.Element = () => { - return (

BinPastes

diff --git a/frontend/src/components/ReadPaste/ReadPaste.tsx b/frontend/src/components/ReadPaste/ReadPaste.tsx index fc1cea7..7a443df 100644 --- a/frontend/src/components/ReadPaste/ReadPaste.tsx +++ b/frontend/src/components/ReadPaste/ReadPaste.tsx @@ -1,12 +1,13 @@ -import linkifyElement from 'linkify-element'; -import {Component, createEffect, createSignal, JSX, on, Show} from 'solid-js'; +import {Component, createEffect, createSignal, JSX, lazy, on, Show} from 'solid-js'; import {PasteView} from '../../api/model/PasteView'; import {decrypt} from '../../crypto/CryptoUtil'; import {relativeDiffLabel, toDateString, toDateTimeString} from '../../datetime/DateTimeUtil'; import {Lock, Unlock, Key, Trash, Copy} from '../../assets/Vectors'; import styles from './readPaste.module.css'; -interface ReadPasteProps { +const linkifyElement = lazy(() => import('linkify-element')); + +type ReadPasteProps = { paste: PasteView onClonePaste: () => void onDeletePaste: () => void diff --git a/frontend/src/pages/404.tsx b/frontend/src/pages/404.tsx index 64d74ce..3165ff6 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -2,7 +2,6 @@ import {A} from '@solidjs/router'; import {JSX} from 'solid-js'; const NotFound: () => JSX.Element = () => { - return (

404 Nothing around here :(

diff --git a/frontend/src/pages/Search.tsx b/frontend/src/pages/Search.tsx index 069d1e9..860a2b1 100644 --- a/frontend/src/pages/Search.tsx +++ b/frontend/src/pages/Search.tsx @@ -1,7 +1,6 @@ import {JSX} from 'solid-js'; const Search: () => JSX.Element = () => { - return ( <>

Search