Skip to content

Commit

Permalink
fixup! TF-3236 Display SearchSnippet in search result
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Nov 15, 2024
1 parent 6536ecb commit a2ba572
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions core/lib/presentation/views/text/rich_text_builder.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:debounce_throttle/debounce_throttle.dart';
import 'package:flutter/material.dart';

class RichTextBuilder extends StatefulWidget {
Expand Down Expand Up @@ -32,11 +31,6 @@ class _RichTextBuilderState extends State<RichTextBuilder> with AutomaticKeepAli
final firstHighlightKey = GlobalKey();
bool firstHighlightKeyed = false;

late final richTextWidthDebouncer = Debouncer<double>(
const Duration(milliseconds: 300),
initialValue: 0,
onChanged: (_) => scrollDebounceListener());

void scrollDebounceListener() {
if (!firstHighlightKeyed) return;
if (firstHighlightKey.currentContext == null) return;
Expand All @@ -54,12 +48,6 @@ class _RichTextBuilderState extends State<RichTextBuilder> with AutomaticKeepAli
}
}

@override
void dispose() {
richTextWidthDebouncer.cancel();
super.dispose();
}

@override
Widget build(BuildContext context) {
super.build(context);
Expand All @@ -83,7 +71,9 @@ class _RichTextBuilderState extends State<RichTextBuilder> with AutomaticKeepAli

if (!widget.ensureHighlightVisible) return text;

richTextWidthDebouncer.value = MediaQuery.sizeOf(context).width;
WidgetsBinding.instance.addPostFrameCallback((_) {
scrollDebounceListener();
});

return SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
Expand Down

0 comments on commit a2ba572

Please sign in to comment.