From 5035bc26748cdf7f306dcf8923065c7fbf3ddf38 Mon Sep 17 00:00:00 2001 From: Jack Chakany Date: Fri, 20 Jan 2023 00:42:01 -0500 Subject: [PATCH] Alert the user if they are missing information. --- src/lib/ModalController.ts | 21 +++++++++++++++++++++ src/routes/+layout.svelte | 8 ++++---- src/routes/+page.svelte | 13 +++++++++++-- 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/lib/ModalController.ts diff --git a/src/lib/ModalController.ts b/src/lib/ModalController.ts new file mode 100644 index 0000000..4c3425e --- /dev/null +++ b/src/lib/ModalController.ts @@ -0,0 +1,21 @@ +/* + * ModalController.ts + * Copyright (c) 2023 Jack Chakany + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { writable } from "svelte/store"; + +export const KeyModal = writable(false) \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 00d7547..afb4d0c 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -20,7 +20,7 @@ import Textbox from "$lib/Textbox.svelte"; import Button from "$lib/Button.svelte"; import Modal from "$lib/Modal.svelte" - let showKeyModal = false; + import { KeyModal } from "$lib/ModalController"; export const ssr = false; import "@fontsource/montserrat"; @@ -70,14 +70,14 @@
-
showKeyModal = true} class="align" style="cursor: pointer;"> +
$KeyModal = true} class="align" style="cursor: pointer;">
- {#if showKeyModal} - + {#if $KeyModal} +

Manage Keys

diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 036a7ad..4632b18 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -24,6 +24,7 @@ import { HighlightAuto, LineNumbers } from "svelte-highlight"; import SvelteMarkdown from "svelte-markdown"; import github from "svelte-highlight/styles/github-dark"; + import { KeyModal } from "$lib/ModalController"; let content; let filename; @@ -32,7 +33,16 @@ $: relay = $nostrInstance.relay.url async function post() { - if ($nostrInstance.pubkey === "" || !content || !filename) return; + if (!filename) { + alert("You must add a filename!"); + return; + } else if (!content) { + alert("You must add content to post!"); + return; + } else if ($nostrInstance.pubkey === "") { + $KeyModal = true; + return; + } const id = await $nostrInstance.postFile(filename, content) console.log(id) if (id) { @@ -78,7 +88,6 @@ {/if}
- Make sure you inputted or generated your keys before attempting to post! Click the profile icon in the top right to get started.