debounce updateAttachment
This commit is contained in:
@@ -238,9 +238,15 @@ class Channel {
|
||||
}
|
||||
|
||||
void onSendProgress(int sent, int total) {
|
||||
updateAttachment(it.copyWith(
|
||||
uploadState: UploadState.inProgress(uploaded: sent, total: total),
|
||||
));
|
||||
debounce(
|
||||
timeout: Duration(seconds: 1),
|
||||
target: updateAttachment,
|
||||
arguments: [
|
||||
it.copyWith(
|
||||
uploadState: UploadState.inProgress(uploaded: sent, total: total),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final isImage = it.type == 'image';
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:async';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// Map of timeouts being debounced
|
||||
Map timeouts = {};
|
||||
Map<Function, Timer> timeouts = {};
|
||||
|
||||
/// Runs a function avoiding calling it too many times in a [timeoutMS] window
|
||||
void debounce({
|
||||
|
||||
Reference in New Issue
Block a user