1
0
mirror of git://jb55.com/damus synced 2024-09-16 10:13:45 +00:00
Commit Graph

153 Commits

Author SHA1 Message Date
Daniel D’Aquino
bf43842590 onboarding: Suggest first post during onboarding
Testing of standard flow
------------------------

PASS

Device: iPhone 14 Pro simulator
iOS: 17.0
Damus: This commit
Steps:
1. Delete and reinstall Damus
2. Go through onboarding until suggested users appear
3. Click "continue". Should slide into the post view. PASS
4. Post view should look similar to the Figma design file, but with examples as placeholders. PASS
5. Examples should switch every 3 seconds. PASS
6. Typing a first character causes the #introductions hashtag to be automatically added. PASS
7. Uploading an image makes progress view show up and not break layout. PASS
8. Clicking on "post" should post this note and dismiss onboarding view. PASS

Testing of other flows
----------------------

PASS

Device: iPhone 14 Pro simulator
iOS: 17.0
Damus: This commit
Special remark: Made local change to always show the onboarding suggestions, and speed up testing
Coverage:

1. Clicking "skip" on suggested users view will skip into the post view. PASS
2. Clicking "cancel" on post view and then going to the normal post view reveals a blank draft. PASS
3. Clicking "cancel" dismisses onboarding view and does not post anything. PASS
4. Normal post view looks normal (not broken). PASS
5. Changing initial suggested post during onboarding, cancelling the post, and then re-entering normal post view reveals the draft with user modifications. PASS

Changelog-Added: Suggest first post during onboarding
Closes: https://github.com/damus-io/damus/issues/1338
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-21 08:42:00 +08:00
Daniel D’Aquino
3b76fcb743 test: Add basic snapshot test coverage for EventView
This commit adds a basic snapshot test for EventView, and also adds some testing infrastructure to help with mocking NostrDB behavior.

Test
----

PASS

Device: iOS 17.0 Simulator
iOS: 17.0
Damus: This commit
Steps: Run `EventViewTests`
Results: Snapshot matches baseline reference added
2023-10-16 03:13:28 +02:00
Daniel D’Aquino
7bed47c919 test: Setup Snapshot testing library and add a snapshot test (testTextWrapperViewWillWrapText)
This change adds `https://github.com/pointfreeco/swift-snapshot-testing` as a package dependency and links it to the `damusTests` target.
It also adds one snapshot test to demonstrate its usefulness, by adding coverage to one particular aspect that we have never been able to test before: Whether or not the post text editor will wrap the text once the text gets long.

Testing of the test
-------------------

PASS

iOS: 17.0
Device: Simulator
Damus: This commit
Test steps:

1. Run `testTextWrapperViewWillWrapText`. PASS
2. Change TextViewWrapper.swift and remove this line:
```
textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
```
3. Rerun. It fails. PASS (This is expected)

Closes: https://github.com/damus-io/damus/issues/1562
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-10 22:05:45 -07:00
Daniel D’Aquino
7744787c51 storage: Improve clear cache functionality
This patch improves clear cache functionality by:
- Reducing kingfisher cache removal to one command (The two commands running async was leading to warning logs. One was a subset of the other)
- Removing all files under the cache folder where not currently used by other processes

Full Functionality test
-----------------------

PASS

Device: iPhone 13 mini (Physical device)
iOS: 17.0.3
Damus: This commit
Special remarks:
- I had to locally delete other unit tests to be able to build the test target
- Unit test run on an earlier version of the patch. Test coverage should still apply since this newer patch is a subset of the previous.

Setup: Run Damus with debugger connection to Xcode

Test steps:

1. Follow multiple active accounts (Skip if local Damus is already filled up with GBs of data)
2. Scroll down on the feed for a couple of minutes (or until you have seen at least a few images, a few videos, and link previews) (Skip if local Damus is filled up with GBs of data)
3. In Xcode, download a storage container (Window > Devices and Simulators > Select the device > Select Damus > click on (...) > Download container)
    - Note: Even though you see the file, it does not download instantly. Monitor the file size until it roughly reaches the size reported in iOS storage settings, as the download may still be in progress. This may take a few minutes in some cases.
    - Also take note of storage usage in iOS settings
4. Open the app data package using terminal
5. Run `du -h . | sort -hr`
6. Clear cache and check logs. Logs should indicate the caches being cleared, and there should be no storage-related warning/error logs. PASS
7. Download a new storage container. Remember to wait until it completes download.
8. Run `du -h . | sort -hr` on it.
9. Compare. There should be much less data. Also check iOS settings storage usage. PASS
10. Go back to the home feed and start scrolling, browsing, follow some other people, etc. Look at your own profile as well. Everything should appear to be working as expected with no crashes or important data loss
11. Check bookmarks are still present. PASS
12. Run `DamusCacheManagerTests`. Should pass. PASS* (*See special remarks)

