Merge pull request 'Fix Performance Issues Relating to File Bubble' (#661) from performance into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #661 Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
commit
2920afa10c
|
@ -1 +1 @@
|
|||
2023-04-05-19-46-v0.0.3-13-gb7a4bc2
|
||||
2023-04-17-10-52-v0.0.3-15-gf485e37
|
|
@ -12,8 +12,6 @@ class AppState extends ChangeNotifier {
|
|||
String? _selectedProfile;
|
||||
int? _selectedConversation;
|
||||
int _initialScrollIndex = 0;
|
||||
int _hoveredIndex = -1;
|
||||
int? _selectedIndex;
|
||||
bool _unreadMessagesBelow = false;
|
||||
bool _disableFilePicker = false;
|
||||
bool _focus = true;
|
||||
|
@ -59,14 +57,6 @@ class AppState extends ChangeNotifier {
|
|||
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;
|
||||
set unreadMessagesBelow(bool newVal) {
|
||||
this._unreadMessagesBelow = newVal;
|
||||
|
|
|
@ -66,6 +66,8 @@ class ContactInfoState extends ChangeNotifier {
|
|||
String? _acnCircuit;
|
||||
MessageDraft _messageDraft = MessageDraft.empty();
|
||||
|
||||
var _hoveredIndex = -1;
|
||||
|
||||
ContactInfoState(
|
||||
this.profileOnion,
|
||||
this.identifier,
|
||||
|
@ -402,7 +404,15 @@ class ContactInfoState extends ChangeNotifier {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -33,11 +33,11 @@ class FileMessage extends Message {
|
|||
int fileSize = shareObj['s'] as int;
|
||||
String fileKey = rootHash + "." + nonce;
|
||||
|
||||
// if (metadata.attributes["file-downloaded"] == "true") {
|
||||
// if (!Provider.of<ProfileInfoState>(context).downloadKnown(fileKey)) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, fileKey);
|
||||
// }
|
||||
//}
|
||||
if (metadata.attributes["file-downloaded"] != "true") {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (!validHash(rootHash, nonce)) {
|
||||
return MessageRow(MalformedBubble(), index);
|
||||
|
|
|
@ -50,7 +50,7 @@ void selectConversation(BuildContext context, int handle) {
|
|||
// triggers update in Double/TripleColumnView
|
||||
Provider.of<AppState>(context, listen: false).initialScrollIndex = unread;
|
||||
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
|
||||
var isLandscape = Provider.of<AppState>(context, listen: false).isLandscape(context);
|
||||
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>>[
|
||||
PopupMenuItem<ProfileStatusMenu>(
|
||||
value: ProfileStatusMenu.available,
|
||||
child: Text(AppLocalizations.of(context)!.availabilityStatusAvailable!,),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.availabilityStatusAvailable!,
|
||||
),
|
||||
),
|
||||
PopupMenuItem<ProfileStatusMenu>(
|
||||
value: ProfileStatusMenu.away,
|
||||
child: Text(AppLocalizations.of(context)!.availabilityStatusAway!,),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.availabilityStatusAway!,
|
||||
),
|
||||
),
|
||||
PopupMenuItem<ProfileStatusMenu>(
|
||||
value: ProfileStatusMenu.busy,
|
||||
child: Text(AppLocalizations.of(context)!.availabilityStatusBusy!,),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.availabilityStatusBusy!,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -17,11 +17,9 @@ import 'package:cwtch/models/profile.dart';
|
|||
import 'package:cwtch/third_party/linkify/flutter_linkify.dart';
|
||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
||||
import 'package:cwtch/widgets/messagerow.dart';
|
||||
import 'package:cwtch/widgets/profileimage.dart';
|
||||
import 'package:cwtch/controllers/filesharing.dart' as filesharing;
|
||||
import 'package:cwtch/widgets/staticmessagebubble.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -230,11 +228,12 @@ class _MessageViewState extends State<MessageView> {
|
|||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 42,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft, child: Text(
|
||||
height: 42,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
Provider.of<ContactInfoState>(context).augmentedNickname(context),
|
||||
overflow: TextOverflow.clip,
|
||||
maxLines: 1,
|
||||
|
|
|
@ -113,15 +113,24 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
|
|||
child: Column(children: [
|
||||
Padding(
|
||||
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: 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: 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,
|
||||
),
|
||||
)
|
||||
]))
|
||||
]),
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cwtch/config.dart';
|
||||
import 'package:cwtch/models/appstate.dart';
|
||||
import 'package:cwtch/models/contact.dart';
|
||||
import 'package:cwtch/models/message.dart';
|
||||
|
|
|
@ -81,7 +81,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
|||
Widget wdgReply = Platform.isAndroid
|
||||
? SizedBox.shrink()
|
||||
: 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,
|
||||
maintainAnimation: true,
|
||||
maintainState: true,
|
||||
|
@ -106,7 +106,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
|||
Widget wdgSeeReplies = Platform.isAndroid
|
||||
? SizedBox.shrink()
|
||||
: 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,
|
||||
maintainAnimation: true,
|
||||
maintainState: true,
|
||||
|
@ -128,8 +128,8 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
|||
: Visibility(
|
||||
visible: Provider.of<FlwtchState>(context, listen: false).cwtch.IsBlodeuweddSupported() &&
|
||||
Provider.of<Settings>(context).isExperimentEnabled(BlodeuweddExperiment) &&
|
||||
(EnvironmentConfig.TEST_MODE || Provider.of<AppState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID),
|
||||
maintainSize: false,
|
||||
(EnvironmentConfig.TEST_MODE || Provider.of<ContactInfoState>(context).hoveredIndex == Provider.of<MessageMetadata>(context).messageID),
|
||||
maintainSize: true,
|
||||
maintainAnimation: true,
|
||||
maintainState: true,
|
||||
maintainInteractivity: false,
|
||||
|
@ -245,16 +245,12 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
|||
var mr = MouseRegion(
|
||||
// For desktop...
|
||||
onHover: (event) {
|
||||
if (Provider.of<AppState>(context, listen: false).hoveredIndex != Provider.of<MessageMetadata>(context, listen: false).messageID) {
|
||||
setState(() {
|
||||
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) {
|
||||
Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||
}
|
||||
},
|
||||
onExit: (event) {
|
||||
// setState(() {
|
||||
// Provider.of<AppState>(context, listen: false).hoveredIndex = -1;
|
||||
//});
|
||||
Provider.of<ContactInfoState>(context, listen: false).hoveredIndex = -1;
|
||||
},
|
||||
child: GestureDetector(
|
||||
onPanUpdate: (details) {
|
||||
|
@ -270,12 +266,16 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
|||
},
|
||||
onPanEnd: (details) {
|
||||
_runAnimation(details.velocity.pixelsPerSecond, size);
|
||||
Provider.of<ContactInfoState>(context, listen: false).messageDraft.quotedReference = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||
Provider.of<ContactInfoState>(context, listen: false).notifyMessageDraftUpdate();
|
||||
setState(() {});
|
||||
if (Platform.isAndroid) {
|
||||
Provider.of<ContactInfoState>(context, listen: false).messageDraft.quotedReference = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||
Provider.of<ContactInfoState>(context, listen: false).notifyMessageDraftUpdate();
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
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(
|
||||
padding: EdgeInsets.all(2),
|
||||
|
|
Loading…
Reference in New Issue