Browse Source

Merge pull request 'Fix #457 + Formatting' (#459) from fix457 into trunk

Reviewed-on: https://git.openprivacy.ca/cwtch.im/cwtch-ui/pulls/459
trunk
Dan Ballard 3 weeks ago
parent
commit
427081c937
  1. 2
      lib/models/contact.dart
  2. 4
      lib/models/message.dart
  3. 3
      lib/models/messages/quotedmessage.dart
  4. 3
      lib/models/messages/textmessage.dart
  5. 6
      lib/views/contactsview.dart
  6. 5
      lib/views/globalsettingsview.dart
  7. 9
      lib/views/messageview.dart

2
lib/models/contact.dart

@ -145,7 +145,7 @@ class ContactInfoState extends ChangeNotifier {
}
void selected() {
this._newMarkerMsgIndex = this._unreadMessages-1;
this._newMarkerMsgIndex = this._unreadMessages - 1;
this._unreadMessages = 0;
}

4
lib/models/message.dart

@ -38,8 +38,7 @@ abstract class Message {
}
Message compileOverlay(MessageInfo messageInfo) {
try {
try {
dynamic message = jsonDecode(messageInfo.wrapper);
var content = message['d'] as dynamic;
var overlay = int.parse(message['o'].toString());
@ -93,7 +92,6 @@ class ByIndex implements CacheHandler {
amount += index - start;
}
// check that we aren't asking for messages beyond stored messages
if (start + amount >= cache.storageMessageCount) {
amount = cache.storageMessageCount - start;

3
lib/models/messages/quotedmessage.dart

@ -59,7 +59,8 @@ class QuotedMessage extends Message {
return ChangeNotifierProvider.value(
value: this.metadata,
builder: (bcontext, child) {
return MessageRow(QuotedMessageBubble(message["body"], messageHandler(bcontext, metadata.profileOnion, metadata.conversationIdentifier, ByContentHash(message["quotedHash"]))), index, key: key);
return MessageRow(QuotedMessageBubble(message["body"], messageHandler(bcontext, metadata.profileOnion, metadata.conversationIdentifier, ByContentHash(message["quotedHash"]))), index,
key: key);
});
} catch (e) {
return MalformedBubble();

3
lib/models/messages/textmessage.dart

@ -34,7 +34,8 @@ class TextMessage extends Message {
value: this.metadata,
builder: (bcontext, child) {
return MessageRow(
MessageBubble(this.content), index,
MessageBubble(this.content),
index,
key: key,
);
});

6
lib/views/contactsview.dart

@ -32,11 +32,7 @@ void selectConversation(BuildContext context, int handle) {
var initialIndex = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(handle)!.unreadMessages;
var previouslySelected = Provider.of<AppState>(context, listen: false).selectedConversation;
if (previouslySelected != null) {
Provider
.of<ProfileInfoState>(context, listen: false)
.contactList
.getContact(previouslySelected)!
.unselected();
Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(previouslySelected)!.unselected();
}
Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(handle)!.selected();
// triggers update in Double/TripleColumnView

5
lib/views/globalsettingsview.dart

@ -110,6 +110,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
trailing: Container(
width: MediaQuery.of(context).size.width / 4,
child: DropdownButton(
isExpanded: true,
value: Provider.of<Settings>(context).locale.languageCode,
onChanged: (String? newValue) {
setState(() {
@ -146,7 +147,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
width: MediaQuery.of(context).size.width / 4,
child: DropdownButton<String>(
key: Key("DropdownTheme"),
isDense: true,
isExpanded: true,
value: Provider.of<Settings>(context).theme.theme,
onChanged: (String? newValue) {
setState(() {
@ -168,6 +169,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
trailing: Container(
width: MediaQuery.of(context).size.width / 4,
child: DropdownButton(
isExpanded: true,
value: settings.uiColumnModePortrait.toString(),
onChanged: (String? newValue) {
settings.uiColumnModePortrait = Settings.uiColumnModeFromString(newValue!);
@ -249,6 +251,7 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
trailing: Container(
width: MediaQuery.of(context).size.width / 4,
child: DropdownButton(
isExpanded: true,
value: settings.notificationPolicy,
onChanged: (NotificationPolicy? newValue) {
settings.notificationPolicy = newValue!;

9
lib/views/messageview.dart

@ -171,11 +171,7 @@ class _MessageViewState extends State<MessageView> {
var previouslySelected = Provider.of<AppState>(context, listen: false).selectedConversation;
if (previouslySelected != null) {
Provider
.of<ProfileInfoState>(context, listen: false)
.contactList
.getContact(previouslySelected)!
.unselected();
Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(previouslySelected)!.unselected();
}
Provider.of<AppState>(context, listen: false).selectedConversation = null;
@ -230,7 +226,8 @@ class _MessageViewState extends State<MessageView> {
if (Provider.of<AppState>(context, listen: false).selectedConversation != null && Provider.of<AppState>(context, listen: false).selectedIndex != null) {
var conversationId = Provider.of<AppState>(context, listen: false).selectedConversation!;
MessageCache? cache = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(conversationId)?.messageCache;
ById(Provider.of<AppState>(context, listen: false).selectedIndex!).get(Provider.of<FlwtchState>(context, listen: false).cwtch, Provider.of<AppState>(context, listen: false).selectedProfile!, conversationId, cache!)
ById(Provider.of<AppState>(context, listen: false).selectedIndex!)
.get(Provider.of<FlwtchState>(context, listen: false).cwtch, Provider.of<AppState>(context, listen: false).selectedProfile!, conversationId, cache!)
.then((MessageInfo? data) {
try {
var bytes1 = utf8.encode(data!.metadata.senderHandle + data.wrapper);

Loading…
Cancel
Save