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

TW-746: apply download images/videos in mobile #881

Merged
merged 8 commits into from
Nov 3, 2023

Conversation

sherlockvn
Copy link
Contributor

@sherlockvn sherlockvn commented Oct 31, 2023

Blockers:

Demo 1: compare memory usage when user scroll through a lot of images

  • Before:
Screen.Recording.2023-10-31.at.14.43.47.mov
  • After:
Screen.Recording.2023-10-31.at.14.39.47.mov

Demo 2: compare memory usage when download a video

  • Before:
new.mov

-After:

Screen.Recording.2023-10-31.at.17.30.33.mov

Demo image and video in web and mobile in unencrypted chat

new_demo.mov

@sherlockvn sherlockvn temporarily deployed to PR-881 October 31, 2023 03:10 — with GitHub Actions Inactive
@github-actions
Copy link

This PR has been deployed to https://linagora.github.io/twake-on-matrix/881

@sherlockvn sherlockvn temporarily deployed to PR-881 October 31, 2023 05:11 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 October 31, 2023 07:07 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 October 31, 2023 07:41 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 October 31, 2023 10:32 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 October 31, 2023 15:33 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 November 1, 2023 08:26 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 November 1, 2023 08:31 — with GitHub Actions Inactive
// FIXME: change to false after https://github.com/linagora/twake-on-matrix/issues/746
getThumbnail: true,
future: controller.widget.event.getFileInfo(
getThumbnail: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not get thumbnail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think when open image in full screen, we should download the root file not thumbnail one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @sherlockvn

@sherlockvn sherlockvn temporarily deployed to PR-881 November 1, 2023 09:55 — with GitHub Actions Inactive
@sherlockvn sherlockvn temporarily deployed to PR-881 November 1, 2023 11:27 — with GitHub Actions Inactive
pubspec.yaml Outdated Show resolved Hide resolved
@sherlockvn sherlockvn temporarily deployed to PR-881 November 2, 2023 09:04 — with GitHub Actions Inactive
@sherlockvn sherlockvn force-pushed the TW-746/download-image-video-using-stream branch from 7b3e0a8 to 292b080 Compare November 2, 2023 09:06
@sherlockvn sherlockvn temporarily deployed to PR-881 November 2, 2023 09:06 — with GitHub Actions Inactive
@@ -505,4 +505,8 @@ extension SendFileExtension on Room {
Future<Size> _calculateImageBytesDimension(Uint8List bytes) {
return Image.memory(bytes).calculateImageDimension();
}

bool isRoomEncrypted() {
Copy link
Contributor

@imGok imGok Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move it to room extension please ? Would be useful for encrypted icon for example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's already in the room extension

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it in Send file extension

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

year and on Room :))

@@ -297,7 +297,7 @@ extension StringCasingExtension on String {
if (length < maxCharacters) return this;
return substring(0, maxCharacters);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 274 to 307
child: filePath != null && filePath!.isNotEmpty
? Image.file(
File(filePath!),
width: widget.width,
height: widget.height,
cacheWidth: needResize ? widget.width?.toInt() : null,
cacheHeight: needResize ? widget.height?.toInt() : null,
fit: widget.fit,
filterQuality: FilterQuality.medium,
errorBuilder: (context, __, ___) {
_isCached = false;
filePath = null;
WidgetsBinding.instance.addPostFrameCallback(_tryLoad);
return placeholder(context);
},
)
: data != null
? Image.memory(
data,
width: widget.width,
height: widget.height,
cacheWidth: needResize ? widget.width?.toInt() : null,
cacheHeight: needResize ? widget.height?.toInt() : null,
fit: widget.fit,
filterQuality: FilterQuality.medium,
errorBuilder: (context, __, ___) {
_isCached = false;
_imageData = null;
WidgetsBinding.instance
.addPostFrameCallback(_tryLoad);
return placeholder(context);
},
)
: const SizedBox.shrink(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write methods to simplify the comprehension ? nested ternary conditions are hard to read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. good idea

@hoangdat hoangdat merged commit 9aa5bb7 into main Nov 3, 2023
3 checks passed
@hoangdat hoangdat deleted the TW-746/download-image-video-using-stream branch November 3, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants