-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline support for Network page #8332
base: master
Are you sure you want to change the base?
Offline support for Network page #8332
Conversation
@hrajwade96 is this PR ready for review or is this still a work in progress? |
@kenzieschmoll just finishing up few things, I will mark it ready soon |
…into network_screen_offline_support
packages/devtools_app/lib/src/screens/network/network_screen.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
shouldLoad: (data) => !data.isEmpty, | ||
loadData: (data) => loadOfflineData(data), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code after this if statement should be put in an else
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not using else was an oversight, added else block now, and also now there is no code outside.
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_screen.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_screen.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_screen.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_controller.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/network_model.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
List<Socket>? socketReqData = []; | ||
socketReqData = json[OfflineDataKeys.socketData.name] as List<Socket>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define in one step:
final socketRequestData =(json[OfflineDataKeys.socketData.name] as List?)?.cast<Socket>();
Also, prefer socketRequestData
over socketReqData
to avoid abbreviations in variable names
final httpRequestData = json[OfflineDataKeys.httpRequestData.name] | ||
as List<DartIOHttpRequestData>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cast this to the proper type instead:
final httpRequestData = (json[OfflineDataKeys.httpRequestData.name] as List?)?.cast<DartIOHttpRequestData>();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now I have explicitly called fromJson on each object from list, will refactor it and make it into an extension.
BTW one observation is when I remove/comment all the toJson() of all the required classes, and pass the list of DartIOHttpRequestData directly
//To Json
Map<String, dynamic> toJson() {
return {
OfflineDataKeys.httpRequestData.name: httpRequestData,
OfflineDataKeys.selectedRequestId.name: selectedRequestId,
OfflineDataKeys.socketData.name: socketData,
};
// From Json
final httpRequestData = json[OfflineDataKeys.httpRequestData.name]
as List<DartIOHttpRequestData>;
return OfflineNetworkData(
httpRequestData: httpRequestData,
selectedRequestId:
json[OfflineDataKeys.selectedRequestId.name] as String?,
socketData: socketReqData,
)
This still works, as dart is preserving those object types (when we don't serialise them, hence no need for deserialisation).
Since this offline feature is only used in dart (not passed to any external system) and an in-memory thing, is this a good idea to not fully serialise & de-serialise it? and store the inner objects of DartIOHttpRequestData list and Socket and as they are and pick them? Or is it not recommended or safe to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to download the screen's data as a JSON file, the serialization is required. However, not serializing the data is acceptable for the 'review history' feature, which allows continuing to view recent data offline when the connected app disconnects. I wouldn't worry about distinguishing the two for this PR. This can be a clean up later if the serialization / deserialization for the 'review history' features causes performance issues.
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/shared/http/http_request_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/shared/http/http_request_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/shared/http/http_request_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/shared/http/http_request_data.dart
Outdated
Show resolved
Hide resolved
SocketJsonKey.id.name: id, | ||
SocketJsonKey.startTime.name: startTime, | ||
SocketJsonKey.endTime.name: endTime, | ||
//TODO verify if these timings are in correct format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address this TODO.
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/screens/network/offline_network_data.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test coverage for this change. Thanks!
Adding offline support to Network page.
issue link - #4470
List which issues are fixed by this PR.
Please add a note to
packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
if your change requires release notes. Otherwise, add the 'release-notes-not-required' label to the PR.Pre-launch Checklist
///
).If you need help, consider asking for help on Discord.