Skip to content

Commit

Permalink
comments resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
hrajwade96 committed Oct 8, 2024
1 parent 941ec88 commit 852b144
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,21 @@ class NetworkController extends DisposableController

void _initHelper() async {
try {
if (offlineDataController.showingOfflineData.value == true) {
if (offlineDataController.showingOfflineData.value) {
await maybeLoadOfflineData(
NetworkScreen.id,
createData: (json) => OfflineNetworkData.fromJson(json),
shouldLoad: (data) => !data.isEmpty,
loadData: (data) => loadOfflineData(data),
);
}
cancelListeners();
if (!offlineDataController.showingOfflineData.value) {
}else{
unawaited(startRecording());
debugPrint('started recording');
addAutoDisposeListener(
serviceConnection.serviceManager.isolateManager.mainIsolate,
() {
() {
if (serviceConnection
.serviceManager.isolateManager.mainIsolate.value !=
.serviceManager.isolateManager.mainIsolate.value !=
null) {
unawaited(startRecording());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import '../../shared/primitives/utils.dart';
import 'network_model.dart';

/// Class to encapsulate offline data for the [NetworkController].
///
/// It is responsible for serializing and deserializing offline network data.
class OfflineNetworkData with Serializable {
OfflineNetworkData({
required this.requests,
this.selectedRequestId,
this.recording = false,
});

/// Creates an instance of [OfflineNetworkData] from a JSON map.
Expand All @@ -33,7 +33,6 @@ class OfflineNetworkData with Serializable {
return OfflineNetworkData(
requests: requests,
selectedRequestId: json['selectedRequestId'] as String?,
recording: json['recording'] as bool? ?? false,
);
}
bool get isEmpty => requests.isNullOrEmpty;
Expand All @@ -54,16 +53,12 @@ class OfflineNetworkData with Serializable {
/// The ID of the currently selected request, if any.
final String? selectedRequestId;

/// Whether the recording state is enabled.
final bool recording;

/// Converts the current offline data to a JSON format.
@override
Map<String, dynamic> toJson() {
return {
'requests': requests.map((request) => request.toJson()).toList(),
'selectedRequestId': selectedRequestId,
'recording': recording,
};
}
}

0 comments on commit 852b144

Please sign in to comment.