Skip to content

Commit

Permalink
Invalidate first line pointer on buffer_line_added and check if it's …
Browse files Browse the repository at this point in the history
…available on resume
  • Loading branch information
nilscc committed Feb 21, 2023
1 parent ef736e7 commit 06402b7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/relay/buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class RelayBuffer extends ChangeNotifier {
relayConnection.addCallback(
'_buffer_line_added',
(body) async {
// invalidate pointer to first line
_firstLinePointer = null;

for (final RelayHData obj in body.objects()) {
if (obj.hPath == 'line') {
// store information about last line
Expand All @@ -137,6 +140,7 @@ class RelayBuffer extends ChangeNotifier {
}
}
}

notifyListeners();
},
repeat: true,
Expand Down Expand Up @@ -177,6 +181,13 @@ class RelayBuffer extends ChangeNotifier {
}

Future<void> resume() async {
if (_firstLinePointer == null) {
// perform full sync if first line pointer is not available
lines.clear();
await sync();
return;
}

final hdataCmd = 'hdata'
' line:$_firstLinePointer/next_line(*)/data'
' $_lineDataSelected';
Expand Down

0 comments on commit 06402b7

Please sign in to comment.