debounce updateAttachment

This commit is contained in:
Salvatore Giordano
2021-03-01 11:55:37 +01:00
parent ecb559f687
commit b36c31c992
2 changed files with 10 additions and 4 deletions
@@ -238,9 +238,15 @@ class Channel {
} }
void onSendProgress(int sent, int total) { void onSendProgress(int sent, int total) {
updateAttachment(it.copyWith( debounce(
uploadState: UploadState.inProgress(uploaded: sent, total: total), timeout: Duration(seconds: 1),
)); target: updateAttachment,
arguments: [
it.copyWith(
uploadState: UploadState.inProgress(uploaded: sent, total: total),
),
],
);
} }
final isImage = it.type == 'image'; final isImage = it.type == 'image';
+1 -1
View File
@@ -3,7 +3,7 @@ import 'dart:async';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
/// Map of timeouts being debounced /// Map of timeouts being debounced
Map timeouts = {}; Map<Function, Timer> timeouts = {};
/// Runs a function avoiding calling it too many times in a [timeoutMS] window /// Runs a function avoiding calling it too many times in a [timeoutMS] window
void debounce({ void debounce({