Android + Time out Resume Logic so files can be requested again
continuous-integration/drone/pr Build is pending Details

This commit is contained in:
Sarah Jamie Lewis 2022-07-06 12:14:40 -07:00
parent 0ea2a2116e
commit 60e822cf12
3 changed files with 22 additions and 3 deletions

View File

@ -7,8 +7,10 @@ class FileDownloadProgress {
String? downloadedTo;
DateTime? timeStart;
DateTime? timeEnd;
DateTime? requested;
FileDownloadProgress(this.chunksTotal, this.timeStart);
double progress() {
return 1.0 * chunksDownloaded / chunksTotal;
}

View File

@ -291,12 +291,27 @@ class ProfileInfoState extends ChangeNotifier {
}
bool downloadInterrupted(String fileKey) {
return this._downloads.containsKey(fileKey) && this._downloads[fileKey]!.interrupted;
if (this._downloads.containsKey(fileKey)) {
if (this._downloads[fileKey]!.interrupted) {
return true;
}
if (this._downloads[fileKey]!.requested != null) {
if (DateTime.now().difference(this._downloads[fileKey]!.requested!) > Duration(minutes: 1)) {
this._downloads[fileKey]!.requested = null;
this._downloads[fileKey]!.interrupted = true;
return true;
}
}
}
return false;
}
void downloadMarkResumed(String fileKey) {
if (this._downloads.containsKey(fileKey)) {
this._downloads[fileKey]!.interrupted = false;
this._downloads[fileKey]!.requested = DateTime.now();
notifyListeners();
}
}

View File

@ -99,8 +99,10 @@ class _MessageViewState extends State<MessageView> {
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
var appBarButtons = <Widget>[];
appBarButtons.add(
IconButton(splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushFileSharingSettings));
if (showFileSharing) {
appBarButtons.add(IconButton(
splashRadius: Material.defaultSplashRadius / 2, icon: Icon(Icons.folder_shared), tooltip: AppLocalizations.of(context)!.conversationSettings, onPressed: _pushFileSharingSettings));
}
if (Provider.of<ContactInfoState>(context).isOnline()) {
if (showFileSharing) {