Skip to content

Commit

Permalink
fix possible message missing due to top channel start block.
Browse files Browse the repository at this point in the history
  • Loading branch information
shuotwang committed Oct 23, 2022
1 parent 16ea786 commit 09bcbfd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class MainActivity : FlutterFragmentActivity() {
private val CHANNEL = "clipboard/image"


override fun configureFlutterEngdine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
// override fun configureFlutterEngdine(@NonNull flutterEngine: FlutterEngine) {
// super.configureFlutterEngine(flutterEngine)
// MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler {
// if (call.method == "getBatteryLevel") {
// val batteryLevel = getBatteryLevel()
Expand All @@ -40,7 +40,7 @@ class MainActivity : FlutterFragmentActivity() {
// result.notImplemented()
// }
// }
}
// }

// private fun getBatteryLevel(): Int {
// val batteryLevel: Int
Expand Down
26 changes: 12 additions & 14 deletions lib/ui/chats/chat/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class _ChatPageState extends State<ChatPage> {

@override
Widget build(BuildContext context) {
for (final each in _uiMsgList) {
print(each.chatMsgM.values);
}
return Scaffold(
backgroundColor: Colors.white,
appBar: ChatBar(
Expand Down Expand Up @@ -533,20 +536,13 @@ class _ChatPageState extends State<ChatPage> {
break;
}

sortUiMsgList();

_uiMsgList.sort((a, b) => b.chatMsgM.mid.compareTo(a.chatMsgM.mid));

if (mounted) {
setState(() {});
}
}

void sortUiMsgList() {
// sort success messages by mid (from server);
// sort remaining local unsuccessful messages by timestamps.
}

Future<void> _onReaction(ReactionTypes type, int mid,
[ChatMsgM? chatMsgM]) async {
switch (type) {
Expand Down Expand Up @@ -965,13 +961,14 @@ class _ChatPageState extends State<ChatPage> {
itemCount: _uiMsgList.length + 1,
itemBuilder: (context, index) {
// If reaches very top, show channel start widget.
if (index == widget.msgCount) {
if (widget._isGroup) {
return ChannelStart(widget.groupInfoNotifier!);
} else {
return SizedBox.shrink();
}
} else if (index == _uiMsgList.length) {
// if (index == widget.msgCount) {
// if (widget._isGroup) {
// return ChannelStart(widget.groupInfoNotifier!);
// } else {
// return SizedBox.shrink();
// }
// } else
if (index == _uiMsgList.length) {
if (_isLoadingHistory) {
return SizedBox(
height: 20,
Expand All @@ -982,6 +979,7 @@ class _ChatPageState extends State<ChatPage> {
}
} else {
UiMsg uiMsg = _uiMsgList[index];

final userInfoM =
_userInfoMMap[uiMsg.chatMsgM.fromUid] ?? UserInfoM.deleted();
final isSelf = userInfoM.uid == App.app.userDb!.uid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class AppTextSelectionControls extends CupertinoTextSelectionControls {
int? uid;
int? gid;

static const double _kToolbarContentDistanceBelow = 10.0;
static const double _kToolbarContentDistance = 8.0;

// Function(ImageProvider) callback;
AppTextSelectionControls();

@override
Expand Down

0 comments on commit 09bcbfd

Please sign in to comment.