try to please codex

This commit is contained in:
ericz 2026-04-07 18:53:53 +02:00
parent 6dad343004
commit 74a0a3960e
4 changed files with 21 additions and 13 deletions

View file

@ -2407,8 +2407,9 @@ class MeshCoreConnector extends ChangeNotifier {
_locationSharingContactKey = contactKey;
_locationSharingChannelIndex = channelIndex;
_lastSharedLocationPositionKey = null;
final gpsInterval =
final rawGpsInterval =
int.tryParse(_currentCustomVars?['gps_interval'] ?? '') ?? 900;
final gpsInterval = rawGpsInterval > 0 ? rawGpsInterval : 900;
_sendLocationOnce(contactKey, channelIndex);
_locationSharingTimer = Timer.periodic(Duration(seconds: gpsInterval), (_) {
if (!isConnected || DateTime.now().isAfter(_locationSharingEnd!)) {
@ -5547,6 +5548,10 @@ class MeshCoreConnector extends ChangeNotifier {
_stopRadioStatsPolling();
_locationSharingTimer?.cancel();
_locationSharingTimer = null;
_locationSharingEnd = null;
_locationSharingContactKey = null;
_locationSharingChannelIndex = null;
_lastSharedLocationPositionKey = null;
_latestRadioStats = null;
radioStatsNotifier.value = null;
_prevTotalAirSecs = 0;

View file

@ -974,9 +974,10 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
maxBytes - utf8.encode(prefix).length - utf8.encode(suffix).length;
if (allowsTimedLocationSharing) {
final gpsInterval =
final rawGpsInterval =
int.tryParse(connector.currentCustomVars?['gps_interval'] ?? '') ??
900;
final gpsInterval = rawGpsInterval > 0 ? rawGpsInterval : 900;
final minIntervals = (300.0 / gpsInterval).ceil().clamp(2, 9999);
final sliderMax = ((86400 / gpsInterval).floor() - minIntervals + 1)
.clamp(1, 99999);

View file

@ -508,6 +508,7 @@ class _ChatScreenState extends State<ChatScreen> {
? Smaz.encodeIfSmaller
: null;
final gpsEnabled = connector.currentCustomVars?['gps'] == '1';
final isRoomChat = _resolveContact(connector).type == advTypeRoom;
final sharingHere =
connector.locationSharingContactKey == widget.contact.publicKeyHex;
return Column(
@ -565,7 +566,7 @@ class _ChatScreenState extends State<ChatScreen> {
itemBuilder: (context) => [
PopupMenuItem(
value: _ChatInputAction.shareLocation,
enabled: gpsEnabled,
enabled: gpsEnabled && !isRoomChat,
child: Row(
children: [
const Icon(Icons.my_location, size: 20),
@ -606,7 +607,7 @@ class _ChatScreenState extends State<ChatScreen> {
child: ValueListenableBuilder<TextEditingValue>(
valueListenable: _textController,
builder: (context, value, child) {
final gifId = _parseGifId(value.text);
final gifId = GifHelper.parseGif(value.text);
if (gifId != null) {
return Focus(
autofocus: true,
@ -686,12 +687,6 @@ class _ChatScreenState extends State<ChatScreen> {
);
}
String? _parseGifId(String text) {
final trimmed = text.trim();
final match = RegExp(r'^g:([A-Za-z0-9_-]+)$').firstMatch(trimmed);
return match?.group(1);
}
void _insertTextAtCursor(String text) {
final currentValue = _textController.value;
final selection = currentValue.selection;
@ -723,6 +718,10 @@ class _ChatScreenState extends State<ChatScreen> {
}
Future<void> _shareLocation(MeshCoreConnector connector) async {
if (_resolveContact(connector).type == advTypeRoom) {
return;
}
final lat = connector.selfLatitude;
final lon = connector.selfLongitude;
if (lat == null || lon == null) {
@ -757,8 +756,9 @@ class _ChatScreenState extends State<ChatScreen> {
const suffix = '|loc';
final maxLabelBytes =
maxBytes - utf8.encode(prefix).length - utf8.encode(suffix).length;
final gpsInterval =
final rawGpsInterval =
int.tryParse(connector.currentCustomVars?['gps_interval'] ?? '') ?? 900;
final gpsInterval = rawGpsInterval > 0 ? rawGpsInterval : 900;
final minIntervals = (300.0 / gpsInterval).ceil().clamp(2, 9999);
final sliderMax = ((86400 / gpsInterval).floor() - minIntervals + 1).clamp(
1,

View file

@ -1310,7 +1310,7 @@ class _MapScreenState extends State<MapScreen> {
final flags = parts.length > 2 ? parts[2].trim() : '';
return _MarkerPayload(
position: LatLng(lat, lon),
label: label.isEmpty ? context.l10n.map_sharedPin : label,
label: label,
flags: flags,
);
}
@ -1539,7 +1539,9 @@ class _MapScreenState extends State<MapScreen> {
showDialog(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(marker.label),
title: Text(
marker.label.isEmpty ? context.l10n.map_sharedPin : marker.label,
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,