-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Persistent Preferences #175
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d00b17
Start on v2 allow state stuff
nakajima 87c1df3
encrypt
nakajima fb6166e
Derive topic identifier instead of using wallet address
nakajima 0618b77
generate the latest proto code
nplasterer dbad2c5
update contacts to use proto code
nplasterer 3e55e80
pull the identifier and keys out to the init
nplasterer 5ffb800
remove proto code that breaks the build
nplasterer 1b9c9a0
bump the pod specs for RN
nplasterer ece91cf
update the topic
nplasterer 815c117
name it preference list and confirm tests still pass
nplasterer 3ecba27
fix the linter issue
nplasterer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,19 @@ public enum Conversation: Sendable { | |
case v1, v2 | ||
} | ||
|
||
public func allowState() async -> AllowState { | ||
let client: Client | ||
|
||
switch self { | ||
case .v1(let conversationV1): | ||
client = conversationV1.client | ||
case .v2(let conversationV2): | ||
client = conversationV2.client | ||
} | ||
|
||
return await client.contacts.allowList.state(address: peerAddress) | ||
} | ||
|
||
public var version: Version { | ||
switch self { | ||
case .v1: | ||
|
@@ -82,7 +95,7 @@ public enum Conversation: Sendable { | |
/// See Conversations.importTopicData() | ||
public func toTopicData() -> Xmtp_KeystoreApi_V1_TopicMap.TopicData { | ||
Xmtp_KeystoreApi_V1_TopicMap.TopicData.with { | ||
$0.createdNs = UInt64(createdAt.timeIntervalSince1970 * 1_000) * 1_000_000 | ||
$0.createdNs = UInt64(createdAt.timeIntervalSince1970 * 1000) * 1_000_000 | ||
$0.peerAddress = peerAddress | ||
if case let .v2(cv2) = self { | ||
$0.invitation = Xmtp_MessageContents_InvitationV1.with { | ||
|
@@ -123,16 +136,16 @@ public enum Conversation: Sendable { | |
} | ||
} | ||
|
||
// This is a convenience for invoking the underlying `client.publish(prepared.envelopes)` | ||
// If a caller has a `Client` handy, they may opt to do that directly instead. | ||
@discardableResult public func send(prepared: PreparedMessage) async throws -> String { | ||
switch self { | ||
case let .v1(conversationV1): | ||
return try await conversationV1.send(prepared: prepared) | ||
case let .v2(conversationV2): | ||
return try await conversationV2.send(prepared: prepared) | ||
} | ||
} | ||
// This is a convenience for invoking the underlying `client.publish(prepared.envelopes)` | ||
// If a caller has a `Client` handy, they may opt to do that directly instead. | ||
@discardableResult public func send(prepared: PreparedMessage) async throws -> String { | ||
switch self { | ||
case let .v1(conversationV1): | ||
return try await conversationV1.send(prepared: prepared) | ||
case let .v2(conversationV2): | ||
return try await conversationV2.send(prepared: prepared) | ||
} | ||
} | ||
|
||
@discardableResult public func send<T>(content: T, options: SendOptions? = nil, fallback _: String? = nil) async throws -> String { | ||
switch self { | ||
|
@@ -199,10 +212,10 @@ public enum Conversation: Sendable { | |
} | ||
|
||
/// List messages in the conversation | ||
public func messages(limit: Int? = nil, before: Date? = nil, after: Date? = nil, direction: PagingInfoSortDirection? = .descending) async throws -> [DecodedMessage] { | ||
public func messages(limit: Int? = nil, before: Date? = nil, after: Date? = nil, direction: PagingInfoSortDirection? = .descending) async throws -> [DecodedMessage] { | ||
switch self { | ||
case let .v1(conversationV1): | ||
return try await conversationV1.messages(limit: limit, before: before, after: after, direction: direction) | ||
return try await conversationV1.messages(limit: limit, before: before, after: after, direction: direction) | ||
case let .v2(conversationV2): | ||
return try await conversationV2.messages(limit: limit, before: before, after: after, direction: direction) | ||
} | ||
Comment on lines
-202
to
221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disregard formatting changes here. |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard formatting changes here.