diff --git a/frontend/src/AppContext.ts b/frontend/src/AppContext.ts
index 136b146..112ad18 100644
--- a/frontend/src/AppContext.ts
+++ b/frontend/src/AppContext.ts
@@ -6,6 +6,7 @@ export interface IAppContext {
popPasteCloned: () => PasteClone | undefined
pushPasteCreated: (paste: PasteView) => void
popPasteCreated: () => PasteView | undefined
+ pushPasteDeleted: (paste: PasteView) => void
onPasteCreated: (callback: (paste: PasteView) => void) => void
onPasteDeleted: (callback: (paste: PasteView) => void) => void
}
diff --git a/frontend/src/components/CreatePaste/CreatePaste.tsx b/frontend/src/components/CreatePaste/CreatePaste.tsx
index 805a59e..ca9a058 100644
--- a/frontend/src/components/CreatePaste/CreatePaste.tsx
+++ b/frontend/src/components/CreatePaste/CreatePaste.tsx
@@ -20,7 +20,7 @@ type FormModel = {
content: string
expiry?: 'ONE_HOUR' | 'ONE_DAY' | 'ONE_WEEK' | 'ONE_MONTH' | 'THREE_MONTHS' | 'ONE_YEAR' | 'NEVER'
exposure?: 'PUBLIC' | 'UNLISTED' | 'ONCE'
- password: string
+ password?: string
}
const CreatePaste: Component = ({onCreatePaste, initialPaste}): JSX.Element => {
@@ -28,9 +28,9 @@ const CreatePaste: Component = ({onCreatePaste, initialPaste})
const [form, setForm] = createStore({
title: initialPaste?.title || null,
content: initialPaste?.content || null,
- password: null,
expiry: null,
- exposure: null
+ exposure: null,
+ password: null,
});
const [lastPasteUrl, setLastPasteUrl] = createSignal();
@@ -51,7 +51,7 @@ const CreatePaste: Component = ({onCreatePaste, initialPaste})
}
const resetStore = () => {
- setLastPasteUrl(null);
+ setLastPasteUrl();
setForm({
title: null,
password: null,
diff --git a/frontend/src/components/ReadPaste/ReadPaste.tsx b/frontend/src/components/ReadPaste/ReadPaste.tsx
index 0af2036..63ef371 100644
--- a/frontend/src/components/ReadPaste/ReadPaste.tsx
+++ b/frontend/src/components/ReadPaste/ReadPaste.tsx
@@ -1,4 +1,4 @@
-import {Component, createEffect, createSignal, JSX, lazy, on, Show} from 'solid-js';
+import {Component, createEffect, createSignal, JSX, on, Show} from 'solid-js';
import linkifyElement from 'linkify-element';
import {PasteView} from '../../api/model/PasteView';
import {decrypt} from '../../crypto/CryptoUtil';
diff --git a/frontend/src/components/SearchPastes/SearchPastes.tsx b/frontend/src/components/SearchPastes/SearchPastes.tsx
index 56c6c11..4d4bec4 100644
--- a/frontend/src/components/SearchPastes/SearchPastes.tsx
+++ b/frontend/src/components/SearchPastes/SearchPastes.tsx
@@ -1,39 +1,19 @@
-import {Component, createResource, createSignal, JSX, Show} from 'solid-js';
+import {Component, JSX, Show} from 'solid-js';
import {A} from '@solidjs/router';
-import ApiClient from '../../api/client';
import {PasteSearchView} from '../../api/model/PasteSearchView';
import {toDateTimeString} from '../../datetime/DateTimeUtil';
import styles from "./searchPastes.module.css";
type SearchPastesProps = {
term: String
- pastes: PasteSearchView
+ pastes: Array
onSearchEnter: (term: String) => void
}
const SearchPastes: Component = ({term, pastes, onSearchEnter}): JSX.Element => {
- const [search, setSearch] = createSignal();
-
- const [results, { refetch }] = createResource(() => search(), () => searchTerm());
-
let searchInput: HTMLInputElement;
-
- const searchTerm = (): Promise> => {
- if (search() && search().length >= 3) {
- return ApiClient.searchAll(search());
- }
-
- return Promise.resolve([]);
- }
-
- const resetSearchForm = () => {
- setSearch(null);
- refetch();
- }
-
-
const submitOnClick = (e: Event) => {
e.preventDefault();
if (searchInput.value?.length >= 3) {
@@ -55,7 +35,7 @@ const SearchPastes: Component = ({term, pastes, onSearchEnter
<>
}>
-
+
{item =>
-
{item.title || 'Untitled' }
@@ -81,7 +61,6 @@ const SearchPastes: Component = ({term, pastes, onSearchEnter
-
>
)
}
diff --git a/frontend/src/pages/Search.tsx b/frontend/src/pages/Search.tsx
index f2fd9f6..8e4156a 100644
--- a/frontend/src/pages/Search.tsx
+++ b/frontend/src/pages/Search.tsx
@@ -1,26 +1,23 @@
import {JSX, createResource, Switch, Match} from 'solid-js';
-import {A, useLocation, useSearchParams} from '@solidjs/router';
+import {useSearchParams} from '@solidjs/router';
import ApiClient from '../api/client';
-import {toDateTimeString} from '../datetime/DateTimeUtil';
import SearchPastes from '../components/SearchPastes/SearchPastes';
import Spinner from '../components/Spinner/Spinner';
const Search: () => JSX.Element = () => {
- const location = useLocation();
-
- const [searchTerm, setSearchTerm] = useSearchParams();
-
- const effectiveTerm = () => {
- return (searchTerm.q && searchTerm.q.length >= 3) ? searchTerm.q : null;
- }
+ const [searchTerm, setSearchTerm] = useSearchParams<{q: string}>();
const [pastes] = createResource(
effectiveTerm,
(term) => ApiClient.searchAll(term),
- {initialValue: []}
+ { initialValue: [] }
);
+ function effectiveTerm(): string | null {
+ return (searchTerm.q && searchTerm.q.length >= 3) ? searchTerm.q : null;
+ }
+
function onSearchEnter(term: String) {
setSearchTerm({q: term})
}