nausharipov commented on code in PR #26978:
URL: https://github.com/apache/beam/pull/26978#discussion_r1214276423
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -137,22 +135,27 @@ class TourNotifier extends ChangeNotifier with
PageStateMixin<void> {
if (currentNode is! UnitModel) {
await _emptyPlayground();
} else {
- _setUnitContent(null);
- notifyListeners();
-
- final content = await _unitContentCache.getUnitContent(
- currentSdk.id,
- currentNode.id,
- );
-
- _setUnitContent(content);
- await _unitProgressCache.loadUnitProgress(currentSdk);
- _trySetSnippetType(SnippetType.saved);
- await _loadSnippetByType();
+ await _loadUnit(currentNode);
}
notifyListeners();
}
+ Future<void> _loadUnit(NodeModel? node) async {
Review Comment:
Make `node` non-nullable?
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -125,10 +125,8 @@ class TourNotifier extends ChangeNotifier with
PageStateMixin<void> {
Future<void> _onAppNotifierChanged() async {
playgroundController.setSdk(currentSdk);
_listenToCurrentSnippetEditingController();
-
- await _unitProgressCache.loadUnitProgress(currentSdk);
- _trySetSnippetType(SnippetType.saved);
- await _loadSnippetByType();
+ final currentNode = contentTreeController.currentNode;
+ await _loadUnit(currentNode);
Review Comment:
```suggestion
await _loadUnit(contentTreeController.currentNode);
```
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -137,22 +135,27 @@ class TourNotifier extends ChangeNotifier with
PageStateMixin<void> {
if (currentNode is! UnitModel) {
await _emptyPlayground();
} else {
- _setUnitContent(null);
- notifyListeners();
-
- final content = await _unitContentCache.getUnitContent(
- currentSdk.id,
- currentNode.id,
- );
-
- _setUnitContent(content);
- await _unitProgressCache.loadUnitProgress(currentSdk);
- _trySetSnippetType(SnippetType.saved);
- await _loadSnippetByType();
+ await _loadUnit(currentNode);
}
notifyListeners();
}
+ Future<void> _loadUnit(NodeModel? node) async {
+ _setUnitContent(null);
+ notifyListeners();
+
+ final content = await _unitContentCache.getUnitContent(
+ currentSdk.id,
+ node?.id ?? '',
+ );
+
Review Comment:
Delete the line?
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]