Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backoff retry failed images (#126) #164

Merged
merged 129 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 125 commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
2bfae4c
First push
skazkiful Oct 6, 2022
e062073
Merge branch 'main' into 126-retry-load-images
skazkiful Oct 6, 2022
dca6ab1
some changes
skazkiful Oct 7, 2022
54cc9ff
some working version
skazkiful Oct 7, 2022
d95bb57
some working version
skazkiful Oct 7, 2022
3f4fa24
final
skazkiful Oct 7, 2022
6033141
trying to do e2e test
skazkiful Oct 7, 2022
ada6da6
Some changes
skazkiful Oct 10, 2022
cedae53
Some changes
skazkiful Oct 11, 2022
347f27a
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
skazkiful Oct 11, 2022
904088c
Final version
skazkiful Oct 11, 2022
e13185e
Some changes
skazkiful Oct 11, 2022
e181d80
Some changes
skazkiful Oct 11, 2022
a88a78a
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
skazkiful Oct 11, 2022
e6a691d
Fixes
skazkiful Oct 11, 2022
b3c5cd3
Fixes
skazkiful Oct 11, 2022
ff5e171
Fixes
skazkiful Oct 11, 2022
c9058b3
Fixes
skazkiful Oct 11, 2022
64d7cdc
Small changes
skazkiful Oct 13, 2022
d320fcf
try to find error
skazkiful Oct 13, 2022
701cfca
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
skazkiful Oct 14, 2022
c82f3c4
some changes
skazkiful Oct 14, 2022
e4628fb
Fix
skazkiful Oct 17, 2022
4cbefbc
Small fix
skazkiful Oct 17, 2022
4537913
Corrections
krida2000 Oct 18, 2022
245ad98
Fix analyzer
krida2000 Oct 19, 2022
6929cfc
Dock corrections
krida2000 Oct 19, 2022
d09c0e2
Change e2e test
skazkiful Oct 20, 2022
0b844d7
some changes
skazkiful Oct 21, 2022
e0717af
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
skazkiful Oct 21, 2022
6853150
some changes
skazkiful Oct 21, 2022
714842f
Try to fix ci
skazkiful Oct 24, 2022
d9a77ac
Try to fix ci
skazkiful Oct 25, 2022
0e6e39f
Try to fix ci
skazkiful Oct 25, 2022
9c77e08
Try to fix ci
skazkiful Oct 25, 2022
a878b22
Merge branch 'main' into 126-retry-load-images
skazkiful Oct 25, 2022
50c3805
some changes
skazkiful Oct 25, 2022
8e9b054
Add width to image
skazkiful Oct 25, 2022
d27af39
some changes
skazkiful Oct 25, 2022
73341cc
Merge branch 'main' into 126-retry-load-images
skazkiful Oct 25, 2022
69798cb
fix
skazkiful Oct 25, 2022
7c2ab6a
fix ci
skazkiful Oct 25, 2022
119c583
fix ci
skazkiful Oct 25, 2022
f8b7a25
Corrections
krida2000 Oct 26, 2022
1527523
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
SleepySquash Oct 27, 2022
efacbc2
Corrections
SleepySquash Oct 27, 2022
162d695
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
SleepySquash Oct 27, 2022
0539504
Corrections
SleepySquash Oct 27, 2022
f7c73f9
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
skazkiful Oct 31, 2022
2ca5e89
Trying some ci changes
skazkiful Nov 2, 2022
a6db0cb
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 2, 2022
a169515
some changes
skazkiful Nov 2, 2022
a42d787
Impl RetryImage everywhere
skazkiful Nov 2, 2022
669a41f
Small change
skazkiful Nov 2, 2022
21189f3
Try ci
skazkiful Nov 2, 2022
5dba328
Try ci
skazkiful Nov 2, 2022
2e54001
try ci
skazkiful Nov 2, 2022
1c104b6
try ci
skazkiful Nov 2, 2022
573fd13
another try ci
skazkiful Nov 2, 2022
83f2335
some changes
skazkiful Nov 3, 2022
0b82111
some changes
skazkiful Nov 3, 2022
cf7f663
try new ci
skazkiful Nov 3, 2022
b00f4c3
try new ci
skazkiful Nov 3, 2022
a92150b
try new ci
skazkiful Nov 3, 2022
133fc21
try ci
skazkiful Nov 4, 2022
725be1c
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
skazkiful Nov 4, 2022
adf8e55
try ci
skazkiful Nov 4, 2022
bf62b8d
try ci
skazkiful Nov 4, 2022
321bf09
try ci
skazkiful Nov 4, 2022
668178b
try ci
skazkiful Nov 4, 2022
4607147
try ci
skazkiful Nov 4, 2022
80eb9e2
try ci
skazkiful Nov 7, 2022
067d51b
fix ci
skazkiful Nov 7, 2022
1d1591a
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 7, 2022
7df3079
try ci
skazkiful Nov 7, 2022
4bca09d
try ci
skazkiful Nov 7, 2022
901d0e5
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 8, 2022
d1c6170
try ci
skazkiful Nov 8, 2022
4f55ea2
try ci
skazkiful Nov 8, 2022
b98db83
try ci
skazkiful Nov 8, 2022
8c3dba4
fix ci
skazkiful Nov 8, 2022
b4179c4
fix ci
skazkiful Nov 8, 2022
1905c19
fix test error
skazkiful Nov 8, 2022
720a77b
fix test error
skazkiful Nov 8, 2022
4c24046
try ci
skazkiful Nov 9, 2022
17d4905
try ci
skazkiful Nov 9, 2022
edc9128
awesome fix e2e test
skazkiful Nov 9, 2022
7fb03f7
some changes
skazkiful Nov 9, 2022
8279f5f
try ci
skazkiful Nov 10, 2022
88432e6
try ci
skazkiful Nov 10, 2022
5fbfaaa
try ci
skazkiful Nov 10, 2022
28a702d
try ci
skazkiful Nov 10, 2022
251d089
fixes
skazkiful Nov 10, 2022
cf88343
Corrections
SleepySquash Nov 11, 2022
2b67fcc
fix e2e
skazkiful Nov 11, 2022
84f0334
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 11, 2022
c47e496
fix e2e
skazkiful Nov 11, 2022
fa77b74
Merge remote-tracking branch 'origin/126-retry-load-images' into 126-…
skazkiful Nov 11, 2022
0fa0e98
some changes
skazkiful Nov 11, 2022
190684a
some changes
skazkiful Nov 11, 2022
75b3a59
some changes
skazkiful Nov 14, 2022
ad7f2e6
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 14, 2022
e996896
some changes
skazkiful Nov 14, 2022
445adc6
some changes
skazkiful Nov 14, 2022
dc46668
some changes
skazkiful Nov 14, 2022
a7938c1
try ci
skazkiful Nov 14, 2022
807e7bf
try ci
skazkiful Nov 14, 2022
2809556
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 16, 2022
4d04028
try ci
skazkiful Nov 16, 2022
b70b210
try ci
skazkiful Nov 17, 2022
f4edc25
try ci
skazkiful Nov 17, 2022
edacfc9
changes
skazkiful Nov 17, 2022
436116c
Corrections
SleepySquash Nov 18, 2022
707504a
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
SleepySquash Nov 18, 2022
8a45700
Corrections
SleepySquash Nov 18, 2022
3d9565f
changes
skazkiful Nov 18, 2022
313e127
Merge remote-tracking branch 'origin/main' into 126-retry-load-images
SleepySquash Nov 21, 2022
841b681
E2E test corrections
SleepySquash Nov 21, 2022
7fc97ed
Corrections
SleepySquash Nov 21, 2022
c23d049
changes
skazkiful Nov 28, 2022
fc14e6c
working version
skazkiful Nov 28, 2022
4eb7f4f
working version
skazkiful Nov 28, 2022
e203e52
working version
skazkiful Nov 28, 2022
4ac026b
Merge branch 'main' into 126-retry-load-images
skazkiful Nov 28, 2022
80e557f
small changes
skazkiful Nov 28, 2022
cad627f
Corrections
SleepySquash Nov 30, 2022
3185f51
Corrections
SleepySquash Nov 30, 2022
e473e20
Corrections
SleepySquash Nov 30, 2022
4004cf7
Make analyzer happy
SleepySquash Nov 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ All user visible changes to this project will be documented in this file. This p
- UI:
- Chat page:
- Replies having reversed order in messages. ([#193], [#192])
- Images sometimes not loading. ([#164], [#126])
- Web:
- Context menu not opening over video previews. ([#198], [#196])

[#63]: /../../issues/63
[#102]: /../../issues/102
[#126]: /../../issues/126
[#134]: /../../issues/134
[#142]: /../../pull/142
[#164]: /../../pull/164
[#172]: /../../pull/172
[#173]: /../../pull/173
[#188]: /../../pull/188
Expand Down
4 changes: 2 additions & 2 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ class Config {
// configuration.
if (confRemote) {
try {
var response =
await Dio().fetch(RequestOptions(path: '$url:$port/conf.toml'));
final response = await PlatformUtils.dio
.fetch(RequestOptions(path: '$url:$port/conf.toml'));
if (response.statusCode == 200) {
Map<String, dynamic> remote =
TomlDocument.parse(response.data.toString()).toMap();
Expand Down
19 changes: 16 additions & 3 deletions lib/domain/model/precise_date_time/src/non_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import 'package:hive/hive.dart';
import '/domain/model_type_id.dart';
import '/util/new_type.dart';

part 'non_web.g.dart';

/// [DateTime] considering the microseconds on any platform, including Web.
@HiveType(typeId: ModelTypeId.preciseDateTime)
class PreciseDateTime extends NewType<DateTime>
krida2000 marked this conversation as resolved.
Show resolved Hide resolved
implements Comparable<PreciseDateTime> {
PreciseDateTime(DateTime val, {int microsecond = 0}) : super(val);
Expand Down Expand Up @@ -188,3 +185,19 @@ class PreciseDateTime extends NewType<DateTime>
static PreciseDateTime parse(String formattedString) =>
PreciseDateTime(DateTime.parse(formattedString));
}

/// [Hive] adapter for a [PreciseDateTime].
class PreciseDateTimeAdapter extends TypeAdapter<PreciseDateTime> {
@override
final typeId = ModelTypeId.preciseDateTime;

@override
PreciseDateTime read(BinaryReader reader) => PreciseDateTime(
DateTime.fromMicrosecondsSinceEpoch(reader.readInt()),
);

@override
void write(BinaryWriter writer, PreciseDateTime obj) {
writer.writeInt(obj.microsecondsSinceEpoch);
}
}
20 changes: 16 additions & 4 deletions lib/domain/model/precise_date_time/src/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ import 'package:hive/hive.dart';
import '/domain/model_type_id.dart';
import '/util/new_type.dart';

part 'web.g.dart';

/// [DateTime] considering the microseconds on any platform, including Web.
@HiveType(typeId: ModelTypeId.preciseDateTimeWeb)
class PreciseDateTime extends NewType<DateTime>
implements Comparable<PreciseDateTime> {
PreciseDateTime(DateTime val, {this.microsecond = 0}) : super(val);

@HiveField(1)
final int microsecond;

/// Returns the number of microseconds since the "Unix epoch"
Expand Down Expand Up @@ -209,3 +205,19 @@ class PreciseDateTime extends NewType<DateTime>
return formattedString;
}
}

/// [Hive] adapter for a [PreciseDateTime].
class PreciseDateTimeAdapter extends TypeAdapter<PreciseDateTime> {
@override
final typeId = ModelTypeId.preciseDateTime;

@override
PreciseDateTime read(BinaryReader reader) =>
PreciseDateTime(reader.read() as DateTime, microsecond: reader.readInt());

@override
void write(BinaryWriter writer, PreciseDateTime obj) {
writer.write(obj.val);
writer.writeInt(obj.microsecond);
}
}
17 changes: 8 additions & 9 deletions lib/domain/model_type_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ class ModelTypeId {
static const mediaSettings = 71;
static const chatCallDeviceId = 72;
static const preciseDateTime = 73;
static const preciseDateTimeWeb = 74;
static const applicationSettings = 75;
static const sendingStatus = 76;
static const nativeFile = 77;
static const localAttachment = 78;
static const mediaType = 79;
static const hiveBackground = 80;
static const storageFile = 81;
static const chatCallCredentials = 82;
static const applicationSettings = 74;
static const sendingStatus = 75;
static const nativeFile = 76;
static const localAttachment = 77;
static const mediaType = 78;
static const hiveBackground = 79;
static const storageFile = 80;
static const chatCallCredentials = 81;
}
8 changes: 4 additions & 4 deletions lib/provider/gql/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
import 'dart:async';

import 'package:async/async.dart' show StreamGroup;
import 'package:dio/dio.dart' as dio show Dio, DioError, Options, Response;
import 'package:dio/dio.dart' as dio show DioError, Options, Response;
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:mutex/mutex.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import '/config.dart';
import '/domain/model/session.dart';
import '/util/log.dart';
import '/util/platform_utils.dart';
import 'exceptions.dart';

/// Base GraphQl provider.
Expand Down Expand Up @@ -205,13 +206,12 @@ class GraphQlClient {
void Function(int, int)? onSendProgress,
}) =>
_middleware(() async {
var client = dio.Dio();
var authorized = options ?? dio.Options();
final dio.Options authorized = options ?? dio.Options();
authorized.headers = (authorized.headers ?? {});
authorized.headers!['Authorization'] = 'Bearer $token';

try {
return await client.post<T>(
return await PlatformUtils.dio.post<T>(
'${Config.url}:${Config.port}${Config.graphql}',
data: data,
options: authorized,
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/page/call/widget/call_cover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:flutter/material.dart';
import '/domain/model/user.dart';
import '/domain/model/user_call_cover.dart';
import '/ui/page/home/widget/avatar.dart';
import '/ui/page/home/widget/retry_image.dart';
import '/ui/widget/svg/svg.dart';

/// Widget to build an [UserCallCover].
Expand All @@ -29,7 +30,7 @@ import '/ui/widget/svg/svg.dart';
class CallCoverWidget extends StatelessWidget {
const CallCoverWidget(this.cover, {Key? key, this.user}) : super(key: key);

/// Call cover data object.
/// [UserCallCover] to display.
final UserCallCover? cover;

/// [User] this [UserCallCover] belongs to.
Expand All @@ -48,7 +49,7 @@ class CallCoverWidget extends StatelessWidget {
)
: Stack(
children: [
Image.network(
RetryImage(
cover!.full.url,
width: double.infinity,
height: double.infinity,
Expand Down
21 changes: 9 additions & 12 deletions lib/ui/page/home/page/chat/forward/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import '/ui/page/home/page/chat/widget/chat_item.dart';
import '/ui/page/home/page/chat/forward/controller.dart';
import '/ui/page/home/page/chat/widget/animated_fab.dart';
import '/ui/page/home/widget/avatar.dart';
import '/ui/page/home/widget/retry_image.dart';
import '/ui/widget/animations.dart';
import '/ui/widget/modal_popup.dart';
import '/ui/widget/svg/svg.dart';
Expand Down Expand Up @@ -225,14 +226,16 @@ class ChatForwardView extends StatelessWidget {
decoration: BoxDecoration(
color: const Color(0XFFF0F2F6),
borderRadius: BorderRadius.circular(4),
image: image == null
? null
: DecorationImage(image: NetworkImage(image.original.url)),
),
width: 50,
height: 50,
child:
image == null ? const Icon(Icons.attach_file, size: 16) : null,
child: image == null
? const Icon(Icons.attach_file, size: 16)
: RetryImage(
image.medium.url,
fit: BoxFit.cover,
borderRadius: BorderRadius.circular(4),
),
);
}).toList();
}
Expand Down Expand Up @@ -439,17 +442,11 @@ class ChatForwardView extends StatelessWidget {
width: 80,
height: 80,
)
: Image.network(
: RetryImage(
e.original.url,
fit: BoxFit.cover,
width: 80,
height: 80,
errorBuilder: (_, __, ___) => const SizedBox(
width: 80,
height: 80,
child:
Center(child: Icon(Icons.error, color: Colors.red)),
),
),
)
else
Expand Down
21 changes: 12 additions & 9 deletions lib/ui/page/home/page/chat/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import '/ui/page/home/widget/app_bar.dart';
import '/ui/page/home/widget/avatar.dart';
import '/ui/page/home/widget/gallery_popup.dart';
import '/ui/page/home/widget/init_callback.dart';
import '/ui/page/home/widget/retry_image.dart';
import '/ui/widget/animations.dart';
import '/ui/widget/menu_interceptor/menu_interceptor.dart';
import '/ui/widget/svg/svg.dart';
Expand Down Expand Up @@ -1383,7 +1384,7 @@ class _ChatViewState extends State<ChatView>
}
}
} else {
child = Image.network(
child = RetryImage(
e.original.url,
fit: BoxFit.cover,
width: size,
Expand Down Expand Up @@ -1648,9 +1649,6 @@ class _ChatViewState extends State<ChatView>
? Colors.white.withOpacity(0.2)
: Colors.black.withOpacity(0.03),
borderRadius: BorderRadius.circular(4),
image: image == null
? null
: DecorationImage(image: NetworkImage(image.small.url)),
),
width: 30,
height: 30,
Expand All @@ -1660,7 +1658,11 @@ class _ChatViewState extends State<ChatView>
color: fromMe ? Colors.white : const Color(0xFFDDDDDD),
size: 16,
)
: null,
: RetryImage(
image.small.url,
fit: BoxFit.cover,
borderRadius: BorderRadius.circular(4),
),
);
}).toList();
}
Expand Down Expand Up @@ -1884,9 +1886,6 @@ class _ChatViewState extends State<ChatView>
? Colors.white.withOpacity(0.2)
: Colors.black.withOpacity(0.03),
borderRadius: BorderRadius.circular(4),
image: image == null
? null
: DecorationImage(image: NetworkImage(image.small.url)),
),
width: 30,
height: 30,
Expand All @@ -1896,7 +1895,11 @@ class _ChatViewState extends State<ChatView>
color: fromMe ? Colors.white : const Color(0xFFDDDDDD),
size: 16,
)
: null,
: RetryImage(
image.small.url,
fit: BoxFit.cover,
borderRadius: BorderRadius.circular(4),
),
);
}).toList();
}
Expand Down
30 changes: 11 additions & 19 deletions lib/ui/page/home/page/chat/widget/chat_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import '/ui/page/home/page/chat/forward/view.dart';
import '/ui/page/home/widget/avatar.dart';
import '/ui/page/home/widget/confirm_dialog.dart';
import '/ui/page/home/widget/gallery_popup.dart';
import '/ui/page/home/widget/init_callback.dart';
import '/ui/page/home/widget/retry_image.dart';
import '/ui/widget/animated_delayed_switcher.dart';
import '/ui/widget/animations.dart';
import '/ui/widget/context_menu/menu.dart';
Expand Down Expand Up @@ -200,20 +200,12 @@ class ChatItemWidget extends StatefulWidget {
} else {
attachment = KeyedSubtree(
key: const Key('SentImage'),
child: Image.network(
child: RetryImage(
(e as ImageAttachment).big.url,
key: key,
fit: BoxFit.cover,
height: 300,
errorBuilder: (_, __, ___) {
return InitCallback(
callback: onError,
child: const SizedBox.square(
dimension: 300,
child: Center(child: CircularProgressIndicator()),
),
);
},
onForbidden: onError,
),
);
}
Expand Down Expand Up @@ -1042,13 +1034,6 @@ class _ChatItemWidgetState extends State<ChatItemWidget> {
? Colors.white.withOpacity(0.25)
: Colors.black.withOpacity(0.03),
borderRadius: BorderRadius.circular(10),
image: image == null
? null
: DecorationImage(
image: NetworkImage(image.medium.url),
onError: (_, __) => widget.onAttachmentError?.call(),
fit: BoxFit.cover,
),
),
width: 50,
height: 50,
Expand All @@ -1058,7 +1043,14 @@ class _ChatItemWidgetState extends State<ChatItemWidget> {
color: fromMe ? Colors.white : const Color(0xFFDDDDDD),
size: 28,
)
: null,
: RetryImage(
image.medium.url,
onForbidden: widget.onAttachmentError,
fit: BoxFit.cover,
width: double.infinity,
height: double.infinity,
borderRadius: BorderRadius.circular(10.0),
),
);
})
.take(3)
Expand Down
19 changes: 5 additions & 14 deletions lib/ui/page/home/tab/chats/widget/recent_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import '/ui/page/home/tab/chats/widget/periodic_builder.dart';
import '/ui/page/home/widget/animated_typing.dart';
import '/ui/page/home/widget/avatar.dart';
import '/ui/page/home/widget/chat_tile.dart';
import '/ui/page/home/widget/init_callback.dart';
import '/ui/page/home/widget/retry_image.dart';
import '/ui/widget/context_menu/menu.dart';
import '/ui/widget/svg/svg.dart';
import '/ui/widget/widget_button.dart';
Expand Down Expand Up @@ -553,21 +553,12 @@ class RecentChatTile extends StatelessWidget {
}

if (e is ImageAttachment) {
content = Image.network(
content = RetryImage(
'${Config.files}${e.medium.relativeRef}',
fit: BoxFit.cover,
errorBuilder: (_, __, ___) {
return InitCallback(
callback: onError,
child: const Center(
child: SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 3),
),
),
);
},
width: double.infinity,
height: double.infinity,
onForbidden: onError,
);
}

Expand Down
Loading