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 {
79
79
message: Text ( " Are you sure you want to sign out? " ) ,
80
80
primaryButton: . destructive( Text ( " Sign out " ) ) {
81
81
withAnimation {
82
- chatClient. disconnect {
82
+ chatClient. logout {
83
83
UnsecureRepository . shared. removeCurrentUser ( )
84
84
DispatchQueue . main. async {
85
85
AppState . shared. userState = . notLoggedIn
Original file line number Diff line number Diff line change @@ -15,8 +15,10 @@ struct DemoAppSwiftUIApp: App {
15
15
@ObservedObject var appState = AppState . shared
16
16
@ObservedObject var notificationsHandler = NotificationsHandler . shared
17
17
18
- @State var channelListController : ChatChannelListController ?
19
-
18
+ var channelListController : ChatChannelListController ? {
19
+ appState. channelListController
20
+ }
21
+
20
22
var body : some Scene {
21
23
WindowGroup {
22
24
switch appState. userState {
@@ -51,7 +53,7 @@ struct DemoAppSwiftUIApp: App {
51
53
. init( key: . updatedAt)
52
54
]
53
55
)
54
- channelListController = chatClient. channelListController ( query: channelListQuery)
56
+ appState . channelListController = chatClient. channelListController ( query: channelListQuery)
55
57
}
56
58
notificationsHandler. setupRemoteNotifications ( )
57
59
}
@@ -61,7 +63,15 @@ struct DemoAppSwiftUIApp: App {
61
63
62
64
class AppState : ObservableObject {
63
65
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 ?
65
75
66
76
static let shared = AppState ( )
67
77
You can’t perform that action at this time.
0 commit comments