From fc4790baa9bae97b3a9b3d71c6ed1da9d6ebc6e7 Mon Sep 17 00:00:00 2001 From: kaoru Date: Sun, 14 Jun 2026 22:04:50 -0400 Subject: [PATCH] fix(video): preserve decimal latency display --- lib/screens/channel/video/video_store.dart | 2 +- .../video/video_store_latency_js_test.dart | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/screens/channel/video/video_store_latency_js_test.dart diff --git a/lib/screens/channel/video/video_store.dart b/lib/screens/channel/video/video_store.dart index c9b2aaae..a91fe6d2 100644 --- a/lib/screens/channel/video/video_store.dart +++ b/lib/screens/channel/video/video_store.dart @@ -782,7 +782,7 @@ abstract class VideoStoreBase with Store { // Convert to abbreviated unit: "4.69 sec." -> "4.69s" const match = latencyText.match(/([0-9.]+)\s*sec/i); if (match) { - latencyText = Math.round(parseFloat(match[1])) + 's'; + latencyText = parseFloat(match[1]).toFixed(2) + 's'; this.hasInitialLatency = true; } diff --git a/test/screens/channel/video/video_store_latency_js_test.dart b/test/screens/channel/video/video_store_latency_js_test.dart new file mode 100644 index 00000000..67cb7bf8 --- /dev/null +++ b/test/screens/channel/video/video_store_latency_js_test.dart @@ -0,0 +1,17 @@ +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test( + 'webview latency tracker keeps two decimal places in overlay labels', + () { + final source = File( + 'lib/screens/channel/video/video_store.dart', + ).readAsStringSync(); + + expect(source, contains("parseFloat(match[1]).toFixed(2) + 's'")); + expect(source, isNot(contains("Math.round(parseFloat(match[1])) + 's'"))); + }, + ); +}