Commit Graph

4354 Commits

Author SHA1 Message Date
William Casarin
a0b85129d4 nostrdb: relay: fix race condition bug
Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
e42b14cc6f nostrdb: debug: add a print for debugging rust integration
Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
f0521ba406 nostrdb: relay-index: fix a few bugs
There were a few race conditions and lmdb bugs in the
relay index implementation. Fix those!

Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
c29027ff5b nostrdb: note: always write relay index
This fixes a race condition where if multiple of the same note
is processed at the same time, we still manage to write the
note relays

Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
c6674199de nostrdb: win: fix build on windows 2025-09-24 14:06:03 -07:00
William Casarin
5961bf7958 nostrdb: ndb: add print-relay-kind-index-keys
for debugging

Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
a877a19c25 nostrdb: relay: add note relay iteration
This is a simple cursor that walks the NDB_DB_NOTE_RELAYS db

Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
684701931d nostrdb: Initial relay index implementation
Add relay indexing for existing notes

This patch introduces a relay index for new notes and notes that have
already been stored, allowing the database to track additional relay
sources for a given note.

Changes:

- Added `NDB_WRITER_NOTE_RELAY` to handle relay indexing separately from
  new note ingestion.

- Implemented `ndb_write_note_relay()` and
  `ndb_write_note_relay_kind_index()` to store relay URLs.

- Modified `ndb_ingester_process_event()` to check for existing notes
  and append relay info if necessary.

- Introduced `ndb_note_has_relay()` to prevent duplicate relay entries.

- Updated LMDB schema with `NDB_DB_NOTE_RELAYS` (note_id -> relay) and
  `NDB_DB_NOTE_RELAY_KIND` (relay + kind + created_at -> note).

- Refactored `ndb_process_event()` to use `ndb_ingest_meta` for tracking
  relay sources.

- Ensured proper memory management for relay strings in writer thread.

With this change, nostrdb can better track where notes are seen across
different relays, improving query capabilities for relay-based data
retrieval.

Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
William Casarin
fcd8131063 nostrdb: config: custom writer scratch size
making more things configurable if you have memory constraints

Signed-off-by: William Casarin <jb55@jb55.com>
2025-09-24 14:06:03 -07:00
Daniel D’Aquino
3290e1f9d2 Improve NostrNetworkManager interfaces
This commit improves NostrNetworkManager interfaces to be easier to use,
and with more options on how to read data from the Nostr network

This reduces the amount of duplicate logic in handling streams, and also
prevents possible common mistakes when using the standard subscribe method.

This fixes an issue with the mute list manager (which prompted for this
interface improvement, as the root cause is similar to other similar
issues).

Closes: https://github.com/damus-io/damus/issues/3221
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
2bea2faf3f Add load more content button to the top bar
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
9bcee298d4 Fix forever-loading hashtag view
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
7eb759a8a0 Fix issue with wallet loading
Changelog-Changed: Increased transaction list limit to 50 transactions
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
2550d613b2 Fix test compilation issues
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
9fb7ed741e Fix race condition on app swap that would cause ndb to remain closed
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
d766029f2b Improve loading UX in the home timeline
Changelog-Changed: Improved loading UX in the home timeline
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
4478672c10 Fix occasional stale timeline issue
Changelog-Changed: Added UX hint to make it easier to load new notes
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
c43a37d2d3 Fix forever-loading quote repost view
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
ab22206093 Fix broken Follow Pack timeline
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
de70d19135 Fix NIP-05 timeline crash
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
0f26d50e08 Prevent publishing changes to Observable outside the main thread
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
9709e69dda Fix forever loading Universe view
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
809c8c80ac Fix missing relay list from profile
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
c4c3656f90 Multi-session subscriptions and RelayPool reopening
This commit implements nostr network subscriptions that survive between
sessions, as well as improved handling of RelayPool opening/closing with
respect to the app lifecycle.

This prevents stale data after users swap out and back into Damus.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
46c3667ec3 Update setting on main actor to avoid crashes
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
739a3a0b8c Add more test cases to SubscriptionManager tests
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
ab6ea7a9c1 Fix issue where repost and like counts would not appear
Previously, HomeModel could listen to all subscriptions throughout the
app, and it would handle reaction and repost counting.

