Skip to content

Commit

Permalink
problem: can't publish air replies
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed May 28, 2024
1 parent 7a5303d commit 6791cc1
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 27 deletions.
87 changes: 64 additions & 23 deletions src/lib/components/MessageInput.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
<script lang="js">
import { GhostSolid } from "svelte-awesome-icons";
import Button from "./Button.svelte";
<script lang="ts">
import { GhostSolid } from 'svelte-awesome-icons';
import Button from './Button.svelte';
import { currentUser, ndk } from '@/ndk/ndk';
import { NDKEvent, type NDKTag } from '@nostr-dev-kit/ndk';
import { Textarea } from './ui/textarea';
export let selected = true
export let selected = true;
export let content = '';
export let tags: NDKTag[] = [];
export let horsenote = false;
function publish(c: string) {
if (c.length < 1) {alert("invalid note length")}
console.log(15, c)
if (!$currentUser) {
alert('could not find your event signer');
throw new Error('invalid user');
} else {
let e = new NDKEvent($ndk);
e.kind = 1;
e.created_at = Math.floor(new Date().getTime() / 1000);
e.content = c + (horsenote ? '\nPublished with humble.horse 🐎🐎🐎' : '');
e.tags = tags;
e.author = $currentUser;
console.log(e)
e.publish().then((r) => {
console.log(r);
console.log(e);
});
}
}
</script>
<div class="flex items-center h-16 focus-within:h-36 w-full px-3 py-2 bg-zinc-300 dark:bg-cyan-900 ">

<div class="flex items-center h-16 focus-within:h-36 w-full px-3 py-2 bg-zinc-300 dark:bg-cyan-900">
<div class="">
<button
type="button"
Expand Down Expand Up @@ -60,27 +88,40 @@ export let selected = true
<span class="sr-only">Add emoji</span>
</button>
</div>
<textarea on:blur={()=>{}} on:click={()=>{selected=true}}
<Textarea
on:blur={() => {}}
on:click={() => {
selected = true;
}}
id="chat"
rows="1"
class="resize-none block mx-4 p-2.5 w-full h-full text-sm text-gray-900 bg-white rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Start typing..."
></textarea>
bind:value={content}
></Textarea>
<div class="flex flex-col">
<Button onClick={()=>{alert("ghost mode: implement me!")}}><GhostSolid /></Button>
<Button onClick={()=>{alert("could not find your signer, or something is broken")}}>
<svg
class="w-5 h-5 rotate-90 rtl:-rotate-90"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 18 20"
<Button
onClick={() => {
alert('ghost mode: implement me!');
}}><GhostSolid /></Button
>
<path
d="m17.914 18.594-8-18a1 1 0 0 0-1.828 0l-8 18a1 1 0 0 0 1.157 1.376L8 18.281V9a1 1 0 0 1 2 0v9.281l6.758 1.689a1 1 0 0 0 1.156-1.376Z"
/>
</svg>
<span class="sr-only">Send message</span>
</Button>
</div>
<Button
onClick={() => {
//console.log(content)
publish(content);
}}
>
<svg
class="w-5 h-5 rotate-90 rtl:-rotate-90"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 18 20"
>
<path
d="m17.914 18.594-8-18a1 1 0 0 0-1.828 0l-8 18a1 1 0 0 0 1.157 1.376L8 18.281V9a1 1 0 0 1 2 0v9.281l6.758 1.689a1 1 0 0 0 1.156-1.376Z"
/>
</svg>
<span class="sr-only">Send message</span>
</Button>
</div>
</div>
10 changes: 6 additions & 4 deletions src/lib/views/messages/Messages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
import MessageInput from '@/components/MessageInput.svelte';
import Input from '@/components/ui/input/input.svelte';
import { currentUser, ndk } from '@/ndk/ndk';
import { PushEvent, UpdatePubkey, FrontendDataStore as feds, viewed } from '@/snort_workers/main';
import { PushEvent, FrontendDataStore as feds, viewed } from '@/snort_workers/main';
import { updateRepliesInPlace } from '@/snort_workers/utils';
import { stableShortList, threadParentID, threadParentIDChain } from '@/stores/shortlist';
import { NDKEvent } from '@nostr-dev-kit/ndk';
import NDKSvelte from '@nostr-dev-kit/ndk-svelte';
import { RequestBuilder, type QueryLike } from '@snort/system';
import { BloomFilter } from 'bloomfilter';
import type { NostrEvent } from 'nostr-tools';
import { ArrowTurnUpSolid } from 'svelte-awesome-icons';
import { onMount } from 'svelte';
import { ArrowTurnUpSolid } from 'svelte-awesome-icons';
import { derived, writable } from 'svelte/store';
import RenderKind1 from './RenderKind1.svelte';
import RenderKind1AsThreadHead from './RenderKind1AsThreadHead.svelte';
import { System } from './snort';
import NDKSvelte from '@nostr-dev-kit/ndk-svelte';
let messageInputContent = ""
let localEvents = writable(new Map<string, NostrEvent>());
Expand Down Expand Up @@ -220,7 +222,7 @@
<Coracle />
{/if}
</slot>
<div slot="input" class="w-full content-end"><MessageInput /></div>
<div slot="input" class="w-full content-end"><MessageInput horsenote bind:content={messageInputContent} /></div>
<div slot="right">
<div class=" ml-2">
<h3>HUMBLE HORSE</h3>
Expand Down

0 comments on commit 6791cc1

Please sign in to comment.