forked from cwtch.im/cwtch-ui
Fix exceptions when quoting with quotes + fix size of message row without toolbar
This commit is contained in:
parent
7b397ecfe2
commit
70c5325351
|
@ -68,7 +68,13 @@ class CwtchNotifier {
|
|||
}
|
||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) == null) {
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["GroupID"],
|
||||
authorization: ContactAuthorization.approved, imagePath: data["PicturePath"], nickname: data["GroupName"], status: status, server: data["GroupServer"], isGroup: true, lastMessageTime: DateTime.now()));
|
||||
authorization: ContactAuthorization.approved,
|
||||
imagePath: data["PicturePath"],
|
||||
nickname: data["GroupName"],
|
||||
status: status,
|
||||
server: data["GroupServer"],
|
||||
isGroup: true,
|
||||
lastMessageTime: DateTime.now()));
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now());
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -329,14 +329,10 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
enum ContactAuthorization {
|
||||
unknown,
|
||||
approved,
|
||||
blocked
|
||||
}
|
||||
enum ContactAuthorization { unknown, approved, blocked }
|
||||
|
||||
ContactAuthorization stringToContactAuthorization(String authStr) {
|
||||
switch(authStr) {
|
||||
switch (authStr) {
|
||||
case "approved":
|
||||
return ContactAuthorization.approved;
|
||||
case "blocked":
|
||||
|
@ -346,7 +342,6 @@ ContactAuthorization stringToContactAuthorization(String authStr) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class ContactInfoState extends ChangeNotifier {
|
||||
final String profileOnion;
|
||||
final String onion;
|
||||
|
|
|
@ -23,8 +23,6 @@ const TorV3ContactHandleLength = 56;
|
|||
// Defines the length of a Cwtch v2 Group.
|
||||
const GroupConversationHandleLength = 32;
|
||||
|
||||
|
||||
|
||||
abstract class Message {
|
||||
MessageMetadata getMetadata();
|
||||
Widget getWidget(BuildContext context);
|
||||
|
|
|
@ -10,6 +10,17 @@ import 'package:provider/provider.dart';
|
|||
import '../../main.dart';
|
||||
import '../../model.dart';
|
||||
|
||||
class QuotedMessageStructure {
|
||||
final String quotedHash;
|
||||
final String body;
|
||||
QuotedMessageStructure(this.quotedHash, this.body);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'quotedHash': quotedHash,
|
||||
'body': body,
|
||||
};
|
||||
}
|
||||
|
||||
class LocallyIndexedMessage {
|
||||
final dynamic message;
|
||||
final int index;
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:crypto/crypto.dart';
|
||||
import 'package:cwtch/cwtch_icons_icons.dart';
|
||||
import 'package:cwtch/models/message.dart';
|
||||
import 'package:cwtch/models/messages/quotedmessage.dart';
|
||||
import 'package:cwtch/widgets/malformedbubble.dart';
|
||||
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
||||
import 'package:cwtch/widgets/profileimage.dart';
|
||||
|
@ -127,7 +128,7 @@ class _MessageViewState extends State<MessageView> {
|
|||
var bytes1 = utf8.encode(messageWrapper["PeerID"] + messageWrapper['Message']);
|
||||
var digest1 = sha256.convert(bytes1);
|
||||
var contentHash = base64Encode(digest1.bytes);
|
||||
var quotedMessage = "{\"quotedHash\":\"" + contentHash + "\",\"body\":\"" + ctrlrCompose.value.text + "\"}";
|
||||
var quotedMessage = jsonEncode(QuotedMessageStructure(contentHash, ctrlrCompose.value.text));
|
||||
ChatMessage cm = new ChatMessage(o: QuotedMessageOverlay, d: quotedMessage);
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
|
@ -204,7 +205,7 @@ class _MessageViewState extends State<MessageView> {
|
|||
suffixIcon: IconButton(
|
||||
icon: Icon(CwtchIcons.send_24px, size: 24, color: Provider.of<Settings>(context).theme.mainTextColor()),
|
||||
tooltip: AppLocalizations.of(context)!.sendMessage,
|
||||
onPressed: isOffline ? null :_sendMessage,
|
||||
onPressed: isOffline ? null : _sendMessage,
|
||||
),
|
||||
)))),
|
||||
),
|
||||
|
|
|
@ -99,8 +99,6 @@ class _ContactRowState extends State<ContactRow> {
|
|||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _btnApprove() {
|
||||
Provider.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
|
|
|
@ -39,6 +39,7 @@ class MessageRowState extends State<MessageRow> {
|
|||
|
||||
Widget wdgIcons = Visibility(
|
||||
visible: this.showMenu,
|
||||
maintainSize: true,
|
||||
child: IconButton(
|
||||
tooltip: AppLocalizations.of(context)!.tooltipReplyToThisMessage,
|
||||
onPressed: () {
|
||||
|
@ -127,10 +128,7 @@ class MessageRowState extends State<MessageRow> {
|
|||
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
||||
child: Text(AppLocalizations.of(context)!.addContact),
|
||||
onPressed: () {
|
||||
Provider
|
||||
.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.ImportBundle(profileOnion, senderOnion);
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.ImportBundle(profileOnion, senderOnion);
|
||||
final snackBar = SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.successfullAddedContact),
|
||||
duration: Duration(seconds: 2),
|
||||
|
|
|
@ -5,7 +5,8 @@ import 'package:provider/provider.dart';
|
|||
import '../settings.dart';
|
||||
|
||||
class ProfileImage extends StatefulWidget {
|
||||
ProfileImage({required this.imagePath, required this.diameter, required this.border, this.badgeCount = 0, required this.badgeColor, required this.badgeTextColor, this.maskOut = false, this.tooltip = ""});
|
||||
ProfileImage(
|
||||
{required this.imagePath, required this.diameter, required this.border, this.badgeCount = 0, required this.badgeColor, required this.badgeTextColor, this.maskOut = false, this.tooltip = ""});
|
||||
final double diameter;
|
||||
final String imagePath;
|
||||
final Color border;
|
||||
|
@ -47,11 +48,7 @@ class _ProfileImageState extends State<ProfileImage> {
|
|||
color: widget.border,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2.0), //border size
|
||||
child: ClipOval(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: widget.tooltip == "" ? image : Tooltip(
|
||||
message: widget.tooltip,
|
||||
child: image))))),
|
||||
child: ClipOval(clipBehavior: Clip.antiAlias, child: widget.tooltip == "" ? image : Tooltip(message: widget.tooltip, child: image))))),
|
||||
Visibility(
|
||||
visible: widget.badgeCount > 0,
|
||||
child: Positioned(
|
||||
|
|
Loading…
Reference in New Issue