mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-07 11:19:58 +02:00
feat(apple): send a transfer to a device from the share panel
Send to a device now sits alongside the QR code, NFC, and export actions, since an offer is another way to deliver the same invitation. Picking a device pushes the existing transfer rather than re-sharing the files. The picker lists only devices holding a live grant, so nothing offered there can fail on tap, and it distinguishes accepted from waiting for that device to open the app. Also fixes the deprecated SF Symbol and the two Sendable warnings introduced with the contacts screen: the sections now talk to the model directly rather than storing view callbacks that a Binding setter has to convert.
This commit is contained in:
@@ -374,6 +374,46 @@ final class ContactsModelTests: XCTestCase {
|
||||
XCTAssertEqual(model.state.heldOffers.map(\.offerId), ["held-1"])
|
||||
}
|
||||
|
||||
/// Offering an existing transfer reuses it rather than creating another.
|
||||
func testOfferingAnExistingTransferReportsAcceptance() async {
|
||||
let gateway = FakeCoreGateway()
|
||||
gateway.offerTransferResult = .success(
|
||||
ContactSendOutcome(
|
||||
share: Share(
|
||||
transferId: 7, ticket: "vnd1:x", transferName: "doc",
|
||||
contentHash: "h", fileCount: 1, totalSize: 2
|
||||
),
|
||||
delivered: true
|
||||
)
|
||||
)
|
||||
let (model, _) = makeModel(gateway)
|
||||
|
||||
let delivered = await model.offerTransfer(transferId: 7, to: contact("peer"))
|
||||
|
||||
XCTAssertTrue(delivered)
|
||||
XCTAssertEqual(gateway.offeredTransfers.map(\.transferId), [7])
|
||||
XCTAssertEqual(gateway.offeredTransfers.map(\.endpointId), ["peer"])
|
||||
}
|
||||
|
||||
/// An offer to a closed device is reported as waiting, not accepted.
|
||||
func testOfferingToAClosedDeviceReportsItAsWaiting() async {
|
||||
let gateway = FakeCoreGateway()
|
||||
gateway.offerTransferResult = .success(
|
||||
ContactSendOutcome(
|
||||
share: Share(
|
||||
transferId: 7, ticket: "vnd1:x", transferName: "doc",
|
||||
contentHash: "h", fileCount: 1, totalSize: 2
|
||||
),
|
||||
delivered: false
|
||||
)
|
||||
)
|
||||
let (model, _) = makeModel(gateway)
|
||||
|
||||
let delivered = await model.offerTransfer(transferId: 7, to: contact("peer"))
|
||||
|
||||
XCTAssertFalse(delivered)
|
||||
}
|
||||
|
||||
func testUnreachableContactIsSurfacedForRepairing() async {
|
||||
let gateway = FakeCoreGateway()
|
||||
gateway.contactsResult = .success([contact("peer", canSend: false)])
|
||||
|
||||
Reference in New Issue
Block a user