File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ struct CustomChannelModifier: ChannelListHeaderViewModifier {
7979 message: Text ( " Are you sure you want to sign out? " ) ,
8080 primaryButton: . destructive( Text ( " Sign out " ) ) {
8181 withAnimation {
82- chatClient. disconnect {
82+ chatClient. logout {
8383 UnsecureRepository . shared. removeCurrentUser ( )
8484 DispatchQueue . main. async {
8585 AppState . shared. userState = . notLoggedIn
Original file line number Diff line number Diff line change @@ -15,8 +15,10 @@ struct DemoAppSwiftUIApp: App {
1515 @ObservedObject var appState = AppState . shared
1616 @ObservedObject var notificationsHandler = NotificationsHandler . shared
1717
18- @State var channelListController : ChatChannelListController ?
19-
18+ var channelListController : ChatChannelListController ? {
19+ appState. channelListController
20+ }
21+
2022 var body : some Scene {
2123 WindowGroup {
2224 switch appState. userState {
@@ -51,7 +53,7 @@ struct DemoAppSwiftUIApp: App {
5153 . init( key: . updatedAt)
5254 ]
5355 )
54- channelListController = chatClient. channelListController ( query: channelListQuery)
56+ appState . channelListController = chatClient. channelListController ( query: channelListQuery)
5557 }
5658 notificationsHandler. setupRemoteNotifications ( )
5759 }
@@ -61,7 +63,15 @@ struct DemoAppSwiftUIApp: App {
6163
6264class AppState : ObservableObject {
6365
64- @Published var userState : UserState = . launchAnimation
66+ @Published var userState : UserState = . launchAnimation {
67+ willSet {
68+ if newValue == . notLoggedIn && userState == . loggedIn {
69+ channelListController = nil
70+ }
71+ }
72+ }
73+
74+ var channelListController : ChatChannelListController ?
6575
6676 static let shared = AppState ( )
6777
You can’t perform that action at this time.
0 commit comments