@@ -63,6 +63,13 @@ class CurrentProfileController: NativeProfileController {
6363 } )
6464 ] )
6565
66+ NotificationCenter . default. addObserver ( forName: SPProfiling . didChangedAuthState, object: nil , queue: nil ) { [ weak self] _ in
67+ guard let self = self else { return }
68+ if ( ProfileModel . currentProfile? . id != self . profileModel. id) {
69+ self . dismissAnimated ( )
70+ }
71+ }
72+
6673 NotificationCenter . default. addObserver ( forName: SPProfiling . didReloadedProfile, object: nil , queue: nil ) { [ weak self] _ in
6774 guard let self = self else { return }
6875 if let profileModel = ProfileModel . currentProfile {
@@ -124,22 +131,27 @@ class CurrentProfileController: NativeProfileController {
124131 action: { [ weak self] _, indexPath in
125132 guard let self = self else { return }
126133 let sourceView = self . tableView. cellForRow ( at: indexPath) ?? UIView ( )
134+ let cell = self . tableView. cellForRow ( at: indexPath) as? SPTableViewCell
135+ cell? . setLoading ( true )
136+
127137 UIAlertController . confirm (
128138 title: Texts . Profile. Actions. SignOut. Confirm. title,
129139 description: Texts . Profile. Actions. SignOut. Confirm. description,
130140 actionTitle: Texts . Profile. Actions. SignOut. title,
131141 cancelTitle: Texts . cancel,
132142 desctructive: true ,
133- action : { [ weak self] in
143+ completion : { [ weak self] confirmed in
134144 guard let self = self else { return }
135- let cell = self . tableView. cellForRow ( at: indexPath) as? SPTableViewCell
136- cell? . setLoading ( true )
137- ProfileModel . currentProfile? . signOut { error in
138- if let error = error {
139- SPAlert . present ( message: error. localizedDescription, haptic: . error)
140- } else {
141- self . dismissAnimated ( )
145+ if confirmed {
146+ ProfileModel . currentProfile? . signOut { error in
147+ if let error = error {
148+ SPAlert . present ( message: error. localizedDescription, haptic: . error)
149+ } else {
150+ self . dismissAnimated ( )
151+ }
152+ cell? . setLoading ( false )
142153 }
154+ } else {
143155 cell? . setLoading ( false )
144156 }
145157 } ,
@@ -163,21 +175,25 @@ class CurrentProfileController: NativeProfileController {
163175 action: { [ weak self] _, indexPath in
164176 guard let self = self else { return }
165177 let sourceView = self . tableView. cellForRow ( at: indexPath) ?? UIView ( )
178+ let cell = self . tableView. cellForRow ( at: indexPath) as? SPTableViewCell
179+ cell? . setLoading ( true )
166180 UIAlertController . confirmDouble (
167181 title: Texts . Profile. Actions. Delete. Confirm. title,
168182 description: Texts . Profile. Actions. Delete. Confirm. description,
169183 actionTitle: Texts . Profile. Actions. Delete. title,
170184 cancelTitle: Texts . cancel,
171185 desctructive: true ,
172- action : { [ weak self] in
186+ completion : { [ weak self] confirmed in
173187 guard let self = self else { return }
174- let cell = self . tableView . cellForRow ( at : indexPath ) as? SPTableViewCell
175- cell ? . setLoading ( true )
176- self . profileModel . delete { error in
177- cell ? . setLoading ( false )
178- if let error = error {
179- SPAlert . present ( message : error . localizedDescription , haptic : . error )
188+ if confirmed {
189+ self . profileModel . delete ( on : self ) { error in
190+ cell ? . setLoading ( false )
191+ if let error = error {
192+ SPAlert . present ( message : error. localizedDescription , haptic : . error )
193+ }
180194 }
195+ } else {
196+ cell? . setLoading ( false )
181197 }
182198 } ,
183199 sourceView: sourceView,
0 commit comments