@@ -22,7 +22,7 @@ extension NSNotification.Name {
2222protocol ZendeskManagerProtocol : SupportManagerAdapter {
2323 typealias onUserInformationCompletion = ( _ success: Bool , _ email: String ? ) -> Void
2424
25- func test_listenToSiteSwitchChanges ( )
25+ func observeStoreSwitch ( )
2626
2727 /// Displays the Zendesk New Request view from the given controller, for users to submit new tickets.
2828 ///
@@ -46,7 +46,7 @@ protocol ZendeskManagerProtocol: SupportManagerAdapter {
4646}
4747
4848struct NoZendeskManager : ZendeskManagerProtocol {
49- func test_listenToSiteSwitchChanges ( ) {
49+ func observeStoreSwitch ( ) {
5050 // no-op
5151 }
5252
@@ -148,7 +148,9 @@ final class ZendeskManager: NSObject, ZendeskManagerProtocol {
148148
149149 /// Loads Plugins from the Storage Layer.
150150 ///
151- private var pluginResultsController : ResultsController < StorageSitePlugin > {
151+ private lazy var pluginResultsController : ResultsController < StorageSitePlugin > = updatePluginResultsController ( )
152+
153+ private func updatePluginResultsController( ) -> ResultsController < StorageSitePlugin > {
152154 var sitePredicate : NSPredicate ? = nil
153155 if let siteID = stores. sessionManager. defaultSite? . siteID {
154156 sitePredicate = NSPredicate ( format: " siteID == %lld " , siteID)
@@ -163,12 +165,12 @@ final class ZendeskManager: NSObject, ZendeskManagerProtocol {
163165 sortedBy: pluginStatusDescriptor)
164166 }
165167
166- func test_listenToSiteSwitchChanges ( ) {
167- print ( " Changed! SiteID: " )
168+ func observeStoreSwitch ( ) {
169+ pluginResultsController = updatePluginResultsController ( )
168170 do {
169171 try pluginResultsController. performFetch ( )
170172 } catch {
171- DDLogError ( " :( " )
173+ DDLogError ( " ZendeskManager: Unable to update plugin results " )
172174 }
173175 }
174176
@@ -249,6 +251,7 @@ final class ZendeskManager: NSObject, ZendeskManagerProtocol {
249251 ///
250252 fileprivate override init ( ) {
251253 super. init ( )
254+ try ? pluginResultsController. performFetch ( )
252255 observeZendeskNotifications ( )
253256 }
254257
0 commit comments