Remove general room

This commit is contained in:
Jon Staab
2025-05-27 15:04:44 -07:00
parent cf4e40c4cf
commit c33698c662
9 changed files with 31 additions and 63 deletions

View File

@@ -14,13 +14,7 @@
import ModalFooter from "@lib/components/ModalFooter.svelte"
import InfoBunker from "@app/components/InfoBunker.svelte"
import BunkerConnect, {BunkerConnectController} from "@app/components/BunkerConnect.svelte"
import {
GENERAL,
alerts,
getMembershipUrls,
getMembershipRoomsByUrl,
userMembership,
} from "@app/state"
import {alerts, getMembershipUrls, getMembershipRoomsByUrl, userMembership} from "@app/state"
import {loadAlertStatuses} from "@app/requests"
import {publishAlert} from "@app/commands"
import {pushToast} from "@app/toast"
@@ -107,7 +101,7 @@
display.push("chat")
filters.push({
kinds: [MESSAGE],
"#h": [GENERAL, ...getMembershipRoomsByUrl(relay, $userMembership)],
"#h": getMembershipRoomsByUrl(relay, $userMembership),
})
}

View File

@@ -13,7 +13,7 @@
import ModalFooter from "@lib/components/ModalFooter.svelte"
import DateTimeInput from "@lib/components/DateTimeInput.svelte"
import EditorContent from "@app/editor/EditorContent.svelte"
import {PROTECTED, GENERAL, tagRoom} from "@app/state"
import {PROTECTED} from "@app/state"
import {makeEditor} from "@app/editor"
import {pushToast} from "@app/toast"
@@ -73,7 +73,6 @@
["end", end.toString()],
...daysBetween(start, end).map(D => ["D", D.toString()]),
...ed.storage.nostr.getEditorTags(),
tagRoom(GENERAL, url),
PROTECTED,
],
})

View File

@@ -1,11 +1,7 @@
<script lang="ts">
import {GENERAL, channelsById, makeChannelId} from "@app/state"
import {channelsById, makeChannelId} from "@app/state"
const {url, room} = $props()
</script>
{#if room === GENERAL}
general
{:else}
{$channelsById.get(makeChannelId(url, room))?.name || room}
{/if}
{$channelsById.get(makeChannelId(url, room))?.name || room}

View File

@@ -8,7 +8,7 @@
import ModalFooter from "@lib/components/ModalFooter.svelte"
import EditorContent from "@app/editor/EditorContent.svelte"
import {publishComment} from "@app/commands"
import {tagRoom, GENERAL, PROTECTED} from "@app/state"
import {PROTECTED} from "@app/state"
import {makeEditor} from "@app/editor"
import {pushToast} from "@app/toast"
@@ -23,7 +23,7 @@
const ed = await editor
const content = ed.getText({blockSeparator: "\n"}).trim()
const tags = [...ed.storage.nostr.getEditorTags(), tagRoom(GENERAL, url), PROTECTED]
const tags = [...ed.storage.nostr.getEditorTags(), PROTECTED]
if (!content) {
return pushToast({

View File

@@ -10,7 +10,7 @@
import ModalFooter from "@lib/components/ModalFooter.svelte"
import EditorContent from "@app/editor/EditorContent.svelte"
import {pushToast} from "@app/toast"
import {GENERAL, tagRoom, PROTECTED} from "@app/state"
import {PROTECTED} from "@app/state"
import {makeEditor} from "@app/editor"
const {url} = $props()
@@ -41,12 +41,7 @@
})
}
const tags = [
...ed.storage.nostr.getEditorTags(),
tagRoom(GENERAL, url),
["title", title],
PROTECTED,
]
const tags = [...ed.storage.nostr.getEditorTags(), ["title", title], PROTECTED]
publishThunk({
relays: [url],

View File

@@ -71,8 +71,6 @@ export const fromCsv = (s: string) => (s || "").split(",").filter(identity)
export const ROOM = "h"
export const GENERAL = "_"
export const PROTECTED = ["-"]
export const ALERT = 32830
@@ -582,13 +580,8 @@ export const channelsByUrl = derived(channelsById, $channelsById => {
return $channelsByUrl
})
export const displayChannel = (url: string, room: string) => {
if (room === GENERAL) {
return "general"
}
return channelsById.get().get(makeChannelId(url, room))?.name || room
}
export const displayChannel = (url: string, room: string) =>
channelsById.get().get(makeChannelId(url, room))?.name || room
export const roomComparator = (url: string) => (room: string) =>
displayChannel(url, room).toLowerCase()
@@ -633,17 +626,13 @@ export const userRoomsByUrl = withGetter(
addToMapKey($userRoomsByUrl, normalizeRelayUrl(url), room)
}
for (const url of getRelayTagValues(tags)) {
addToMapKey($userRoomsByUrl, normalizeRelayUrl(url), GENERAL)
}
return $userRoomsByUrl
}),
)
export const deriveUserRooms = (url: string) =>
derived(userRoomsByUrl, $userRoomsByUrl =>
sortBy(roomComparator(url), uniq(Array.from($userRoomsByUrl.get(url) || [GENERAL]))),
sortBy(roomComparator(url), uniq(Array.from($userRoomsByUrl.get(url) || []))),
)
export const deriveOtherRooms = (url: string) =>

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import type {Snippet} from 'svelte'
import type {Snippet} from "svelte"
import {page} from "$app/stores"
type Props = {

View File

@@ -22,7 +22,6 @@
import {
userSettingValues,
decodeRelay,
GENERAL,
tagRoom,
userRoomsByUrl,
displayChannel,
@@ -41,7 +40,7 @@
import {popKey} from "@app/implicit"
import {pushToast} from "@app/toast"
const {room = GENERAL} = $page.params
const {room} = $page.params
const mounted = now()
const lastChecked = $checked[$page.url.pathname]
const url = decodeRelay($page.params.relay)
@@ -252,7 +251,6 @@
{/snippet}
{#snippet action()}
<div class="row-2">
{#if room !== GENERAL}
{#if $userRoomsByUrl.get(url)?.has(room)}
<Button class="btn btn-neutral btn-sm" onclick={leaveRoom}>
<Icon icon="arrows-a-logout-2" />
@@ -268,7 +266,6 @@
Join Room
</Button>
{/if}
{/if}
<MenuSpaceButton {url} />
</div>
{/snippet}

View File

@@ -17,7 +17,7 @@
import CalendarEventItem from "@app/components/CalendarEventItem.svelte"
import CalendarEventCreate from "@app/components/CalendarEventCreate.svelte"
import {pushModal} from "@app/modal"
import {GENERAL, getEventsForUrl, decodeRelay} from "@app/state"
import {getEventsForUrl, decodeRelay} from "@app/state"
import {makeCalendarFeed} from "@app/requests"
import {setChecked} from "@app/notifications"
@@ -92,10 +92,8 @@
})
onMount(() => {
const feedFilters = [{kinds: [EVENT_TIME], "#h": [GENERAL]}]
const subscriptionFilters = [
{kinds: [DELETE, REACTION, EVENT_TIME], "#h": [GENERAL], since: now()},
]
const feedFilters = [{kinds: [EVENT_TIME]}]
const subscriptionFilters = [{kinds: [DELETE, REACTION, EVENT_TIME], since: now()}]
;({events, cleanup} = makeCalendarFeed({
element: element!,