debounce updateAttachment
This commit is contained in:
@@ -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';
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user