Merge pull request 'Fix Performance Issues Relating to File Bubble' (#661) from performance into trunk
continuous-integration/drone/push Build is passing Details

Reviewed-on: #661
Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2023-04-17 20:33:03 +00:00
commit 2920afa10c
9 changed files with 61 additions and 46 deletions

View File

@ -1 +1 @@
2023-04-05-19-46-v0.0.3-13-gb7a4bc2 2023-04-17-10-52-v0.0.3-15-gf485e37

View File

@ -12,8 +12,6 @@ class AppState extends ChangeNotifier {
String? _selectedProfile; String? _selectedProfile;
int? _selectedConversation; int? _selectedConversation;
int _initialScrollIndex = 0; int _initialScrollIndex = 0;
int _hoveredIndex = -1;
int? _selectedIndex;
bool _unreadMessagesBelow = false; bool _unreadMessagesBelow = false;
bool _disableFilePicker = false; bool _disableFilePicker = false;
bool _focus = true; bool _focus = true;
@ -59,14 +57,6 @@ class AppState extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
// Never use this for message lookup - can be a non-indexed value
// e.g. -1
int get hoveredIndex => _hoveredIndex;
set hoveredIndex(int newVal) {
this._hoveredIndex = newVal;
notifyListeners();
}
bool get unreadMessagesBelow => _unreadMessagesBelow; bool get unreadMessagesBelow => _unreadMessagesBelow;
set unreadMessagesBelow(bool newVal) { set unreadMessagesBelow(bool newVal) {
this._unreadMessagesBelow = newVal; this._unreadMessagesBelow = newVal;

View File

@ -66,6 +66,8 @@ class ContactInfoState extends ChangeNotifier {
String? _acnCircuit; String? _acnCircuit;
MessageDraft _messageDraft = MessageDraft.empty(); MessageDraft _messageDraft = MessageDraft.empty();
var _hoveredIndex = -1;
ContactInfoState( ContactInfoState(
this.profileOnion, this.profileOnion,
this.identifier, this.identifier,
@ -402,7 +404,15 @@ class ContactInfoState extends ChangeNotifier {
} }
String augmentedNickname(BuildContext context) { String augmentedNickname(BuildContext context) {
return this.nickname + (this.availabilityStatus == ProfileStatusMenu.available ? "" : " (" +this.statusString(context) + ")"); return this.nickname + (this.availabilityStatus == ProfileStatusMenu.available ? "" : " (" + this.statusString(context) + ")");
}
// Never use this for message lookup - can be a non-indexed value
// e.g. -1
int get hoveredIndex => _hoveredIndex;
set hoveredIndex(int newVal) {
this._hoveredIndex = newVal;
notifyListeners();
} }
String statusString(BuildContext context) { String statusString(BuildContext context) {

View File

@ -33,11 +33,11 @@ class FileMessage extends Message {
int fileSize = shareObj['s'] as int; int fileSize = shareObj['s'] as int;
String fileKey = rootHash + "." + nonce; String fileKey = rootHash + "." + nonce;
// if (metadata.attributes["file-downloaded"] == "true") { if (metadata.attributes["file-downloaded"] != "true") {
// if (!Provider.of<ProfileInfoState>(context).downloadKnown(fileKey)) { if (!Provider.of<ProfileInfoState>(context, listen: false).downloadKnown(fileKey)) {
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, fileKey); Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, fileKey);
// } }
//} }
if (!validHash(rootHash, nonce)) { if (!validHash(rootHash, nonce)) {
return MessageRow(MalformedBubble(), index); return MessageRow(MalformedBubble(), index);

View File

@ -50,7 +50,7 @@ void selectConversation(BuildContext context, int handle) {
// triggers update in Double/TripleColumnView // triggers update in Double/TripleColumnView
Provider.of<AppState>(context, listen: false).initialScrollIndex = unread; Provider.of<AppState>(context, listen: false).initialScrollIndex = unread;
Provider.of<AppState>(context, listen: false).selectedConversation = handle; Provider.of<AppState>(context, listen: false).selectedConversation = handle;
Provider.of<AppState>(context, listen: false).hoveredIndex = -1; Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = -1;
// if in singlepane mode, push to the stack // if in singlepane mode, push to the stack
var isLandscape = Provider.of<AppState>(context, listen: false).isLandscape(context); var isLandscape = Provider.of<AppState>(context, listen: false).isLandscape(context);
if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle); if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle);
@ -164,15 +164,21 @@ class _ContactsViewState extends State<ContactsView> {
itemBuilder: (BuildContext context) => <PopupMenuEntry<ProfileStatusMenu>>[ itemBuilder: (BuildContext context) => <PopupMenuEntry<ProfileStatusMenu>>[
PopupMenuItem<ProfileStatusMenu>( PopupMenuItem<ProfileStatusMenu>(
value: ProfileStatusMenu.available, value: ProfileStatusMenu.available,
child: Text(AppLocalizations.of(context)!.availabilityStatusAvailable!,), child: Text(
AppLocalizations.of(context)!.availabilityStatusAvailable!,
),
), ),
PopupMenuItem<ProfileStatusMenu>( PopupMenuItem<ProfileStatusMenu>(
value: ProfileStatusMenu.away, value: ProfileStatusMenu.away,
child: Text(AppLocalizations.of(context)!.availabilityStatusAway!,), child: Text(
AppLocalizations.of(context)!.availabilityStatusAway!,
),
), ),
PopupMenuItem<ProfileStatusMenu>( PopupMenuItem<ProfileStatusMenu>(
value: ProfileStatusMenu.busy, value: ProfileStatusMenu.busy,
child: Text(AppLocalizations.of(context)!.availabilityStatusBusy!,), child: Text(
AppLocalizations.of(context)!.availabilityStatusBusy!,
),
), ),
], ],
), ),

View File

@ -17,11 +17,9 @@ import 'package:cwtch/models/profile.dart';
import 'package:cwtch/third_party/linkify/flutter_linkify.dart'; import 'package:cwtch/third_party/linkify/flutter_linkify.dart';
import 'package:cwtch/widgets/malformedbubble.dart'; import 'package:cwtch/widgets/malformedbubble.dart';
import 'package:cwtch/widgets/messageloadingbubble.dart'; import 'package:cwtch/widgets/messageloadingbubble.dart';
import 'package:cwtch/widgets/messagerow.dart';
import 'package:cwtch/widgets/profileimage.dart'; import 'package:cwtch/widgets/profileimage.dart';
import 'package:cwtch/controllers/filesharing.dart' as filesharing; import 'package:cwtch/controllers/filesharing.dart' as filesharing;
import 'package:cwtch/widgets/staticmessagebubble.dart'; import 'package:cwtch/widgets/staticmessagebubble.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -230,11 +228,12 @@ class _MessageViewState extends State<MessageView> {
), ),
Expanded( Expanded(
child: Container( child: Container(
height: 42, height: 42,
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(), decoration: BoxDecoration(),
child: Align( child: Align(
alignment: Alignment.centerLeft, child: Text( alignment: Alignment.centerLeft,
child: Text(
Provider.of<ContactInfoState>(context).augmentedNickname(context), Provider.of<ContactInfoState>(context).augmentedNickname(context),
overflow: TextOverflow.clip, overflow: TextOverflow.clip,
maxLines: 1, maxLines: 1,

View File

@ -113,15 +113,24 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
child: Column(children: [ child: Column(children: [
Padding( Padding(
padding: EdgeInsets.all(1), padding: EdgeInsets.all(1),
child: SelectableText(Provider.of<ContactInfoState>(context, listen: false).attributes[0] ?? "", textAlign: TextAlign.center,), child: SelectableText(
Provider.of<ContactInfoState>(context, listen: false).attributes[0] ?? "",
textAlign: TextAlign.center,
),
), ),
Padding( Padding(
padding: EdgeInsets.all(1), padding: EdgeInsets.all(1),
child: SelectableText(Provider.of<ContactInfoState>(context, listen: false).attributes[1] ?? "", textAlign: TextAlign.center,), child: SelectableText(
Provider.of<ContactInfoState>(context, listen: false).attributes[1] ?? "",
textAlign: TextAlign.center,
),
), ),
Padding( Padding(
padding: EdgeInsets.all(1), padding: EdgeInsets.all(1),
child: SelectableText(Provider.of<ContactInfoState>(context, listen: false).attributes[2] ?? "", textAlign: TextAlign.center,), child: SelectableText(
Provider.of<ContactInfoState>(context, listen: false).attributes[2] ?? "",
textAlign: TextAlign.center,
),
) )
])) ]))
]), ]),

View File

@ -1,3 +1,4 @@
import 'package:cwtch/config.dart';
import 'package:cwtch/models/appstate.dart'; import 'package:cwtch/models/appstate.dart';
import 'package:cwtch/models/contact.dart'; import 'package:cwtch/models/contact.dart';
import 'package:cwtch/models/message.dart'; import 'package:cwtch/models/message.dart';

View File

@ -81,7 +81,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
Widget wdgReply = Platform.isAndroid Widget wdgReply = Platform.isAndroid
? SizedBox.shrink() ? SizedBox.shrink()
: Visibility( : Visibility(
visible: EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID, visible: EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID,
maintainSize: true, maintainSize: true,
maintainAnimation: true, maintainAnimation: true,
maintainState: true, maintainState: true,
@ -106,7 +106,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
Widget wdgSeeReplies = Platform.isAndroid Widget wdgSeeReplies = Platform.isAndroid
? SizedBox.shrink() ? SizedBox.shrink()
: Visibility( : Visibility(
visible: EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID, visible: EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID,
maintainSize: true, maintainSize: true,
maintainAnimation: true, maintainAnimation: true,
maintainState: true, maintainState: true,
@ -128,8 +128,8 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
: Visibility( : Visibility(
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() && visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() &&
Provider.of<Settings>(context).isExperimentEnabled(BlodeuweddExperiment) && Provider.of<Settings>(context).isExperimentEnabled(BlodeuweddExperiment) &&
(EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID), (EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID),
maintainSize: false, maintainSize: true,
maintainAnimation: true, maintainAnimation: true,
maintainState: true, maintainState: true,
maintainInteractivity: false, maintainInteractivity: false,
@ -245,16 +245,12 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
var mr = MouseRegion( var mr = MouseRegion(
// For desktop... // For desktop...
onHover: (event) { onHover: (event) {
if (Provider.of<AppState>(context, listen: false).hoveredIndex != Provider.of<MessageMetadata>(context, listen: false).messageID) { if (Provider.of<ContactInfoState>(context, listen: false).hoveredIndex != Provider.of<MessageMetadata>(context, listen: false).messageID) {
setState(() { Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
Provider.of<AppState>(context, listen: false).hoveredIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
});
} }
}, },
onExit: (event) { onExit: (event) {
// setState(() { Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = -1;
// Provider.of<AppState>(context, listen: false).hoveredIndex = -1;
//});
}, },
child: GestureDetector( child: GestureDetector(
onPanUpdate: (details) { onPanUpdate: (details) {
@ -270,12 +266,16 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
}, },
onPanEnd: (details) { onPanEnd: (details) {
_runAnimation(details.velocity.pixelsPerSecond, size); _runAnimation(details.velocity.pixelsPerSecond, size);
Provider.of<ContactInfoState>(context, listen: false).messageDraft.quotedReference = Provider.of<MessageMetadata>(context, listen: false).messageID; if (Platform.isAndroid) {
Provider.of<ContactInfoState>(context, listen: false).notifyMessageDraftUpdate(); Provider.of<ContactInfoState>(context, listen: false).messageDraft.quotedReference = Provider.of<MessageMetadata>(context, listen: false).messageID;
setState(() {}); Provider.of<ContactInfoState>(context, listen: false).notifyMessageDraftUpdate();
setState(() {});
}
}, },
onLongPress: () async { onLongPress: () async {
modalShowReplies(context, AppLocalizations.of(context)!.headingReplies, AppLocalizations.of(context)!.messageNoReplies, settings, pis, cis, borderColor, cache, messageID); if (Platform.isAndroid) {
modalShowReplies(context, AppLocalizations.of(context)!.headingReplies, AppLocalizations.of(context)!.messageNoReplies, settings, pis, cis, borderColor, cache, messageID);
}
}, },
child: Padding( child: Padding(
padding: EdgeInsets.all(2), padding: EdgeInsets.all(2),