Results:
- Storage usage goes from 3.9GB to 394.7MB
- Damus works as normal after clearing cache, and after restarting the app as well. It becomes slower for a moment, but after a bit it loads as normal again.
- No warning or error logs pertaining to clearing cache
- Unit test passes

My storage container disk usage stats after clearing cache:
```
% du -h | sort -hr
359M	./AppData
359M	.
336M	./AppData/Documents
 23M	./AppData/Library
 20M	./AppData/Library/Caches
7.9M	./AppData/Library/Caches/com.jb55.damus2
2.4M	./AppData/Library/SplashBoard/Snapshots
2.4M	./AppData/Library/SplashBoard
1.8M	./AppData/Library/SplashBoard/Snapshots/com.jb55.damus2 - {DEFAULT GROUP}
1.6M	./AppData/Library/Caches/com.jb55.damus2/fsCachedData
636K	./AppData/Library/SplashBoard/Snapshots/sceneID:com.jb55.damus2-ecc156b1-eb9c-4439-b219-e1eebf2b4c36
596K	./AppData/Library/Caches/com.apple.WebKit.GPU/com.apple.metal
596K	./AppData/Library/Caches/com.apple.WebKit.GPU
452K	./AppData/Library/Caches/com.jb55.damus2/com.apple.metal
296K	./AppData/Library/SplashBoard/Snapshots/sceneID:com.jb55.damus2-ecc156b1-eb9c-4439-b219-e1eebf2b4c36/downscaled
224K	./AppData/Library/HTTPStorages/com.jb55.damus2
224K	./AppData/Library/HTTPStorages
164K	./AppData/Library/Caches/com.onevcat.Kingfisher.ImageCache.default
156K	./AppData/Library/Caches/RelayLogs
112K	./AppData/Library/Caches/com.apple.dyld
 92K	./AppData/Library/Preferences
 60K	./AppData/Library/Caches/com.jb55.damus2/com.apple.metal/archiveUsage.db
 12K	./AppData/Library/Saved Application State/com.jb55.damus2.savedState
 12K	./AppData/Library/Saved Application State
8.0K	./AppData/StoreKit
8.0K	./AppData/Library/Saved Application State/com.jb55.damus2.savedState/ecc156b1-eb9c-4439-b219-e1eebf2b4c36
4.0K	./AppData/Library/Saved Application State/com.jb55.damus2.savedState/KnownSceneSessions
4.0K	./AppData/Library/LanguageModeling/en-dynamic.lm
4.0K	./AppData/Library/LanguageModeling
4.0K	./AppData/Library/Cookies
  0B	./AppData/SystemData/com.apple.SafariViewService/Library/WebKit/WebsiteData
  0B	./AppData/SystemData/com.apple.SafariViewService/Library/WebKit
  0B	./AppData/SystemData/com.apple.SafariViewService/Library
  0B	./AppData/SystemData/com.apple.SafariViewService
```

Biggest storage used remaining is in the Documents folder where NostrDB is stored. However, we do not want to clear NostrDB, so this is expected behavior.

Changelog-Changed: Improve clear cache functionality
Closes: https://github.com/damus-io/damus/issues/1472
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-07 16:42:08 -07:00
Daniel D’Aquino
0f9e87cb37 test: temporarily disable UserCacheManagerTests
Resolves build errors on the test target while we work on #1586

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-10-07 14:35:24 -07:00
William Casarin
69c7acea76 tests: add ndb support to tests
stops it from crashing
2023-09-21 09:10:06 -04:00
William Casarin
bb4fd75576 nostrdb: add profiles to nostrdb
This adds profiles to nostrdb

- Remove in-memory Profiles caches, nostrdb is as fast as an in-memory cache
- Remove ProfileDatabase and just use nostrdb directly

Changelog-Changed: Use nostrdb for profiles
2023-09-21 09:10:06 -04:00
Jon Marrs
aa4ecc2139 test: add test cases for ASCII and UTF-8 characters in hashtags
Closes: https://github.com/damus-io/damus/pull/1546
Signed-off-by: William Casarin <jb55@jb55.com>
2023-09-15 12:31:17 -05:00
Daniel D’Aquino
b1e0a62109 nwc: fix parsing issue with NIP-47 compliant NWC urls without double-slashes
Closes: https://github.com/damus-io/damus/issues/1547
Changelog-Fixed: Fix parsing issue with NIP-47 compliant NWC urls without double-slashes
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-09-13 12:59:21 -06:00
Jericho Hasselbush
8dad8e6703 posting: fix issue with username and multiple emojis
Fixes issue where username with multiple emojis would place cursor in
strange position. Now properly moves the cursor to space past the
multiple emoji user name.

