-
-
-
Topics
-
-
-
- #{item.name}
+
+
+
-
-
-
-
- {/if}
-
+
+
+
+ {/if}
+
+
{/if}
diff --git a/src/app/shared/FilterSummary.svelte b/src/app/shared/FilterSummary.svelte
index 1b0157a9..2298e4b3 100644
--- a/src/app/shared/FilterSummary.svelte
+++ b/src/app/shared/FilterSummary.svelte
@@ -16,18 +16,9 @@
const getFilterParts = f => {
const parts = []
- if (filter.since && filter.until) {
- const since = formatTimestampAsDate(filter.since)
- const until = formatTimestampAsDate(filter.until)
-
- parts.push(`Between ${since} and ${until}`)
- } else if (filter.since) {
- parts.push(`After ${formatTimestampAsDate(filter.since)}`)
- } else if (filter.until) {
- parts.push(`Before ${formatTimestampAsDate(filter.until)}`)
- }
-
- if (filter.authors?.length > 0) {
+ if (typeof filter.authors === "string") {
+ parts.push(`From ${filter.authors}`)
+ } else if (filter.authors?.length > 0) {
parts.push(`By ${displayPeople(filter.authors)}`)
}
@@ -43,6 +34,17 @@
parts.push(`Matching ${filter.search}`)
}
+ if (filter.since && filter.until) {
+ const since = formatTimestampAsDate(filter.since)
+ const until = formatTimestampAsDate(filter.until)
+
+ parts.push(`Between ${since} and ${until}`)
+ } else if (filter.since) {
+ parts.push(`After ${formatTimestampAsDate(filter.since)}`)
+ } else if (filter.until) {
+ parts.push(`Before ${formatTimestampAsDate(filter.until)}`)
+ }
+
return parts
}
diff --git a/src/app/state.ts b/src/app/state.ts
index bcf1decf..4d25ddda 100644
--- a/src/app/state.ts
+++ b/src/app/state.ts
@@ -1,4 +1,5 @@
-import type {DisplayEvent} from "src/util/types"
+import type {Filter} from "nostr-tools"
+import type {DisplayEvent, DynamicFilter} from "src/util/types"
import Bugsnag from "@bugsnag/js"
import {nip19} from "nostr-tools"
import {navigate} from "svelte-routing"
@@ -7,7 +8,7 @@ import {writable} from "svelte/store"
import {max, omit, pluck, sortBy, find, slice, propEq} from "ramda"
import {createMap, doPipe, first} from "hurdak/lib/hurdak"
import {warn} from "src/util/logger"
-import {hash, sleep, clamp} from "src/util/misc"
+import {hash, shuffle, sleep, clamp} from "src/util/misc"
import {now, timedelta} from "src/util/misc"
import {Tags, isNotification, userKinds} from "src/util/nostr"
import {findReplyId} from "src/util/nostr"
@@ -18,7 +19,7 @@ import keys from "src/agent/keys"
import network from "src/agent/network"
import pool from "src/agent/pool"
import {getUserReadRelays, getUserRelays} from "src/agent/relays"
-import {getUserFollows} from "src/agent/social"
+import {getUserFollows, getUserNetwork} from "src/agent/social"
import user from "src/agent/user"
// Routing
@@ -83,10 +84,6 @@ export const logUsage = async name => {
}
}
-// Feed
-
-export const feedsTab = writable("Follows")
-
// State
export const newNotifications = derived(
@@ -289,3 +286,17 @@ export const publishWithToast = (relays, thunk) =>
toast.show("info", message, pending.size ? null : 5)
})
+
+// Feeds
+
+export const compileFilter = (filter: DynamicFilter): Filter => {
+ if (filter.authors === "global") {
+ filter = omit(["authors"], filter)
+ } else if (filter.authors === "follows") {
+ filter = {...filter, authors: shuffle(getUserFollows()).slice(0, 256)}
+ } else if (filter.authors === "network") {
+ filter = {...filter, authors: shuffle(getUserNetwork()).slice(0, 256)}
+ }
+
+ return filter
+}
diff --git a/src/app/views/Feeds.svelte b/src/app/views/Feeds.svelte
index 668710a4..f9d5749e 100644
--- a/src/app/views/Feeds.svelte
+++ b/src/app/views/Feeds.svelte
@@ -1,63 +1,51 @@
@@ -69,44 +57,41 @@
{/if}
-
- {#if $canPublish}
- {#if $lists.length > 0}
-
-
-
- {#each $lists as e (e.id)}
- {@const meta = Tags.from(e).asMeta()}
+ {#key key}
+
+
+ {#if $lists.length > 0}
+
+
+
+ {#each $lists as e (e.id)}
+ {@const meta = Tags.from(e).asMeta()}
+
+ {/each}
- {/each}
-
-
-
- {:else}
-
- {/if}
- {/if}
-
- {#key $feedsTab}
-
+
+
+ {:else}
+
+ {/if}
+
+
{/key}
diff --git a/src/partials/SelectButton.svelte b/src/partials/SelectButton.svelte
index b4484ec9..d2be88e0 100644
--- a/src/partials/SelectButton.svelte
+++ b/src/partials/SelectButton.svelte
@@ -3,19 +3,21 @@
export let options
export let value
+ export let onChange = null
-
+
{#each options as option, i}
0,
- "bg-accent": value === option,
+ "bg-accent text-white": value === option,
})}
on:click={() => {
value = option
+ onChange?.(value)
}}>
{option}
diff --git a/src/util/types.ts b/src/util/types.ts
index 575ba009..de104807 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -1,4 +1,4 @@
-import type {Event} from "nostr-tools"
+import type {Event, Filter} from "nostr-tools"
export type Relay = {
url: string
@@ -37,3 +37,7 @@ export type Room = {
about?: string
picture?: string
}
+
+export type DynamicFilter = Filter & {
+ authors?: string | string[]
+} & Record