Fix onboarding crash
This commit fixes a crash that occurred when clicking "follow all" during onboarding. This fix works by making `Contacts` and `PostBox` isolated into a specific Swift Actor, and updating direct and indirect usages accordingly. Changelog-Fixed: Fixed a crash that occurred when clicking "follow all" during onboarding. Closes: https://github.com/damus-io/damus/issues/3422 Co-authored-by: alltheseas <64376233+alltheseas@users.noreply.github.com> Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -344,6 +344,7 @@ class NoteContentViewTests: XCTestCase {
|
||||
|
||||
/// Quick test that exercises the direct parsing methods (i.e. not fetching blocks from nostrdb) from `NdbBlockGroup`, and its bridging code with C.
|
||||
/// The parsing logic itself already has test coverage at the nostrdb level.
|
||||
@MainActor
|
||||
func testDirectBlockParsing() {
|
||||
let kp = test_keypair_full
|
||||
let dm: NdbNote = NIP04.create_dm("Test", to_pk: kp.pubkey, tags: [], keypair: kp.to_keypair())!
|
||||
@@ -360,24 +361,28 @@ class NoteContentViewTests: XCTestCase {
|
||||
})
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Pubkey_ContainsAbbreviated() throws {
|
||||
let compatibleText = createCompatibleText(test_pubkey.npub)
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "17ldvg64:nq5mhr77")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Pubkey_ContainsFullBech32() {
|
||||
let compatableText = createCompatibleText(test_pubkey.npub)
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatableText, expected: test_pubkey.npub)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Nprofile_ContainsAbbreviated() throws {
|
||||
let compatibleText = createCompatibleText("nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p")
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "180cvv07:wsyjh6w6")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Nprofile_ContainsFullBech32() throws {
|
||||
let bech = "nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p"
|
||||
let compatibleText = createCompatibleText(bech)
|
||||
@@ -385,18 +390,21 @@ class NoteContentViewTests: XCTestCase {
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: bech)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Note_ContainsAbbreviated() {
|
||||
let compatibleText = createCompatibleText(test_note.id.bech32)
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "note1qqq:qqn2l0z3")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Note_ContainsFullBech32() {
|
||||
let compatibleText = createCompatibleText(test_note.id.bech32)
|
||||
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: test_note.id.bech32)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Nevent_ContainsAbbreviated() {
|
||||
let bech = "nevent1qqstna2yrezu5wghjvswqqculvvwxsrcvu7uc0f78gan4xqhvz49d9spr3mhxue69uhkummnw3ez6un9d3shjtn4de6x2argwghx6egpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5nxnepm"
|
||||
let compatibleText = createCompatibleText(bech)
|
||||
@@ -404,6 +412,7 @@ class NoteContentViewTests: XCTestCase {
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "nevent1q:t5nxnepm")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Nevent_ContainsFullBech32() throws {
|
||||
let bech = "nevent1qqstna2yrezu5wghjvswqqculvvwxsrcvu7uc0f78gan4xqhvz49d9spr3mhxue69uhkummnw3ez6un9d3shjtn4de6x2argwghx6egpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5nxnepm"
|
||||
let compatibleText = createCompatibleText(bech)
|
||||
@@ -411,6 +420,7 @@ class NoteContentViewTests: XCTestCase {
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: bech)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Naddr_ContainsAbbreviated() {
|
||||
let bech = "naddr1qqxnzdesxqmnxvpexqunzvpcqyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypve7elhmamff3sr5mgxxms4a0rppkmhmn7504h96pfcdkpplvl2jqcyqqq823cnmhuld"
|
||||
let compatibleText = createCompatibleText(bech)
|
||||
@@ -418,6 +428,7 @@ class NoteContentViewTests: XCTestCase {
|
||||
assertCompatibleTextHasExpectedString(compatibleText: compatibleText, expected: "naddr1qq:3cnmhuld")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testMentionStr_Naddr_ContainsFullBech32() {
|
||||
let bech = "naddr1qqxnzdesxqmnxvpexqunzvpcqyt8wumn8ghj7un9d3shjtnwdaehgu3wvfskueqzypve7elhmamff3sr5mgxxms4a0rppkmhmn7504h96pfcdkpplvl2jqcyqqq823cnmhuld"
|
||||
let compatibleText = createCompatibleText(bech)
|
||||
@@ -436,6 +447,7 @@ private func assertCompatibleTextHasExpectedString(compatibleText: CompatibleTex
|
||||
XCTAssertTrue(hasExpected)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func createCompatibleText(_ bechString: String) -> CompatibleText {
|
||||
guard let mentionRef = Bech32Object.parse(bechString)?.toMentionRef() else {
|
||||
XCTFail("Failed to create MentionRef from Bech32 string")
|
||||
|
||||
Reference in New Issue
Block a user