Any amount would be great. Not a complex issue to fix!

Tipjar: lnbc1pj0eddtpp5km07jgrfm47nfswqqp33ngv374gzad2hshkra7zm3l0cmpusnp3qdqqcqzzsxqyz5vqsp5rklkzj9upf32z3c3nmc9xg4pdlz5p5mp3s332ygefexf79tq8ucs9qyyssqxfh4kz3sg9zczsnj49w23aw35z87jwyx9m5su8kkyxlspyjk4ajy7vhxuw2rzw4lz8vfutfakm2rggvpzhzs9ehfus4nl683dl99f4sqgm9zkq
Changelog-Fixed: Fixes issue where username with multiple emojis would place cursor in strange position.
Signed-off-by: Jericho Hasselbush <jericho@sal-et-lucem.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-09-11 07:48:36 -07:00
Grimless
f6f7d13f12 Properly implement top-level tests and fix one test using the wrong Block conversion property
Closes: https://github.com/damus-io/damus/pull/1528
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-09-03 18:02:32 -07:00
Grimless
6ee0be40e9 Create helper extensions for Block and update tests for the Block helper model
Closes: https://github.com/damus-io/damus/pull/1528
Signed-off-by: William Casarin <jb55@jb55.com>
2023-09-03 18:02:32 -07:00
Jon Marrs
dd29e87146 test: pass keypair instead of privkey for test cases
Tests were not building due to recent changes in the Damus source code that replaced privkey with keypair. This patch extends those changes to the test cases, allowing the tests to build and pass.

Signed-off-by: Jon Marrs <jdmarrs@gmail.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-08-31 08:52:28 -07:00
William Casarin
f30f93f65c Revert "Move the Block helper type to its own file"
This fixes the broken tests

