forked from coracle/flotilla
Rework alert settings and UI
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
import SpaceAdd from "@app/components/SpaceAdd.svelte"
|
||||
import SpaceInviteAccept from "@app/components/SpaceInviteAccept.svelte"
|
||||
import RelaySummary from "@app/components/RelaySummary.svelte"
|
||||
import SpaceCheck from "@app/components/SpaceCheck.svelte"
|
||||
import SpaceJoin from "@app/components/SpaceJoin.svelte"
|
||||
import {groupListPubkeysByUrl, parseInviteLink} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
})
|
||||
|
||||
const relaySearch = _derived(throttled(1000, relays), $relays => {
|
||||
const options = $relays.filter(
|
||||
r => $groupListPubkeysByUrl.has(r.url) && r.url !== inviteData?.url,
|
||||
)
|
||||
const options = $relays.filter(r => $groupListPubkeysByUrl.has(r.url))
|
||||
|
||||
return createSearch(options, {
|
||||
getValue: (relay: RelayProfile) => relay.url,
|
||||
@@ -60,7 +58,7 @@
|
||||
if (claim) {
|
||||
pushModal(SpaceInviteAccept, {invite: term})
|
||||
} else {
|
||||
pushModal(SpaceCheck, {url})
|
||||
pushModal(SpaceJoin, {url})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +67,7 @@
|
||||
let showScanner = $state(false)
|
||||
let element: Element
|
||||
|
||||
const options = $derived($relaySearch.searchOptions(term))
|
||||
const options = $derived($relaySearch.searchOptions(term).filter(r => r.url !== inviteData?.url))
|
||||
const inviteData = $derived(parseInviteLink(term))
|
||||
|
||||
onMount(() => {
|
||||
|
||||
@@ -105,23 +105,6 @@
|
||||
<input type="checkbox" class="toggle toggle-primary" bind:checked={settings.messages} />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class={cx("card2 bg-alt col-4 shadow-md", {
|
||||
"pointer-events-none opacity-50": !settings.badge && !settings.sound && !settings.push,
|
||||
})}>
|
||||
<strong class="text-lg">Muted Rooms</strong>
|
||||
{#each muted_rooms as id (id)}
|
||||
{@const [url, h] = splitRoomId(id)}
|
||||
<div class="flex-inline badge badge-neutral mr-1 gap-1">
|
||||
<Button class="flex items-center" onclick={() => removeMutedRoom(id)}>
|
||||
<Icon icon={CloseCircle} size={4} class="-ml-1 mt-px" />
|
||||
</Button>
|
||||
Room "<RoomName {url} {h} />" on {displayRelayUrl(url)}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="flex items-center justify-center text-sm py-4 opacity-70">No muted rooms found.</p>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="mt-4 flex flex-row items-center justify-between gap-4">
|
||||
<Button class="btn btn-neutral" onclick={reset} disabled={loading}>Discard Changes</Button>
|
||||
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
||||
|
||||
@@ -20,11 +20,7 @@
|
||||
import ClockCircle from "@assets/icons/clock-circle.svg?dataurl"
|
||||
import Login2 from "@assets/icons/login-3.svg?dataurl"
|
||||
import AltArrowDown from "@assets/icons/alt-arrow-down.svg?dataurl"
|
||||
import Bookmark from "@assets/icons/bookmark.svg?dataurl"
|
||||
import VolumeLoud from "@assets/icons/volume-loud.svg?dataurl"
|
||||
import VolumeCross from "@assets/icons/volume-cross.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import PageBar from "@lib/components/PageBar.svelte"
|
||||
@@ -42,24 +38,19 @@
|
||||
import RoomComposeEdit from "@src/app/components/RoomComposeEdit.svelte"
|
||||
import RoomComposeParent from "@app/components/RoomComposeParent.svelte"
|
||||
import {
|
||||
deriveUserRooms,
|
||||
notificationSettings,
|
||||
userSettingsValues,
|
||||
decodeRelay,
|
||||
deriveUserRoomMembershipStatus,
|
||||
deriveRoom,
|
||||
MembershipStatus,
|
||||
PROTECTED,
|
||||
MESSAGE_KINDS,
|
||||
userSettingsValues,
|
||||
} from "@app/core/state"
|
||||
import {setChecked, checked} from "@app/util/notifications"
|
||||
import {
|
||||
canEnforceNip70,
|
||||
prependParent,
|
||||
publishDelete,
|
||||
publishSettings,
|
||||
addRoomMembership,
|
||||
removeRoomMembership,
|
||||
} from "@app/core/commands"
|
||||
import {makeFeed} from "@app/core/requests"
|
||||
import {popKey} from "@lib/implicit"
|
||||
@@ -72,30 +63,10 @@
|
||||
const url = decodeRelay(relay)
|
||||
const room = deriveRoom(url, h)
|
||||
const shouldProtect = canEnforceNip70(url)
|
||||
const userRooms = deriveUserRooms(url)
|
||||
const isFavorite = $derived($userRooms.includes(h))
|
||||
const membershipStatus = deriveUserRoomMembershipStatus(url, h)
|
||||
const isMuted = $derived($userSettingsValues.muted_rooms.includes($room.id))
|
||||
const hasAlerts = throttled(
|
||||
800,
|
||||
_derived(
|
||||
notificationSettings,
|
||||
({spaces, push, sound, badge}) => spaces && (push || sound || badge),
|
||||
),
|
||||
)
|
||||
|
||||
const showRoomDetail = () => pushModal(RoomDetail, {url, h})
|
||||
|
||||
const addFavorite = () => addRoomMembership(url, h)
|
||||
|
||||
const removeFavorite = () => removeRoomMembership(url, h)
|
||||
|
||||
const muteRoom = () =>
|
||||
publishSettings({muted_rooms: append($room.id, $userSettingsValues.muted_rooms)})
|
||||
|
||||
const unmuteRoom = () =>
|
||||
publishSettings({muted_rooms: remove($room.id, $userSettingsValues.muted_rooms)})
|
||||
|
||||
const join = async () => {
|
||||
joining = true
|
||||
|
||||
@@ -365,43 +336,6 @@
|
||||
{/snippet}
|
||||
{#snippet action()}
|
||||
<div class="row-2">
|
||||
{#if !$hasAlerts}
|
||||
<Link
|
||||
href="/settings/alerts"
|
||||
class="center btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Notifications are disabled">
|
||||
<Icon size={4} icon={VolumeCross} />
|
||||
</Link>
|
||||
{:else if isMuted}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Notifications are turned off"
|
||||
onclick={unmuteRoom}>
|
||||
<Icon size={4} icon={VolumeCross} />
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Notifications are turned on"
|
||||
onclick={muteRoom}>
|
||||
<Icon size={4} icon={VolumeLoud} />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if isFavorite}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left text-secondary"
|
||||
data-tip="Remove Favorite"
|
||||
onclick={removeFavorite}>
|
||||
<Icon size={4} icon={Bookmark} />
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Add Favorite"
|
||||
onclick={addFavorite}>
|
||||
<Icon size={4} icon={Bookmark} />
|
||||
</Button>
|
||||
{/if}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Room information"
|
||||
|
||||
Reference in New Issue
Block a user