@@ -192,37 +192,24 @@ mixin OfflineScreenControllerMixin<T>
192192 _exportController.downloadFile (encodedData);
193193 }
194194
195- /// Adds a listener that will prepare the screen's current data for offline
196- /// viewing after an app disconnect.
195+ /// Prepare the screen's current data for offline viewing after an app
196+ /// disconnect.
197197 ///
198198 /// This is in preparation for the user clicking the 'Review History' button
199199 /// from the disconnect screen.
200- ///
201- /// For screens that support the disconnect experience, which is a screen that
202- /// allows you to view historical data from before the app was disconnected
203- /// even after we lose connection to the device, this should be called in the
204- /// controller's initialization.
205- void initReviewHistoryOnDisconnectListener () {
206- addAutoDisposeListener (serviceConnection.serviceManager.connectedState, () {
207- final connectionState =
208- serviceConnection.serviceManager.connectedState.value;
209- if (! connectionState.connected &&
210- ! connectionState.userInitiatedConnectionState) {
211- final currentScreenData = prepareOfflineScreenData ();
212- // Only store data for the current page. We can change this in the
213- // future if we support offline imports for more than once screen at a
214- // time.
215- if (DevToolsRouterDelegate .currentPage == currentScreenData.screenId) {
216- final previouslyConnectedApp =
217- offlineDataController.previousConnectedApp;
218- final offlineData = _exportController.generateDataForExport (
219- offlineScreenData: currentScreenData.toJson (),
220- connectedApp: previouslyConnectedApp,
221- );
222- offlineDataController.offlineDataJson = offlineData;
223- }
224- }
225- });
200+ void maybePrepareDataForReviewingHistory () {
201+ final currentScreenData = prepareOfflineScreenData ();
202+ // Only store data for the current page. We can change this in the
203+ // future if we support offline imports for more than once screen at a
204+ // time.
205+ if (DevToolsRouterDelegate .currentPage == currentScreenData.screenId) {
206+ final previouslyConnectedApp = offlineDataController.previousConnectedApp;
207+ final offlineData = _exportController.generateDataForExport (
208+ offlineScreenData: currentScreenData.toJson (),
209+ connectedApp: previouslyConnectedApp,
210+ );
211+ offlineDataController.offlineDataJson = offlineData;
212+ }
226213 }
227214}
228215
0 commit comments