mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-11 11:27:03 +00:00
Improve data loading a bit
This commit is contained in:
6244
package-lock.json
generated
6244
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,9 @@
|
|||||||
"format": "prettier --write src",
|
"format": "prettier --write src",
|
||||||
"prepare": "husky"
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
|
"overrides": {
|
||||||
|
"@capacitor/core": "^7.0.1"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/assets": "^3.0.5",
|
"@capacitor/assets": "^3.0.5",
|
||||||
"@sentry/cli": "^2.40.0",
|
"@sentry/cli": "^2.40.0",
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {hash} from "@welshman/lib"
|
import {hash} from "@welshman/lib"
|
||||||
|
import {now} from "@welshman/lib"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
import {
|
import {
|
||||||
thunks,
|
thunks,
|
||||||
|
pubkey,
|
||||||
deriveProfile,
|
deriveProfile,
|
||||||
deriveProfileDisplay,
|
deriveProfileDisplay,
|
||||||
|
formatTimestampAsDate,
|
||||||
formatTimestampAsTime,
|
formatTimestampAsTime,
|
||||||
pubkey,
|
|
||||||
} from "@welshman/app"
|
} from "@welshman/app"
|
||||||
import {isMobile} from "@lib/html"
|
import {isMobile} from "@lib/html"
|
||||||
import LongPress from "@lib/components/LongPress.svelte"
|
import LongPress from "@lib/components/LongPress.svelte"
|
||||||
@@ -31,6 +33,7 @@
|
|||||||
export let inert = false
|
export let inert = false
|
||||||
|
|
||||||
const thunk = $thunks[event.id]
|
const thunk = $thunks[event.id]
|
||||||
|
const today = formatTimestampAsDate(now())
|
||||||
const profile = deriveProfile(event.pubkey)
|
const profile = deriveProfile(event.pubkey)
|
||||||
const profileDisplay = deriveProfileDisplay(event.pubkey)
|
const profileDisplay = deriveProfileDisplay(event.pubkey)
|
||||||
const [_, colorValue] = colors[parseInt(hash(event.pubkey)) % colors.length]
|
const [_, colorValue] = colors[parseInt(hash(event.pubkey)) % colors.length]
|
||||||
@@ -70,7 +73,14 @@
|
|||||||
<Button on:click={openProfile} class="text-sm font-bold" style="color: {colorValue}">
|
<Button on:click={openProfile} class="text-sm font-bold" style="color: {colorValue}">
|
||||||
{$profileDisplay}
|
{$profileDisplay}
|
||||||
</Button>
|
</Button>
|
||||||
<span class="text-xs opacity-50">{formatTimestampAsTime(event.created_at)}</span>
|
<span class="text-xs opacity-50">
|
||||||
|
{#if formatTimestampAsDate(event.created_at) === today}
|
||||||
|
Today
|
||||||
|
{:else}
|
||||||
|
{formatTimestampAsDate(event.created_at)}
|
||||||
|
{/if}
|
||||||
|
at {formatTimestampAsTime(event.created_at)}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="text-sm">
|
<div class="text-sm">
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {ago, WEEK} from "@welshman/lib"
|
import {ago, MONTH} from "@welshman/lib"
|
||||||
import {GROUPS, THREAD, COMMENT, MESSAGE, DELETE} from "@welshman/util"
|
import {GROUPS, THREAD, COMMENT, MESSAGE, DELETE} from "@welshman/util"
|
||||||
import {subscribe} from "@welshman/app"
|
import {subscribe, load} from "@welshman/app"
|
||||||
import Page from "@lib/components/Page.svelte"
|
import Page from "@lib/components/Page.svelte"
|
||||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||||
@@ -47,23 +47,22 @@
|
|||||||
checkConnection()
|
checkConnection()
|
||||||
|
|
||||||
const relays = [url]
|
const relays = [url]
|
||||||
const since = ago(WEEK)
|
const since = ago(MONTH)
|
||||||
|
|
||||||
// Load all groups for this space to populate navigation
|
// Load all groups for this space to populate navigation. It would be nice to sync, but relay29
|
||||||
pullConservatively({relays, filters: [{kinds: [GROUPS]}]})
|
// is too picky about how requests are built.
|
||||||
|
load({relays, filters: [{kinds: [GROUPS]}], delay: 0})
|
||||||
|
|
||||||
// Load threads and comments
|
// Load threads, comments, and recent messages for user rooms to help with a quick page transition
|
||||||
pullConservatively({
|
pullConservatively({
|
||||||
relays,
|
relays,
|
||||||
filters: [
|
filters: [
|
||||||
{kinds: [THREAD], since},
|
{kinds: [THREAD], since},
|
||||||
{kinds: [COMMENT], "#K": [String(THREAD)], since},
|
{kinds: [COMMENT], "#K": [String(THREAD)], since},
|
||||||
|
...rooms.map(r => ({kinds: [MESSAGE], "#h": [r], since})),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
// Load recent messages for user rooms to help with a quick page transition
|
|
||||||
pullConservatively({relays, filters: rooms.map(r => ({kinds: [MESSAGE], "#h": [r], since}))})
|
|
||||||
|
|
||||||
// Listen for deletes that would apply to messages we already have, and new groups
|
// Listen for deletes that would apply to messages we already have, and new groups
|
||||||
const sub = subscribe({relays, filters: [{kinds: [DELETE, GROUPS], since}]})
|
const sub = subscribe({relays, filters: [{kinds: [DELETE, GROUPS], since}]})
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {derived} from "svelte/store"
|
import {derived} from "svelte/store"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {sleep, now, ctx} from "@welshman/lib"
|
import {sleep, ago, MONTH, ctx} from "@welshman/lib"
|
||||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||||
import {throttled} from "@welshman/store"
|
import {throttled} from "@welshman/store"
|
||||||
import {feedsFromFilter, makeIntersectionFeed, makeRelayFeed} from "@welshman/feeds"
|
import {feedsFromFilter, makeIntersectionFeed, makeRelayFeed} from "@welshman/feeds"
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
|
|
||||||
const sub = subscribe({
|
const sub = subscribe({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
filters: [{kinds: [DELETE, REACTION, MESSAGE], "#h": [room], since: now()}],
|
filters: [{kinds: [DELETE, REACTION, MESSAGE], "#h": [room], since: ago(MONTH)}],
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -190,7 +190,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</PageBar>
|
</PageBar>
|
||||||
<div
|
<div
|
||||||
class="scroll-container -mt-2 flex flex-grow flex-col-reverse overflow-auto py-2"
|
class="scroll-container -mt-2 flex flex-grow flex-col-reverse overflow-y-auto overflow-x-hidden py-2"
|
||||||
bind:this={element}>
|
bind:this={element}>
|
||||||
{#each $elements.slice(0, limit) as { type, id, value, showPubkey } (id)}
|
{#each $elements.slice(0, limit) as { type, id, value, showPubkey } (id)}
|
||||||
{#if type === "date"}
|
{#if type === "date"}
|
||||||
|
|||||||
Reference in New Issue
Block a user