Quoted Message Fixes / New Message Label Offet Fixes
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
880c1c107b
commit
c00bfbb48b
|
@ -35,6 +35,10 @@ abstract class Cwtch {
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<dynamic> GetMessage(String profile, int handle, int index);
|
Future<dynamic> GetMessage(String profile, int handle, int index);
|
||||||
|
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
Future<dynamic> GetMessageByID(String profile, int handle, int index);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<dynamic> GetMessageByContentHash(String profile, int handle, String contentHash);
|
Future<dynamic> GetMessageByContentHash(String profile, int handle, String contentHash);
|
||||||
|
|
||||||
|
|
|
@ -694,4 +694,17 @@ class CwtchFfi implements Cwtch {
|
||||||
final Free = free.asFunction<FreeFn>();
|
final Free = free.asFunction<FreeFn>();
|
||||||
Free(ptr);
|
Free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> GetMessageByID(String profile, int handle, int index) async {
|
||||||
|
var getMessageC = library.lookup<NativeFunction<get_json_blob_from_str_int_int_function>>("c_GetMessageByID");
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
final GetMessage = getMessageC.asFunction<GetJsonBlobFromStrIntIntFn>();
|
||||||
|
final utf8profile = profile.toNativeUtf8();
|
||||||
|
Pointer<Utf8> jsonMessageBytes = GetMessage(utf8profile, utf8profile.length, handle, index);
|
||||||
|
String jsonMessage = jsonMessageBytes.toDartString();
|
||||||
|
_UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(jsonMessageBytes);
|
||||||
|
malloc.free(utf8profile);
|
||||||
|
return jsonMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,10 +88,14 @@ class CwtchGomobile implements Cwtch {
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<dynamic> GetMessage(String profile, int handle, int index) {
|
Future<dynamic> GetMessage(String profile, int handle, int index) {
|
||||||
print("gomobile.dart GetMessage " + index.toString());
|
|
||||||
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index});
|
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
Future<dynamic> GetMessageByID(String profile, int handle, int index) {
|
||||||
|
return cwtchPlatform.invokeMethod("GetMessageByID", {"profile": profile, "contact": handle, "index": index});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SendProfileEvent(String onion, String jsonEvent) {
|
void SendProfileEvent(String onion, String jsonEvent) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:cwtch/config.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -31,9 +32,16 @@ abstract class Message {
|
||||||
Widget getPreviewWidget(BuildContext context);
|
Widget getPreviewWidget(BuildContext context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Message> messageHandler(BuildContext context, String profileOnion, int conversationIdentifier, int index) {
|
Future<Message> messageHandler(BuildContext context, String profileOnion, int conversationIdentifier, int index, {bool byID = false}) {
|
||||||
try {
|
try {
|
||||||
var rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessage(profileOnion, conversationIdentifier, index);
|
Future<dynamic> rawMessageEnvelopeFuture;
|
||||||
|
|
||||||
|
if (byID) {
|
||||||
|
rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessageByID(profileOnion, conversationIdentifier, index);
|
||||||
|
} else {
|
||||||
|
rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessage(profileOnion, conversationIdentifier, index);
|
||||||
|
}
|
||||||
|
|
||||||
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
||||||
var metadata = MessageMetadata(profileOnion, conversationIdentifier, index, -1, DateTime.now(), "", "", null, 0, false, true);
|
var metadata = MessageMetadata(profileOnion, conversationIdentifier, index, -1, DateTime.now(), "", "", null, 0, false, true);
|
||||||
try {
|
try {
|
||||||
|
@ -50,7 +58,7 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
||||||
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
||||||
return Future.delayed(Duration(seconds: 2), () {
|
return Future.delayed(Duration(seconds: 2), () {
|
||||||
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
||||||
return messageHandler(context, profileOnion, conversationIdentifier, index).then((value) => value);
|
return messageHandler(context, profileOnion, conversationIdentifier, index, byID: byID).then((value) => value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +92,7 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
||||||
return MalformedMessage(metadata);
|
return MalformedMessage(metadata);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("an error! " + e.toString());
|
EnvironmentConfig.debugLog("an error! " + e.toString());
|
||||||
return MalformedMessage(metadata);
|
return MalformedMessage(metadata);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -168,7 +168,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
if (Provider.of<AppState>(context, listen: false).selectedConversation != null && Provider.of<AppState>(context, listen: false).selectedIndex != null) {
|
if (Provider.of<AppState>(context, listen: false).selectedConversation != null && Provider.of<AppState>(context, listen: false).selectedIndex != null) {
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
.GetMessage(Provider.of<AppState>(context, listen: false).selectedProfile!, Provider.of<AppState>(context, listen: false).selectedConversation!,
|
.GetMessageByID(Provider.of<AppState>(context, listen: false).selectedProfile!, Provider.of<AppState>(context, listen: false).selectedConversation!,
|
||||||
Provider.of<AppState>(context, listen: false).selectedIndex!)
|
Provider.of<AppState>(context, listen: false).selectedIndex!)
|
||||||
.then((data) {
|
.then((data) {
|
||||||
try {
|
try {
|
||||||
|
@ -268,7 +268,8 @@ class _MessageViewState extends State<MessageView> {
|
||||||
var children;
|
var children;
|
||||||
if (Provider.of<AppState>(context).selectedConversation != null && Provider.of<AppState>(context).selectedIndex != null) {
|
if (Provider.of<AppState>(context).selectedConversation != null && Provider.of<AppState>(context).selectedIndex != null) {
|
||||||
var quoted = FutureBuilder(
|
var quoted = FutureBuilder(
|
||||||
future: messageHandler(context, Provider.of<AppState>(context).selectedProfile!, Provider.of<AppState>(context).selectedConversation!, Provider.of<AppState>(context).selectedIndex!),
|
future:
|
||||||
|
messageHandler(context, Provider.of<AppState>(context).selectedProfile!, Provider.of<AppState>(context).selectedConversation!, Provider.of<AppState>(context).selectedIndex!, byID: true),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
var message = snapshot.data! as Message;
|
var message = snapshot.data! as Message;
|
||||||
|
|
|
@ -77,7 +77,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
tooltip: AppLocalizations.of(context)!.tooltipReplyToThisMessage,
|
tooltip: AppLocalizations.of(context)!.tooltipReplyToThisMessage,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Provider.of<AppState>(context, listen: false).selectedIndex = Provider.of<MessageMetadata>(context, listen: false).messageIndex;
|
Provider.of<AppState>(context, listen: false).selectedIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||||
},
|
},
|
||||||
icon: Icon(Icons.reply, color: Provider.of<Settings>(context).theme.dropShadowColor())));
|
icon: Icon(Icons.reply, color: Provider.of<Settings>(context).theme.dropShadowColor())));
|
||||||
Widget wdgSpacer = Flexible(child: SizedBox(width: 60, height: 10));
|
Widget wdgSpacer = Flexible(child: SizedBox(width: 60, height: 10));
|
||||||
|
@ -185,7 +185,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
},
|
},
|
||||||
onPanEnd: (details) {
|
onPanEnd: (details) {
|
||||||
_runAnimation(details.velocity.pixelsPerSecond, size);
|
_runAnimation(details.velocity.pixelsPerSecond, size);
|
||||||
Provider.of<AppState>(context, listen: false).selectedIndex = Provider.of<MessageMetadata>(context, listen: false).messageIndex;
|
Provider.of<AppState>(context, listen: false).selectedIndex = Provider.of<MessageMetadata>(context, listen: false).messageID;
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(2),
|
padding: EdgeInsets.all(2),
|
||||||
|
@ -198,8 +198,8 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
children: widgetRow,
|
children: widgetRow,
|
||||||
)))));
|
)))));
|
||||||
var mark = Provider.of<ContactInfoState>(context).newMarker;
|
var mark = Provider.of<ContactInfoState>(context).newMarker;
|
||||||
if (mark > 0 && mark == Provider.of<ContactInfoState>(context).totalMessages - Provider.of<MessageMetadata>(context).messageIndex) {
|
if (mark > 0 && mark == Provider.of<MessageMetadata>(context).messageIndex + 1) {
|
||||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [Align(alignment: Alignment.center, child: _bubbleNew()), mr]);
|
return Column(crossAxisAlignment: fromMe ? CrossAxisAlignment.end : CrossAxisAlignment.start, children: [Align(alignment: Alignment.center, child: _bubbleNew()), mr]);
|
||||||
} else {
|
} else {
|
||||||
return mr;
|
return mr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue