Skip to content

Presence sync bugfix & Codable support for Broadcast and Presence API #27

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

Merged

Conversation

foodisbeast
Copy link

@foodisbeast foodisbeast commented Aug 2, 2023

What kind of change does this PR introduce?

Bug fix, feature

What is the current behavior?

Presence .diff event is set to wrong ChannelEvent. This prevents registered onSync callbacks from executing.

public static let defaults = Options(events: [
  .state: .presenceState,
  .diff: .presenceState,
])

What is the new behavior?

Fixes .diff event replacing ChannelEvent.presenceState with ChannelEvent.presenceDiff

public static let defaults = Options(events: [
  .state: .presenceState,
  .diff: .presenceDiff,
])

Add alternative Encodable parameterization for Channel broadcast

public func broadcast(event: String, payload: Encodable, encoder: JSONEncoder = Defaults.encoder) throws -> Push

Add alternative Encodable parameterization for Channel Presence track

public func track(payload: Encodable, encoder: JSONEncoder = Defaults.encoder) throws -> Push

@foodisbeast foodisbeast changed the title Presence sync bugfix & Encodable support for Broadcast and Presence API Presence sync bugfix & Codable support for Broadcast and Presence API Aug 2, 2023
@foodisbeast
Copy link
Author

foodisbeast commented Aug 2, 2023

Also added decode functions to Payload extension, and a new type BroadcastPayload. Let me know if you have any suggestions @GRSouza!

Copy link
Contributor

@grdsdev grdsdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor improvement, but LGTM.

@foodisbeast
Copy link
Author

Added new PushStatus enum

public enum PushStatus: RawRepresentable {
    case ok
    case error
    case timeout
    // ...
}

Co-authored-by: Guilherme Souza <[email protected]>
@grdsdev grdsdev merged commit 1d8ba8f into supabase-community:update-upstream Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants