-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add EventType to Realtime Message * refactor: rename Message to RealtimeMessage * feat: add callback manager * feat: implement onMessage handler * refactor realtime based on Kotlin library * wip * Fix Realtime connection * Add Sendable conformances and make classes thread safe * Rename v2 types * Fix Realtime tests * Fix leaks * add _Presence type * block task until subscribed * wip * Make Realtime and Channel Actors * wip slack clone example * Fix tests * Rename Realtime to RealtimeClientV2 * fix: pending heartbeat check * Remove AuthTokenProvider * wip * Remove Combine * Remove OSLog as it doesn't support non-Apple platform * Import FoundationNetworking * Integrate SupabaseLogger * Fix Realtime access token and improve slack clone example * wip * Test * test: realtime connect and subscribe * Import Dispatch * Remove NSEC_PER_SEC since non-Darwin don't have it * Trying to fix build on Linux * ci: use Xcode 15.2 * Comment out failing test * Add local supabase instance for SlackClone * Add visionOS support for SlackClone example * Add migration guide
- Loading branch information
Showing
67 changed files
with
4,358 additions
and
527 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Use an official Swift runtime as a base image | ||
FROM swift:latest | ||
|
||
# Set the working directory to /app | ||
WORKDIR /app | ||
|
||
# Copy the entire content of the local directory to the container | ||
COPY . . | ||
|
||
# Build the Swift package | ||
RUN swift build | ||
|
||
# Run tests | ||
CMD ["swift", "test"] | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
Examples/Examples.xcodeproj/xcshareddata/xcschemes/SlackClone.xcscheme
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1520" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "79D884C62B3C18830009EA4A" | ||
BuildableName = "SlackClone.app" | ||
BlueprintName = "SlackClone" | ||
ReferencedContainer = "container:Examples.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "79D884C62B3C18830009EA4A" | ||
BuildableName = "SlackClone.app" | ||
BlueprintName = "SlackClone" | ||
ReferencedContainer = "container:Examples.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "79D884C62B3C18830009EA4A" | ||
BuildableName = "SlackClone.app" | ||
BlueprintName = "SlackClone" | ||
ReferencedContainer = "container:Examples.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// AppView.swift | ||
// SlackClone | ||
// | ||
// Created by Guilherme Souza on 27/12/23. | ||
// | ||
|
||
import Supabase | ||
import SwiftUI | ||
|
||
@Observable | ||
@MainActor | ||
final class AppViewModel { | ||
var session: Session? | ||
var selectedChannel: Channel? | ||
|
||
init() { | ||
Task { [weak self] in | ||
for await (event, session) in await supabase.auth.authStateChanges { | ||
guard [.signedIn, .signedOut, .initialSession].contains(event) else { return } | ||
self?.session = session | ||
|
||
if session == nil { | ||
for subscription in await supabase.realtimeV2.subscriptions.values { | ||
await subscription.unsubscribe() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@MainActor | ||
struct AppView: View { | ||
@Bindable var model: AppViewModel | ||
|
||
@ViewBuilder | ||
var body: some View { | ||
if model.session != nil { | ||
NavigationSplitView { | ||
ChannelListView(channel: $model.selectedChannel) | ||
} detail: { | ||
if let channel = model.selectedChannel { | ||
MessagesView(channel: channel).id(channel.id) | ||
} | ||
} | ||
} else { | ||
AuthView() | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
AppView(model: AppViewModel()) | ||
} |
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
...xcassets/AppIcon.appiconset/Contents.json → ...xcassets/AppIcon.appiconset/Contents.json
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// AuthView.swift | ||
// SlackClone | ||
// | ||
// Created by Guilherme Souza on 27/12/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@Observable | ||
@MainActor | ||
final class AuthViewModel { | ||
var email = "" | ||
var toast: ToastState? | ||
|
||
func signInButtonTapped() { | ||
Task { | ||
do { | ||
try await supabase.auth.signInWithOTP( | ||
email: email, | ||
redirectTo: URL(string: "slackclone://sign-in") | ||
) | ||
toast = ToastState(status: .success, title: "Check your inbox.") | ||
} catch { | ||
toast = ToastState(status: .error, title: "Error", description: error.localizedDescription) | ||
} | ||
} | ||
} | ||
|
||
func handle(_ url: URL) { | ||
Task { | ||
do { | ||
try await supabase.auth.session(from: url) | ||
} catch { | ||
toast = ToastState(status: .error, title: "Error", description: error.localizedDescription) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@MainActor | ||
struct AuthView: View { | ||
@Bindable var model = AuthViewModel() | ||
|
||
var body: some View { | ||
VStack { | ||
VStack { | ||
TextField("Email", text: $model.email) | ||
#if os(iOS) | ||
.textInputAutocapitalization(.never) | ||
.keyboardType(.emailAddress) | ||
#endif | ||
.textContentType(.emailAddress) | ||
.autocorrectionDisabled() | ||
} | ||
Button("Sign in with Magic Link") { | ||
model.signInButtonTapped() | ||
} | ||
} | ||
.padding() | ||
.toast(state: $model.toast) | ||
.onOpenURL { model.handle($0) } | ||
} | ||
} | ||
|
||
#Preview { | ||
AuthView() | ||
} |
Oops, something went wrong.