Skip to content

Commit

Permalink
problem: don't know when note has already been read
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Apr 18, 2024
1 parent a154494 commit f8b96a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/lib/views/messages/Messages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@
renderQueue.subscribe((q) => {});
//remove viewed and add new items that haven't been viewed
let shortListLength = derived([renderQueue, viewed], ([$renderQ, $viewed]) => {
//todo: if root cool, but if not, keep loading more 3 at a time
let shortListLength = derived([renderQueue, viewed, threadParentID], ([$renderQ, $viewed, $parentID]) => {
let dirty = false;
let updated: NostrEvent[] = [];
for (let e of _stableShortlist) {
if (!$viewed.has(e.id)) {
if (!$viewed.has(e.id) || $parentID != "root") {
//console.log(72, e.id);
updated.push(e);
} else {
Expand Down
37 changes: 20 additions & 17 deletions src/lib/views/messages/RenderKind1.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import { derived, type Writable } from 'svelte/store';
import type { FrontendData } from '@/snort_workers/types';
import { inview } from 'svelte-inview';
import { viewed } from '@/workers_snort/firehose_master';
import { viewed } from '@/workers_snort/firehose_master';
export let note: NostrEvent;
export let onClickReply: () => void;
Expand All @@ -17,7 +16,6 @@
$: childrenCount = $store?.replies.get(note.id) ? $store.replies.get(note.id)!.size : 0;
</script>


<div class="w-full mt-2">
<div class="grid">
<div class="flex gap-2">
Expand Down Expand Up @@ -56,24 +54,29 @@
</div>
</div>
</div>
<div class="justify-end items-center inline-flex">
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1">
{new Date(note.created_at * 1000).toLocaleString()}
</h6>
<div class="flex justify-between">
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1">

</h6>
<div class="justify-end items-center inline-flex">
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1">
{new Date(note.created_at * 1000).toLocaleString()} {#if $viewed.has(note.id)}✓{/if}
</h6>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
use:inview={{}}
on:inview_leave={(event) => {
if (event.detail.scrollDirection.vertical == "up") {
viewed.update(v=>{
v.add(note.id)
return v
})
}
}}
></div>
use:inview={{}}
on:inview_leave={(event) => {
if (event.detail.scrollDirection.vertical == 'up') {
viewed.update((v) => {
v.add(note.id);
return v;
});
}
}}
></div>
3 changes: 2 additions & 1 deletion src/lib/views/messages/RenderKind1AsThreadHead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import Reply from "./Reply.svelte";
import { derived, type Writable } from "svelte/store";
import type { FrontendData } from "@/snort_workers/types";
import { viewed } from "@/workers_snort/firehose_master";
export let note:NostrEvent
export let store: Writable<FrontendData>
Expand All @@ -32,7 +33,7 @@
</div>
<div class="justify-end items-center inline-flex">
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1">
{new Date(note.created_at * 1000).toLocaleString()}
{new Date(note.created_at * 1000).toLocaleString()}{#if $viewed.has(note.id)}✓{/if}
</h6>
</div>
</div>
Expand Down

0 comments on commit f8b96a2

Please sign in to comment.