Once moved to the local relay model, HomeModel no longer had access to
all subscriptions, causing those counts to disappear.

The issue was fixed by doing the counting from ThreadModel itself, which
better isolates concerns throughout the app.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
9620dcf6ef Fix crash when loading all follows
This commit fixes a crash that caused the app to crash when getting all
the follows from a profile.

This issue was caused by a use-after-free memory error on inherited
transactions after the original transaction is deinitialized.

The issue was fixed by introducing a reference count on all transactions
and only deallocating the C transaction when the ref count goes to zero.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
a5aff15491 Improve task cancellation management in SubscriptionManager
The widespread usage of the SubscriptionManager caused new crashes to
occur when swapping apps.

This was caused due to an access to Ndb memory after Ndb has been closed
from the app background signal.

The issue was fixed with improved task management logic and ensuring all
subscription tasks are finished before closing Ndb.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
76b6d5c545 Update published items on the main actor
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
940b83f5c4 Add ndb subscription tests
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
e113dee95e Publish "loading" variable update on the main thread to avoid undefined behaviour
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
abd797b7b3 Fix another race condition that leads to a memory error
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
8083269709 Switch to local relay model
Changelog-Changed: Switched to the local relay model
Changelog-Added: Notes now load offline
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
5f3ce30826 Fix memory race condition
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
578d47356d Make RelayPool private to NostrNetworkManager and migrate usages
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2025-09-24 14:06:02 -07:00
Daniel D’Aquino
719a0c8cb0 Merge pull request #3209 from damus-io/translations
Translations
2025-08-25 18:53:36 -07:00
89ad22833d Reduce default zap amount and deduplicate from preset zap amount items
Changelog-Changed: Reduced default zap amount and deduplicated from preset zap amount items
Closes: https://github.com/damus-io/damus/issues/3198
Signed-off-by: Terry Yiu <git@tyiu.xyz>
2025-08-25 18:47:14 -07:00
transifex-integration[bot]
9407c75d60 Translate Localizable.strings in de
100% translated source file: 'Localizable.strings'
on 'de'.
2025-08-25 14:43:27 +00:00
transifex-integration[bot]
c4e6e5e6a7 Translate Localizable.strings in ja
100% translated source file: 'Localizable.strings'
on 'ja'.
2025-08-25 00:36:13 +00:00
transifex-integration[bot]
592e9f9405 Translate Localizable.strings in ja
100% translated source file: 'Localizable.strings'
on 'ja'.
2025-08-25 00:36:02 +00:00
transifex-integration[bot]
d924485bb3 Translate InfoPlist.strings in zh_CN
100% translated source file: 'InfoPlist.strings'
on 'zh_CN'.
2025-08-24 13:56:16 +00:00
transifex-integration[bot]
b774f28427 Translate Localizable.strings in th
100% translated source file: 'Localizable.strings'
on 'th'.
2025-08-24 01:22:28 +00:00
transifex-integration[bot]
deae6c0636 Translate Localizable.strings in pt_PT
100% translated source file: 'Localizable.strings'
on 'pt_PT'.
2025-08-23 19:40:14 +00:00
transifex-integration[bot]
da386f3bcd Translate Localizable.strings in nl
100% translated source file: 'Localizable.strings'
on 'nl'.
2025-08-23 17:57:15 +00:00
55dbb46bb5 Export strings for translation
Signed-off-by: Terry Yiu <git@tyiu.xyz>
2025-08-23 11:08:07 -04:00
transifex-integration[bot]
dc8e647c34 Translate Localizable.strings in pt_PT
100% translated source file: 'Localizable.strings'
on 'pt_PT'.
2025-08-23 11:05:14 -04:00
transifex-integration[bot]
eb25ff3584 Translate Localizable.strings in pt_PT
100% translated source file: 'Localizable.strings'
on 'pt_PT'.
2025-08-23 11:05:14 -04:00
transifex-integration[bot]
0ae03fc3f3 Translate Localizable.strings in pt_PT
100% translated source file: 'Localizable.strings'
on 'pt_PT'.
2025-08-23 11:05:14 -04:00
transifex-integration[bot]
e60f74eb9f Translate Localizable.strings in pt_PT
100% translated source file: 'Localizable.strings'
on 'pt_PT'.
2025-08-23 11:05:14 -04:00