-
Notifications
You must be signed in to change notification settings - Fork 478
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
Showing
56 changed files
with
791 additions
and
386 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 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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<script lang="ts"> | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { get, writable, type Readable, type Writable } from 'svelte/store'; | ||
import Masonry from 'svelte-bricks'; | ||
import type { Filter } from 'nostr-tools'; | ||
import { route66 } from '$lib/stores'; | ||
import { User } from '$lib/models/User.js'; | ||
import type { UserFeed } from '$lib/services/UserService'; | ||
import { FeedService } from '$lib/services/FeedService'; | ||
import { deterministicHash } from '@nostrwatch/route66/utils'; | ||
import type { NostrEvent } from '@nostrwatch/route66/models'; | ||
import FeedNote from './FeedNote.svelte'; | ||
import { observeViewport } from '$lib/utils/ux'; | ||
import { pauseLiveSync } from '$lib/utils/lifecycle'; | ||
export let filters: Filter[]; | ||
let user: User | undefined; | ||
let resumer: Function | undefined; | ||
const feedService: Writable<FeedService | null> = writable(null); | ||
const feed: Writable<UserFeed> = writable([]); | ||
const until: Writable<number> = writable(); | ||
const busy: Writable<boolean> = writable(false); | ||
let items: Readable<NostrEvent[]> | undefined; | ||
let [minColWidth, maxColWidth, gap] = [300, 500, 21] | ||
let width:number, height: number | ||
const lastItemId = () => { | ||
return $items![$feed.length - 1].id; | ||
} | ||
const middleItemId = () => { | ||
return $items![Math.floor($feed.length / 2)].id; | ||
} | ||
const lowItemId = (id: string): boolean => { | ||
return $items!.slice(-4).map( item => item.id).includes(id); | ||
} | ||
const mount = async () => { | ||
resumer = await pauseLiveSync(); | ||
if(!$route66) return console.warn('route66 does not exist.'); | ||
await $route66.ready(); | ||
feedService.set(new FeedService($route66.adapters, filters)); | ||
$feedService!.populate(); | ||
items = $feedService!.memoryRelay.$req(deterministicHash(filters), filters) | ||
} | ||
const destroy = () => { | ||
$feedService!.unsubscribeAll(); | ||
resumer?.() | ||
} | ||
onMount(mount); | ||
onDestroy(destroy); | ||
$: count = $feedService? $feedService?.memoryRelay.count([{}]): 0; | ||
</script> | ||
|
||
<section id="operator-feed" class="block relative"> | ||
{#if $items?.length === 0} | ||
<div class="flex flex-col text-center items-center justify-center h-[600px]"> | ||
<span class="text-2xl text-center">loading</span> | ||
</div> | ||
{/if} | ||
|
||
{$items?.length} | ||
|
||
{#if $feedService && $items?.length} | ||
<Masonry | ||
items={$items as NostrEvent[]} | ||
{minColWidth} | ||
{maxColWidth} | ||
{gap} | ||
let:item | ||
bind:width | ||
bind:height > | ||
|
||
{#if lowItemId(item.id)} | ||
<div | ||
use:observeViewport | ||
on:viewportchange={(event: any) => { | ||
if(event.detail.isIntersecting) $feedService!.populate(); | ||
}}></div> | ||
{/if} | ||
|
||
<FeedNote note={item} memoryRelay={$feedService.memoryRelay} /> | ||
</Masonry> | ||
{/if} | ||
|
||
</section> | ||
|
||
|
||
|
||
|
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.