Added support for force refresh without caching, using this system on chatList.dart
This commit is contained in:
@ -10,8 +10,9 @@ abstract class RequestCache<T> {
|
||||
|
||||
int maxCacheTime;
|
||||
Function(T) onUpdate;
|
||||
bool? renew;
|
||||
|
||||
RequestCache(this.maxCacheTime, this.onUpdate);
|
||||
RequestCache(this.maxCacheTime, this.onUpdate, {this.renew = false});
|
||||
|
||||
void start(String file, String document) async {
|
||||
Map<String, dynamic>? tableData = await Localstore.instance.collection(file).doc(document).get();
|
||||
@ -20,7 +21,7 @@ abstract class RequestCache<T> {
|
||||
}
|
||||
|
||||
if(DateTime.now().millisecondsSinceEpoch - (maxCacheTime * 1000) < (tableData?['lastupdate'] ?? 0)) {
|
||||
return;
|
||||
if(renew == null || !renew!) return;
|
||||
}
|
||||
|
||||
T newValue = await onLoad();
|
||||
|
Reference in New Issue
Block a user