fix crash in chat_screen.dart, try to resolve test error.

This commit is contained in:
ZIER committed 2026-10-13 11:19:29 +02:00
1 parent 4000c49213
commit de6632d70e
3 files changed
+43 -37

No files matched your search

+9 -7
View File
@@ -3794,6 +3794,9 @@ class MeshCoreConnector extends ChangeNotifier {
if (pendingAck != null) { if (pendingAck != null) {
_pendingGenericAckQueue.remove(pendingAck); _pendingGenericAckQueue.remove(pendingAck);
} }
if (_activeTransport == MeshCoreTransportType.tcp) {
unawaited(disconnect(manual: false));
}
rethrow; rethrow;
} }
@@ -5846,17 +5849,16 @@ class MeshCoreConnector extends ChangeNotifier {
_findChannelByIndex(index)?.storageId ?? _slotChannelIds[index]; _findChannelByIndex(index)?.storageId ?? _slotChannelIds[index];
// Delete by setting empty name and zero PSK // Delete by setting empty name and zero PSK
await sendFrame(buildSetChannelFrame(index, '', Uint8List(16))); await sendFrame(buildSetChannelFrame(index, '', Uint8List(16)));
_channelMessages.remove(index);
_processedChannelReactions.remove(index);
// Refresh before clearing history so messages from an in-flight queue sync
// cannot recreate the channel's stored history after it has been deleted.
await getChannels(force: true);
// Another slot holding the same PSK keeps the shared history. // Another slot holding the same PSK keeps the shared history.
final stillHeld = _channels.any( final stillHeld = _slotChannelIds.containsValue(channelId);
(channel) => channel.index != index && channel.storageId == channelId,
);
if (channelId != null && !stillHeld) { if (channelId != null && !stillHeld) {
await _clearChannelStorage(channelId); await _clearChannelStorage(channelId);
} }
_channelMessages.remove(index);
_processedChannelReactions.remove(index);
// Refresh channels after deleting
await getChannels(force: true);
} }
/// Removes everything persisted for [channelId]: messages, settings, /// Removes everything persisted for [channelId]: messages, settings,
+10 -11
View File
@@ -675,7 +675,16 @@ class AppSettingsScreen extends StatelessWidget {
onChanged: settingsService.setChannelMinHopsCountRepeaters, onChanged: settingsService.setChannelMinHopsCountRepeaters,
), ),
], ],
const Divider(height: 1, indent: 16), ],
);
}
Widget _buildImageMessagesContent(
BuildContext context,
AppSettingsService settingsService,
) {
return Column(
children: [
ListTile( ListTile(
contentPadding: const EdgeInsets.symmetric( contentPadding: const EdgeInsets.symmetric(
horizontal: 16, horizontal: 16,
@@ -688,16 +697,6 @@ class AppSettingsScreen extends StatelessWidget {
onTap: () => _showIpfsImageLinksDialog(context, settingsService), onTap: () => _showIpfsImageLinksDialog(context, settingsService),
), ),
const Divider(height: 1, indent: 16), const Divider(height: 1, indent: 16),
],
);
}
Widget _buildImageMessagesContent(
BuildContext context,
AppSettingsService settingsService,
) {
return Column(
children: [
_ScrollIntoViewOnce( _ScrollIntoViewOnce(
enabled: focusImageMessages, enabled: focusImageMessages,
child: SwitchListTile( child: SwitchListTile(
+24 -19
View File
@@ -507,9 +507,6 @@ class _ChatScreenState extends State<ChatScreen> {
final useEncoder = final useEncoder =
connector.isContactSmazEnabled(keyHex) || connector.isContactSmazEnabled(keyHex) ||
connector.isContactCyr2LatEnabled(keyHex); connector.isContactCyr2LatEnabled(keyHex);
final showIpfsAction = context.select<AppSettingsService, bool>(
(s) => s.settings.uploadIpfsEndpoint.trim().isNotEmpty,
);
return ChatComposer( return ChatComposer(
controller: _textController, controller: _textController,
focusNode: _textFieldFocusNode, focusNode: _textFieldFocusNode,
@@ -525,24 +522,32 @@ class _ChatScreenState extends State<ChatScreen> {
sendTooltip: context.l10n.chat_sendMessageTo( sendTooltip: context.l10n.chat_sendMessageTo(
_resolveContact(connector).name, _resolveContact(connector).name,
), ),
actionsBuilder: () => [ actionsBuilder: () {
ChatComposerAction( final showIpfsAction = context
id: 'gif', .read<AppSettingsService>()
icon: Icons.gif_box, .settings
label: context.l10n.chat_sendGif, .uploadIpfsEndpoint
), .trim()
if (showIpfsAction) .isNotEmpty;
return [
ChatComposerAction( ChatComposerAction(
id: 'ipfs-image', id: 'gif',
icon: Icons.cloud_upload_outlined, icon: Icons.gif_box,
label: context.l10n.chat_sendImageIpfs, label: context.l10n.chat_sendGif,
), ),
ChatComposerAction( if (showIpfsAction)
id: 'send-my-location', ChatComposerAction(
icon: Icons.my_location, id: 'ipfs-image',
label: context.l10n.chat_shareMyLocation, icon: Icons.cloud_upload_outlined,
), label: context.l10n.chat_sendImageIpfs,
], ),
ChatComposerAction(
id: 'send-my-location',
icon: Icons.my_location,
label: context.l10n.chat_shareMyLocation,
),
];
},
onAction: (action) { onAction: (action) {
if (!mounted) return; if (!mounted) return;
switch (action) { switch (action) {