Compare commits

...

4 Commits

Author SHA1 Message Date
sakshamjain dcf332fbe4 Merge remote-tracking branch 'upstream/dev' into feat/space-invite-share 2026-04-14 23:24:17 +05:30
sakshamjain 9fa1375435 fix: handle unsupported Share API gracefully 2026-04-14 23:05:49 +05:30
bhavishy2801 132c7f031b fix: remove deleted rooms from space navigation after refresh
## Summary

This PR fixes a bug where deleting a room succeeded on the relay, but the room could still appear in space navigation (including after refresh).

Fixes #194.

## Root Cause

Room list derivation did not consistently treat delete events as authoritative in edge cases:
- Delete timestamp aggregation could involve an undefined prior value.
- Room meta events with the same second-level timestamp as a delete event were still considered active.

## Changes

- Updated room delete timestamp aggregation logic to handle first delete event safely.
- Updated room filtering condition so a room is excluded when its meta timestamp is less than or equal to the delete timestamp.
- This ensures deleted rooms are not shown in navigation immediately or after reload.

## Validation

- `pnpm run check` passed.
- `pnpm run lint` passed.

## Testing

- [x] In a NIP-29 space, create a temporary room.
- [x] Delete the room from room details.
- [x] Confirm it disappears from navigation immediately.
- [x] Hard refresh and confirm it does not reappear.
- [x] Reopen app/session and confirm it remains absent.
- [x] Repeat by creating/deleting another room quickly (same-minute timestamp edge case).
2026-04-14 15:43:49 +00:00
sakshamjain cdeb7afcae feat: add native share support for space invites 2026-04-14 19:27:23 +05:30
5 changed files with 73 additions and 10 deletions
+1
View File
@@ -55,6 +55,7 @@
"@capacitor/keyboard": "^8.0.0",
"@capacitor/preferences": "^8.0.0",
"@capacitor/push-notifications": "^8.0.0",
"@capacitor/share": "^8.0.1",
"@capawesome/capacitor-android-dark-mode-support": "^8.0.0",
"@capawesome/capacitor-badge": "^8.0.0",
"@getalby/lightning-tools": "^6.1.0",
+12
View File
@@ -47,6 +47,9 @@ importers:
'@capacitor/push-notifications':
specifier: ^8.0.0
version: 8.0.0(@capacitor/core@8.0.1)
'@capacitor/share':
specifier: ^8.0.1
version: 8.0.1(@capacitor/core@8.0.1)
'@capawesome/capacitor-android-dark-mode-support':
specifier: ^8.0.0
version: 8.0.0(@capacitor/core@8.0.1)
@@ -838,6 +841,11 @@ packages:
peerDependencies:
'@capacitor/core': '>=8.0.0'
'@capacitor/share@8.0.1':
resolution: {integrity: sha512-3cSBKBCJVon54rKDROP2rqGyeGks4pBh9TbaEk9S375Kbek/ZHe72N50zIa0Vn9Eac/SuhwgehO/mmA4CsUOiw==}
peerDependencies:
'@capacitor/core': '>=8.0.0'
'@capacitor/synapse@1.0.4':
resolution: {integrity: sha512-/C1FUo8/OkKuAT4nCIu/34ny9siNHr9qtFezu4kxm6GY1wNFxrCFWjfYx5C1tUhVGz3fxBABegupkpjXvjCHrw==}
@@ -6021,6 +6029,10 @@ snapshots:
dependencies:
'@capacitor/core': 8.0.1
'@capacitor/share@8.0.1(@capacitor/core@8.0.1)':
dependencies:
'@capacitor/core': 8.0.1
'@capacitor/synapse@1.0.4': {}
'@capawesome/capacitor-android-dark-mode-support@8.0.0(@capacitor/core@8.0.1)':
+48 -8
View File
@@ -3,7 +3,9 @@
import {sleep} from "@welshman/lib"
import {request} from "@welshman/net"
import {displayRelayUrl, getTagValue, RELAY_INVITE} from "@welshman/util"
import {Share} from "@capacitor/share"
import LinkRound from "@assets/icons/link-round.svg?dataurl"
import NativeShare from "@assets/icons/native-share.svg?dataurl"
import Copy from "@assets/icons/copy.svg?dataurl"
import Spinner from "@lib/components/Spinner.svelte"
import Field from "@lib/components/Field.svelte"
@@ -28,6 +30,17 @@
const copyInvite = () => clip(invite)
const shareInvite = async () => {
if (!canShare) return
try {
await Share.share({url: invite})
} catch (e) {
console.error(e)
}
}
let canShare = $state(false)
let claim = $state("")
let loading = $state(true)
@@ -41,6 +54,13 @@
})
onMount(async () => {
try {
const {value} = await Share.canShare()
canShare = value
} catch {
canShare = false
}
const [[event]] = await Promise.all([
request({
relays: [url],
@@ -74,17 +94,37 @@
<p class="center">Oops! It looks like you're not a member of this relay.</p>
{:else}
<div class="flex flex-col items-center gap-6">
<QRCode code={invite} />
<div class="w-48">
<QRCode code={invite} />
</div>
<Field>
{#snippet input()}
<label class="input input-bordered flex w-full items-center gap-2">
<Icon icon={LinkRound} />
<input bind:value={invite} class="grow" type="text" />
<Button onclick={copyInvite}>
<Icon icon={Copy} />
</Button>
</label>
<div class="flex w-full gap-2">
{#if canShare}
<Button
class="input input-bordered flex shrink-0 w-12 items-center justify-center p-0"
onclick={shareInvite}
>
<Icon icon={NativeShare} />
</Button>
{/if}
<label class="input input-bordered flex min-w-0 flex-1 items-center gap-2">
<Icon icon={LinkRound} class="shrink-0" />
<input
bind:value={invite}
class="min-w-0 flex-1 truncate"
type="text"
readonly
/>
<Button class="shrink-0" onclick={copyInvite}>
<Icon icon={Copy} />
</Button>
</label>
</div>
{/snippet}
{#snippet info()}
<p>
This invite link can be used by clicking "Add Space" and pasting it there.
+8 -2
View File
@@ -615,7 +615,12 @@ export const roomsByUrl = derived(roomMetaEventsByIdByUrl, roomMetaEventsByIdByU
for (const event of deleteEvents) {
for (const h of getTagValues("h", event.tags)) {
deletedByH.set(h, max([deletedByH.get(h), event.created_at]))
const deletedAt = deletedByH.get(h)
deletedByH.set(
h,
deletedAt === undefined ? event.created_at : max([deletedAt, event.created_at]),
)
}
}
@@ -623,8 +628,9 @@ export const roomsByUrl = derived(roomMetaEventsByIdByUrl, roomMetaEventsByIdByU
for (const event of metaEvents) {
const meta = tryCatch(() => readRoomMeta(event))
const deletedAt = meta ? deletedByH.get(meta.h) : undefined
if (!meta || gt(deletedByH.get(meta.h), meta.event.created_at)) {
if (!meta || (deletedAt !== undefined && !gt(meta.event.created_at, deletedAt))) {
continue
}
+4
View File
@@ -0,0 +1,4 @@
<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.17933 3.72734L7.41899 1.39855V9.76536C7.41899 10.0954 7.67913 10.3425 7.97911 10.3425C8.29941 10.3425 8.53924 10.0745 8.53924 9.76536V1.41957L10.7789 3.72734C10.8992 3.8513 11.039 3.89235 11.1789 3.89235C11.3187 3.89235 11.4789 3.83037 11.5788 3.72734C11.7992 3.50033 11.7992 3.13007 11.5788 2.88213L9.35938 0.574361C8.69927 -0.187929 7.37983 -0.187929 6.63916 0.553433L4.3791 2.90303C4.15879 3.13003 4.15879 3.5003 4.3791 3.74824C4.5994 3.97444 4.95952 3.97444 5.17905 3.72731L5.17933 3.72734Z" fill="#A6ADBB"/>
<path d="M13.8789 4.61365H11.2197C10.8994 4.61365 10.6596 4.8817 10.6596 5.19081C10.6596 5.49991 10.9197 5.76796 11.2197 5.76796H13.8797C14.4195 5.76796 14.8593 6.22115 14.8593 6.77737V12.7944C14.8593 13.3506 14.4195 13.8038 13.8797 13.8038L2.12025 13.8046C1.58044 13.8046 1.14063 13.3514 1.14063 12.7952L1.13985 6.79816C1.13985 6.24194 1.56014 5.78876 2.11947 5.78876H4.7795C5.0998 5.78876 5.33963 5.5207 5.33963 5.2116C5.33963 4.90169 5.0998 4.61353 4.7795 4.61353H2.12027C0.939881 4.61353 0 5.56177 0 6.79827V12.8153C0 14.0307 0.939781 15 2.12027 15H13.8797C15.0593 15 16 14.0317 16 12.8153L15.9992 6.79827C15.9992 5.56185 15.0594 4.61365 13.8789 4.61365Z" fill="#A6ADBB"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB