Skip to content

Commit

Permalink
Alert the user if they are missing information.
Browse files Browse the repository at this point in the history
  • Loading branch information
chakany committed Jan 20, 2023
1 parent 571064e commit 5035bc2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
21 changes: 21 additions & 0 deletions src/lib/ModalController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* ModalController.ts
* Copyright (c) 2023 Jack Chakany <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/

import { writable } from "svelte/store";

export const KeyModal = writable(false)
8 changes: 4 additions & 4 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -70,14 +70,14 @@
<div class="align flex" style="margin-left: auto; gap: 20px;">
<span class="align"></span>
<a class="align" href="https://github.com/jacany/nosbin"><FontAwesomeIcon size="xl" icon={faGithub} /></a>
<div on:click={() => showKeyModal = true} class="align" style="cursor: pointer;">
<div on:click={() => $KeyModal = true} class="align" style="cursor: pointer;">
<FontAwesomeIcon size="xl" icon={faUser} />
</div>
</div>
</div>
<div class="container">
{#if showKeyModal}
<Modal on:close="{() => {saveKeys(); showKeyModal = false}}">
{#if $KeyModal}
<Modal on:close="{() => {saveKeys(); $KeyModal = false}}">
<h2 slot="header">
Manage Keys
</h2>
Expand Down
13 changes: 11 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -78,7 +88,6 @@
{/if}
</div>
</div>

<Button style="margin-top: 15px" on:click={post}>Post</Button>
<small>Make sure you inputted or generated your keys before attempting to post! Click the profile icon in the top right to get started.</small>

Expand Down

1 comment on commit 5035bc2

@chakany
Copy link
Owner Author

@chakany chakany commented on 5035bc2 Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Courtesy of USER-npub1qjgcmlpkeyl8mdkvp4s0xls4ytcux6my606tgfx9xttut907h0zs76lgjw

Please sign in to comment.