Merge pull request 'Improve Logic for Handelling Interrupted Downloads' (#797) from post-stable-fixes into trunk
continuous-integration/drone/push Build is pending
Details
continuous-integration/drone/push Build is pending
Details
Reviewed-on: #797 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
efb9ce94e7
|
@ -12,19 +12,19 @@ themes:
|
||||||
font: 0xFFFFFF
|
font: 0xFFFFFF
|
||||||
settings: 0xFFFDFF
|
settings: 0xFFFDFF
|
||||||
accent: 0x9E6A56
|
accent: 0x9E6A56
|
||||||
accentAlt: 0x845A48
|
accentAlt: 0x9E6A56
|
||||||
theme:
|
theme:
|
||||||
backgroundMainColor: background # darkGreyPurple
|
backgroundMainColor: background
|
||||||
backgroundPaneColor: header # darkGreyPurple
|
backgroundPaneColor: header
|
||||||
topbarColor: header # darkGreyPurple
|
topbarColor: header
|
||||||
mainTextColor: font # whiteishPurple
|
mainTextColor: font
|
||||||
defaultButtonColor: accent # hotPink
|
defaultButtonColor: accent
|
||||||
textfieldHintColor: mainTextColor # TODO pick
|
textfieldHintColor: mainTextColor
|
||||||
toolbarIconColor: settings # whiteishPurple
|
toolbarIconColor: settings
|
||||||
messageFromMeBackgroundColor: userBubble # mauvePurple
|
messageFromMeBackgroundColor: userBubble
|
||||||
messageFromMeTextColor: font # whiteishPurple
|
messageFromMeTextColor: font
|
||||||
messageFromOtherBackgroundColor: peerBubble # deepPurple
|
messageFromOtherBackgroundColor: peerBubble
|
||||||
messageFromOtherTextColor: font # whiteishPurple
|
messageFromOtherTextColor: font
|
||||||
textfieldBackgroundColor: peerBubble
|
textfieldBackgroundColor: peerBubble
|
||||||
textfieldBorderColor: userBubble
|
textfieldBorderColor: userBubble
|
||||||
backgroundHilightElementColor: accent
|
backgroundHilightElementColor: accent
|
||||||
|
@ -45,3 +45,4 @@ themes:
|
||||||
portraitProfileBadgeColor: accent
|
portraitProfileBadgeColor: accent
|
||||||
portraitProfileBadgeTextColor: mainTextColor
|
portraitProfileBadgeTextColor: mainTextColor
|
||||||
dropShadowColor: accentAlt
|
dropShadowColor: accentAlt
|
||||||
|
chatReactionIconColor: accentAlt
|
|
@ -3,12 +3,22 @@ class FileDownloadProgress {
|
||||||
int chunksTotal = 1;
|
int chunksTotal = 1;
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
bool gotManifest = false;
|
bool gotManifest = false;
|
||||||
bool interrupted = false;
|
bool _interrupted = false;
|
||||||
|
|
||||||
|
// we keep track of both an explicit interrupt flag (for when a request fails or is explicitly cancelled)
|
||||||
|
set interrupted(isInterrupted) {
|
||||||
|
this._interrupted = isInterrupted;
|
||||||
|
}
|
||||||
|
|
||||||
|
// but we have a fuzzy get which depends on lastUpdate, if the file isn't complete, but the last update was more
|
||||||
|
// that 30 seconds ago, we consider this download as failed.
|
||||||
|
get interrupted => _interrupted || (DateTime.now().difference(lastUpdate).abs().inSeconds > 30 && !complete);
|
||||||
|
|
||||||
String? downloadedTo;
|
String? downloadedTo;
|
||||||
DateTime? timeStart;
|
DateTime? timeStart;
|
||||||
DateTime? timeEnd;
|
DateTime? timeEnd;
|
||||||
DateTime? requested;
|
DateTime? requested;
|
||||||
DateTime lastUpdate = DateTime.now();
|
DateTime lastUpdate = DateTime.fromMillisecondsSinceEpoch(0);
|
||||||
|
|
||||||
FileDownloadProgress(this.chunksTotal, this.timeStart);
|
FileDownloadProgress(this.chunksTotal, this.timeStart);
|
||||||
|
|
||||||
|
|
|
@ -383,19 +383,6 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
if (this._downloads[fileKey]!.interrupted) {
|
if (this._downloads[fileKey]!.interrupted) {
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
if (DateTime.now().difference(this._downloads[fileKey]!.lastUpdate) > Duration(minutes: 1)) {
|
|
||||||
this._downloads[fileKey]!.requested = null;
|
|
||||||
this._downloads[fileKey]!.interrupted = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,7 @@ class YmlTheme extends OpaqueThemeType {
|
||||||
|
|
||||||
get chatImage => getImage("chatImage") ?? fallbackTheme.chatImage;
|
get chatImage => getImage("chatImage") ?? fallbackTheme.chatImage;
|
||||||
|
|
||||||
|
|
||||||
ImageProvider loadImage(String key) {
|
ImageProvider loadImage(String key) {
|
||||||
File f = File(key);
|
File f = File(key);
|
||||||
if (f.existsSync()) {
|
if (f.existsSync()) {
|
||||||
|
@ -147,5 +148,4 @@ class YmlTheme extends OpaqueThemeType {
|
||||||
return AssetImage(key);
|
return AssetImage(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue