-
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.
fix most of the memory leaks in feeds, need to find a solution for ob…
…serve
- Loading branch information
Showing
23 changed files
with
375 additions
and
120 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
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
14 changes: 14 additions & 0 deletions
14
apps/gui/src/lib/components/partials/FeedNoteComments.svelte
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,14 @@ | ||
<script lang="ts"> | ||
import { type Readable } from 'svelte/store'; | ||
import { noteCommentsCount$ } from '$stores/helpers/helpers-notes'; | ||
import type { NostrEvent } from '@nostrwatch/route66/models'; | ||
import type { SvelteMemoryRelay } from '@nostrwatch/memory-relay'; | ||
export let note: NostrEvent; | ||
export let memoryRelay: SvelteMemoryRelay<NostrEvent, NostrEvent>; | ||
export let commentsCountCache: number; | ||
const comments: Readable<number> = noteCommentsCount$<NostrEvent>(note.id, memoryRelay); | ||
comments.subscribe( count => commentsCountCache = count ) | ||
</script> | ||
|
||
{commentsCountCache? commentsCountCache : ''} |
14 changes: 14 additions & 0 deletions
14
apps/gui/src/lib/components/partials/FeedNoteReactions.svelte
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,14 @@ | ||
<script lang="ts"> | ||
import { type Readable } from 'svelte/store'; | ||
import { noteReactionsCount$ } from '$stores/helpers/helpers-notes'; | ||
import type { NostrEvent } from '@nostrwatch/route66/models'; | ||
import type { SvelteMemoryRelay } from '@nostrwatch/memory-relay'; | ||
export let note: NostrEvent; | ||
export let memoryRelay: SvelteMemoryRelay<NostrEvent, NostrEvent>; | ||
export let reactionsCountCache: number; | ||
const reactions: Readable<number> = noteReactionsCount$<NostrEvent>(note.id, memoryRelay); | ||
reactions.subscribe( count => reactionsCountCache = count ) | ||
</script> | ||
|
||
{$reactions? $reactions : ''} |
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,47 @@ | ||
<script lang="ts"> | ||
import Bolt11 from 'light-bolt11-decoder'; | ||
import { type Readable } from 'svelte/store'; | ||
import { noteCommentsCount$, noteZaps$ } from '$stores/helpers/helpers-notes'; | ||
import type { NostrEvent } from '@nostrwatch/route66/models'; | ||
import type { SvelteMemoryRelay } from '@nostrwatch/memory-relay'; | ||
export let note: NostrEvent; | ||
export let memoryRelay: SvelteMemoryRelay<NostrEvent, NostrEvent>; | ||
export let zapSumCache: string; | ||
const zaps: Readable<NostrEvent[]> = noteZaps$<NostrEvent>(note.id, memoryRelay); | ||
$: bolt11s = $zaps.map(zap => { | ||
const b11 = zap.tags.find(tag => tag[0] === 'bolt11')?.[1] | ||
if(!b11) return null | ||
return Bolt11.decode(b11) | ||
}).filter( b11 => b11 !== null ) | ||
$: zapSum = abbrNum( | ||
Math | ||
.round( | ||
bolt11s | ||
.reduce((acc, b11) => acc += parseInt( | ||
b11.sections.find( | ||
section => section?.name === 'amount')?.value || "0" | ||
) | ||
, 0) | ||
/1000 | ||
) | ||
); | ||
zaps.subscribe( sum => zapSumCache = zapSum ) | ||
function abbrNum(num: number): string { | ||
if(num === 0) return ''; | ||
if (num < 1000) return num.toString(); | ||
const units = ["", "K", "M", "B", "T", "P", "E"]; | ||
const magnitude = Math.floor(Math.log10(num) / 3); | ||
const precision = magnitude - 1; | ||
const scaled = num / Math.pow(1000, magnitude); | ||
return `${scaled.toFixed(precision + 1)}${units[magnitude]}`; | ||
} | ||
</script> | ||
|
||
{zapSum? zapSum : ''} |
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
Oops, something went wrong.