fix crash in chat_screen.dart, try to resolve test error.
This commit is contained in:
1 parent
4000c49213
commit
de6632d70e
3 files changed
+43
-37
No files matched your search
@@ -3794,6 +3794,9 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
if (pendingAck != null) {
|
||||
_pendingGenericAckQueue.remove(pendingAck);
|
||||
}
|
||||
if (_activeTransport == MeshCoreTransportType.tcp) {
|
||||
unawaited(disconnect(manual: false));
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
@@ -5846,17 +5849,16 @@ class MeshCoreConnector extends ChangeNotifier {
|
||||
_findChannelByIndex(index)?.storageId ?? _slotChannelIds[index];
|
||||
// Delete by setting empty name and zero PSK
|
||||
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.
|
||||
final stillHeld = _channels.any(
|
||||
(channel) => channel.index != index && channel.storageId == channelId,
|
||||
);
|
||||
final stillHeld = _slotChannelIds.containsValue(channelId);
|
||||
if (channelId != null && !stillHeld) {
|
||||
await _clearChannelStorage(channelId);
|
||||
}
|
||||
_channelMessages.remove(index);
|
||||
_processedChannelReactions.remove(index);
|
||||
// Refresh channels after deleting
|
||||
await getChannels(force: true);
|
||||
}
|
||||
|
||||
/// Removes everything persisted for [channelId]: messages, settings,
|
||||
|
||||
@@ -675,7 +675,16 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
onChanged: settingsService.setChannelMinHopsCountRepeaters,
|
||||
),
|
||||
],
|
||||
const Divider(height: 1, indent: 16),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImageMessagesContent(
|
||||
BuildContext context,
|
||||
AppSettingsService settingsService,
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
@@ -688,16 +697,6 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
onTap: () => _showIpfsImageLinksDialog(context, settingsService),
|
||||
),
|
||||
const Divider(height: 1, indent: 16),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImageMessagesContent(
|
||||
BuildContext context,
|
||||
AppSettingsService settingsService,
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
_ScrollIntoViewOnce(
|
||||
enabled: focusImageMessages,
|
||||
child: SwitchListTile(
|
||||
|
||||
@@ -507,9 +507,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
final useEncoder =
|
||||
connector.isContactSmazEnabled(keyHex) ||
|
||||
connector.isContactCyr2LatEnabled(keyHex);
|
||||
final showIpfsAction = context.select<AppSettingsService, bool>(
|
||||
(s) => s.settings.uploadIpfsEndpoint.trim().isNotEmpty,
|
||||
);
|
||||
return ChatComposer(
|
||||
controller: _textController,
|
||||
focusNode: _textFieldFocusNode,
|
||||
@@ -525,24 +522,32 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
sendTooltip: context.l10n.chat_sendMessageTo(
|
||||
_resolveContact(connector).name,
|
||||
),
|
||||
actionsBuilder: () => [
|
||||
ChatComposerAction(
|
||||
id: 'gif',
|
||||
icon: Icons.gif_box,
|
||||
label: context.l10n.chat_sendGif,
|
||||
),
|
||||
if (showIpfsAction)
|
||||
actionsBuilder: () {
|
||||
final showIpfsAction = context
|
||||
.read<AppSettingsService>()
|
||||
.settings
|
||||
.uploadIpfsEndpoint
|
||||
.trim()
|
||||
.isNotEmpty;
|
||||
return [
|
||||
ChatComposerAction(
|
||||
id: 'ipfs-image',
|
||||
icon: Icons.cloud_upload_outlined,
|
||||
label: context.l10n.chat_sendImageIpfs,
|
||||
id: 'gif',
|
||||
icon: Icons.gif_box,
|
||||
label: context.l10n.chat_sendGif,
|
||||
),
|
||||
ChatComposerAction(
|
||||
id: 'send-my-location',
|
||||
icon: Icons.my_location,
|
||||
label: context.l10n.chat_shareMyLocation,
|
||||
),
|
||||
],
|
||||
if (showIpfsAction)
|
||||
ChatComposerAction(
|
||||
id: 'ipfs-image',
|
||||
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) {
|
||||
if (!mounted) return;
|
||||
switch (action) {
|
||||
|
||||
Reference in new issue
Block a user