fix linebreaks in message.title in channel_list_item

This commit is contained in:
Mike Schwörer 2024-06-18 17:36:41 +02:00
parent 59d28d3c49
commit 9542405512
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 13 additions and 9 deletions

View File

@ -76,7 +76,7 @@ class _ChannelListItemState extends State<ChannelListItem> {
children: [
Expanded(
child: Text(
lastMessage?.title ?? '...',
_preformatTitle(lastMessage),
style: TextStyle(color: Theme.of(context).textTheme.bodyLarge?.color?.withAlpha(160)),
),
),
@ -89,4 +89,9 @@ class _ChannelListItemState extends State<ChannelListItem> {
),
);
}
String _preformatTitle(SCNMessage? message) {
if (message == null) return '...';
return message.title.replaceAll('\n', '').replaceAll('\r', '').replaceAll('\t', ' ');
}
}

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:provider/provider.dart';
import 'package:simplecloudnotifier/api/api_client.dart';
@ -21,9 +20,6 @@ class MessageListPage extends StatefulWidget {
final bool isVisiblePage;
//TODO reload on switch to tab
//TODO reload on app to foreground
@override
State<MessageListPage> createState() => _MessageListPageState();
}
@ -111,16 +107,18 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
@override
void didPopNext() {
if (AppSettings().alwaysBackgroundRefreshMessageListOnPop) {
if (AppSettings().backgroundRefreshMessageListOnPop) {
ApplicationLog.debug('[MessageList::RouteObserver] --> didPopNext (will background-refresh)');
_backgroundRefresh(false);
}
}
void _onLifecycleResume() {
if (AppSettings().alwaysBackgroundRefreshMessageListOnLifecycleResume) {
ApplicationLog.debug('[MessageList::_onLifecycleResume] --> (will background-refresh)');
_backgroundRefresh(false);
}
}
Future<void> _fetchPage(String thisPageToken) async {
final acc = Provider.of<AppAuth>(context, listen: false);

View File

@ -4,7 +4,8 @@ class AppSettings extends ChangeNotifier {
bool groupNotifications = true;
int messagePageSize = 128;
bool showDebugButton = true;
bool alwaysBackgroundRefreshMessageListOnPop = false;
bool backgroundRefreshMessageListOnPop = false;
bool alwaysBackgroundRefreshMessageListOnLifecycleResume = true;
static AppSettings? _singleton = AppSettings._internal();