-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b491f76
commit 2dfd8ee
Showing
10 changed files
with
204 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
<script lang="ts"> | ||
import { goto } from '$app/navigation'; | ||
import { base } from '$app/paths'; | ||
import LoginButton from '@/components/LoginButton.svelte'; | ||
import { Button } from '@/components/ui/button'; | ||
import { Input } from '@/components/ui/input'; | ||
import { Init } from '@/workers/firehose_master'; | ||
import { ModeWatcher, toggleMode } from 'mode-watcher'; | ||
import { Home, QuestionMark } from 'radix-icons-svelte'; | ||
import { ModeWatcher } from 'mode-watcher'; | ||
import { onMount } from 'svelte'; | ||
import { ArrowTurnUpSolid } from 'svelte-awesome-icons'; | ||
import Moon from 'svelte-radix/Moon.svelte'; | ||
import Sun from 'svelte-radix/Sun.svelte'; | ||
import '../app.css'; | ||
import { page } from '$app/stores'; | ||
onMount(() => { | ||
Init(); | ||
}); | ||
</script> | ||
|
||
<ModeWatcher /> | ||
<slot /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,7 @@ | ||
<script lang="ts"> | ||
import ChatLayout from '@/components/ChatLayout.svelte'; | ||
import Kind1 from '@/components/Kind1.svelte'; | ||
import { Button } from '@/components/ui/button'; | ||
import { EventTreeItem, type RecursiveEventMap } from '@/workers/firehose.types'; | ||
import { responseFromWorker } from '@/workers/firehose_master'; | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { ArrowTurnUpSolid } from 'svelte-awesome-icons'; | ||
import { derived, writable, type Writable } from 'svelte/store'; | ||
onMount(() => {}); | ||
onDestroy(() => {}); | ||
function find(m: RecursiveEventMap, id: string): EventTreeItem | undefined { | ||
if (m.get(id)) { | ||
return m.get(id)!; | ||
} | ||
for (let [_, item] of m) { | ||
let c = find(item.children, id); | ||
if (c) { | ||
return c; | ||
} | ||
} | ||
} | ||
//todo: if the last parentFromUsersHistory is included in the current threadParent's tags, go to that when user navigates UP. If not, go to the e-tag that 1) we have and 2) has the most replies. | ||
let threadParentID = writable(["root"]); | ||
function pop() { | ||
threadParentID.update(existing=>{ | ||
existing.pop() | ||
return existing | ||
}) | ||
} | ||
let rThreadParent = derived([responseFromWorker, threadParentID], ([$rfw, $threadParentID]) => { | ||
if ($threadParentID[$threadParentID.length-1] == 'root') { | ||
return $rfw.recursiveEvents; | ||
} else { | ||
return find($rfw.recursiveEvents.children, $threadParentID[$threadParentID.length-1]); | ||
} | ||
}); | ||
</script> | ||
|
||
<ChatLayout> | ||
<div slot="buttons"> | ||
{#if $threadParentID[$threadParentID.length-1] != "root"} | ||
<Button on:click={pop} variant="outline" size="icon" class="-scale-x-100 hover:skew-y-12" | ||
><ArrowTurnUpSolid /></Button | ||
> | ||
{/if} | ||
</div> | ||
<slot> | ||
|
||
{#if $rThreadParent} | ||
{$rThreadParent.children.size} <br /> | ||
<Kind1 | ||
treeItem={$rThreadParent || $responseFromWorker.recursiveEvents} | ||
bind:newParent={threadParentID} | ||
/> | ||
{/if} | ||
</slot> | ||
</ChatLayout> | ||
import { goto } from "$app/navigation"; | ||
import { base } from "$app/paths"; | ||
import { onMount } from "svelte"; | ||
onMount(()=>{goto(`${base}/messages`)}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script lang="ts"> | ||
import ChatLayout from '@/components/ChatLayout.svelte'; | ||
import Kind1 from './Kind1.svelte'; | ||
import { Button } from '@/components/ui/button'; | ||
import { EventTreeItem, type RecursiveEventMap } from '@/workers/firehose.types'; | ||
import { responseFromWorker } from '@/workers/firehose_master'; | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { ArrowTurnUpSolid } from 'svelte-awesome-icons'; | ||
import { derived, writable, type Writable } from 'svelte/store'; | ||
onMount(() => {}); | ||
onDestroy(() => {}); | ||
function find(m: RecursiveEventMap, id: string): EventTreeItem | undefined { | ||
if (m.get(id)) { | ||
return m.get(id)!; | ||
} | ||
for (let [_, item] of m) { | ||
let c = find(item.children, id); | ||
if (c) { | ||
return c; | ||
} | ||
} | ||
} | ||
//todo: if the last parentFromUsersHistory is included in the current threadParent's tags, go to that when user navigates UP. If not, go to the e-tag that 1) we have and 2) has the most replies. | ||
let threadParentID = writable(['root']); | ||
function pop() { | ||
threadParentID.update((existing) => { | ||
existing.pop(); | ||
return existing; | ||
}); | ||
} | ||
let rThreadParent = derived([responseFromWorker, threadParentID], ([$rfw, $threadParentID]) => { | ||
if ($threadParentID[$threadParentID.length - 1] == 'root') { | ||
return $rfw.recursiveEvents; | ||
} else { | ||
return find($rfw.recursiveEvents.children, $threadParentID[$threadParentID.length - 1]); | ||
} | ||
}); | ||
</script> | ||
|
||
<ChatLayout> | ||
<div slot="buttons"> | ||
{#if $threadParentID[$threadParentID.length - 1] != 'root'} | ||
<Button on:click={pop} variant="outline" size="icon" class="-scale-x-100 hover:skew-y-12" | ||
><ArrowTurnUpSolid /></Button | ||
> | ||
{/if} | ||
</div> | ||
<slot> | ||
{#if $rThreadParent} | ||
<Kind1 | ||
treeItem={$rThreadParent || $responseFromWorker.recursiveEvents} | ||
bind:newParent={threadParentID} | ||
/> | ||
{/if} | ||
</slot> | ||
</ChatLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script lang="ts"> | ||
import type { EventTreeItem } from '@/workers/firehose.types'; | ||
import { type Writable } from 'svelte/store'; | ||
import RenderNoteContent from '../../lib/components/RenderNoteContent.svelte'; | ||
import Reply from './Reply.svelte'; | ||
import Zap from './Zap.svelte'; | ||
import Marcus from './Marcus.svelte'; | ||
export let treeItem: EventTreeItem; | ||
export let newParent: Writable<string[]>; | ||
let t: [string, EventTreeItem][]; | ||
$: { | ||
let _t = [...treeItem.children.entries()].toSorted((_a, _b): number => { | ||
let [_, a] = _a; | ||
let [__, b] = _b; | ||
return b.children.size - a.children.size; | ||
}); | ||
t = _t.filter(([id, item]) => { | ||
return item.event.kind == 1; | ||
}); | ||
} | ||
</script> | ||
<div class="mt-2"></div> | ||
{#each t as [id, tree], i (id)} | ||
<div class="w-full"> | ||
<div class="grid"> | ||
<div class="flex gap-2"> | ||
<img | ||
class="w-8 h-8 rounded-full" | ||
src="https://zenquotes.io/img/marcus-aurelius.jpg" | ||
alt="profile pic" | ||
/> | ||
<div class="grid"> | ||
<h5 class="text-gray-900 dark:text-orange-600 font-semibold leading-snug pb-1">Marcus</h5> | ||
<div class="grid overflow-hidden mr-2"> | ||
<div class="px-3.5 py-2 bg-gray-200 dark:bg-gray-700 rounded-e-xl rounded-es-xl flex flex-col gap-2"> | ||
<h5 class="text-sm font-normal text-gray-900 dark:text-white py-2"> | ||
<RenderNoteContent inputString={tree.event.content} /> | ||
</h5> | ||
<div class="flex justify-between"> | ||
<div><Marcus onclick={()=>{alert("implement me!")}} {tree} /></div> | ||
|
||
<div> | ||
<Zap onclick={()=>{alert("implement me!")}} {tree}/> | ||
<Reply | ||
onclick={() => { | ||
console.log(48); | ||
newParent.update((existing) => { | ||
existing.push(id); | ||
return existing; | ||
}); | ||
}} | ||
{tree} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="justify-end items-center inline-flex mb-2.5"> | ||
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1"> | ||
{new Date(tree.event.created_at * 1000).toLocaleString()} | ||
</h6> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{/each} |
Oops, something went wrong.