This reverts commit 286ae68fd6.
2023-08-25 19:05:34 -07:00
Daniel D’Aquino
dcb94635ea Fix text editing issues on characters added right after mention link
Changelog-Fixed: Fix text editing issues on characters added right after mention link
Closes: https://github.com/damus-io/damus/issues/1375
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Tested-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-08-20 17:25:06 -07:00
Daniel D‘Aquino
066b3cdde8 Fix image links appearing with escaped slashes
Changelog-Fixed: Fix images and links occasionally appearing with escaped slashes
Closes: https://github.com/damus-io/damus/issues/1468
Signed-off-by: Daniel D‘Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
Rewarded-sats: 50000
2023-08-18 08:41:21 -07:00
William Casarin
9e6fbeefcd url: smartparens hack
support urls like (https://jb55.com/something)
2023-08-06 14:16:43 -07:00
Joel Klabo
85930df8e3 tests: add url parens tests 2023-08-06 13:51:39 -07:00
William Casarin
cf3a9a576d test: move existing url tests to UrlTests 2023-08-06 13:50:20 -07:00
William Casarin
1a2ac976a3 Fix old notifications always appearing on first start
Revert "home: debounce last notified"

This is technically incorrect, as debouncing can prevent saving
important events.

The proper way to do this is to save it locally in memory, and then
debouncing the saving itself. Will do this soon.

Reverts: a9b4cfd424
Fixes: https://github.com/damus-io/damus/issues/1439
Changelog-Fixed: Fixed old notifications always appearing on first start
2023-08-06 09:22:28 -07:00
William Casarin
d4faacb99f relays: strip trailing / from relay urls
Fixes: https://github.com/damus-io/damus/issues/1443
Changelog-Fixed: Fix issue with slashes on relay urls causing relay connection problems
2023-08-06 09:07:33 -07:00
William Casarin
d489bcc586 test: add test for failing nostr report event 2023-08-06 06:56:24 -07:00
William Casarin
cebd1f48ca ndb: switch to nostrdb notes
This is a refactor of the codebase to use a more memory-efficient
representation of notes. It should also be much faster at decoding since
we're using a custom C json parser now.

Changelog-Changed: Improved memory usage and performance when processing events
2023-08-03 13:20:36 -07:00
William Casarin
55bbe8f855 disable nostrscript test for now 2023-08-03 13:15:32 -07:00
Daniel D‘Aquino
ef5a3030a6 Add unit tests surrounding creation of posts with non-latin hashtags, as well as the rendering of non-latin hashtag
Signed-off-by: Daniel D‘Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-08-03 12:17:32 -07:00
Daniel D‘Aquino
72b60573de Fix compilation error on test target in UserSearchCacheTests
Changelog-Fixed: Fix compilation error on test target in UserSearchCacheTests
Signed-off-by: Daniel D‘Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-08-03 12:17:32 -07:00
William Casarin
88306d00a3 key: generate a FullKeypair when generating new keys 2023-08-01 21:53:19 -07:00
William Casarin
a9b4cfd424 home: debounce last notified
Calling UserDefaults fast in a loop is not good
2023-07-31 05:38:19 -07:00
William Casarin
7040235605 refactor: add Pubkey, Privkey, NoteId string aliases
This is a non-behavioral change in preparation for the actual switchover
from Strings to Ids. The purpose of this kit is to reduce the size of
the switchover commit which is going to be very large.
2023-07-31 05:38:19 -07:00
William Casarin
f9d21ef901 test: rename test_event to test_note 2023-07-31 05:38:19 -07:00
William Casarin
2f8aa29e92 ndb: make NostrEvents immutable
Since we can't mutate NdbNotes, let's update the existing codebase to
generate and sign ids on NostrEvent constructions. This will allow us to
match NdbNote's constructor
2023-07-25 15:34:05 -07:00
William Casarin
e3c04465fc ndb: move to uint32 for kind and created_at 2023-07-25 15:24:26 -07:00
William Casarin
b3c87bdc07 test: remove unused var 2023-07-24 12:40:04 -07:00
William Casarin
1a33d639ed test: remove some unused perf tests 2023-07-23 11:54:58 -07:00
William Casarin
6d43754e71 ndb: add pubkey to NdbNote 2023-07-22 17:19:47 -07:00
William Casarin
ad0e1f28b7 test: fix build and tests 2023-07-21 15:26:03 -07:00
William Casarin
61051ee853 nostrdb: add initial swift integration 2023-07-21 15:02:01 -07:00
William Casarin
11b9062865 test: fix some warnings 2023-07-19 10:04:25 -07:00
William Casarin
ff70cb7ebf posting: don't prepad user tag if its a newline
This fixes one more edgecase with the tag prepend logic.
2023-07-17 10:45:05 -07:00
William Casarin
60a0c21272 test: add post composition tests
This adds post composition tests so that we can avoid composition bugs.
This still does not capture all of the dynamics of post composition,
because it ignores much of the mutable cursor position and related state
when editing posts.

We will need to make post editing more pure and less mutable in the
future to get test coverage on those.
2023-07-17 10:25:09 -07:00
William Casarin
ff654c4e11 test: add text attribute testing function
This will be used for testing attributed strings
2023-07-17 10:25:09 -07:00
William Casarin
fd59407171 test: fix old markdown tests 2023-07-17 10:25:09 -07:00
William Casarin
1135c19fea test: add setting property tests
Some initial UserSettingsStore property tests
2023-07-16 13:05:18 -07:00
William Casarin
8d14fdffb5 content: add utf8 char at url left boundary test 2023-07-16 11:46:23 -07:00
William Casarin
0c95071de7 project: rename parse_mentions to parse_note_content
This is more accurate
2023-07-16 11:46:23 -07:00
William Casarin
139be9eef2 Fix nostr: mention prefix bugs
The zero-width space was causing parsing issues. Not sure why we need
this so I just removed it.

Changelog-Fixed: Fix nostr:nostr:... bugs
2023-07-14 17:28:24 -07:00
Terry Yiu
8a9e3ea76b Fix localization issues and export strings for translation
Changelog-Fixed: Fix localization issues and export strings for translation
Signed-off-by: Terry Yiu <git@tyiu.xyz>
Signed-off-by: William Casarin <jb55@jb55.com>
2023-07-14 09:34:29 -07:00
William Casarin
7fc270725f test: add newline mention test
This is currently passing but it shouldn't be. This is because we are
not testing the build_post function directly. We will do this soon.
2023-07-13 07:32:27 -07:00
William Casarin
db2ec0a00a Fix npub mention bugs, fix slowness when parsing large posts
Switch the post parser to use the same code as the content parser. This
was causing many issues, including performance issues.

Changelog-Fixed: Fix lag when creating large posts
Changelog-Fixed: Fix npub mentions failing to parse in some cases
Changelog-Added: Add r tag when mentioning a url
Changelog-Removed: Remove old @ and & hex key mentions
2023-07-11 09:15:13 -07:00
William Casarin
031c7823ae refactor: move hashtag tests to their own file 2023-07-11 07:21:16 -07:00