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: [ children: [
Expanded( Expanded(
child: Text( child: Text(
lastMessage?.title ?? '...', _preformatTitle(lastMessage),
style: TextStyle(color: Theme.of(context).textTheme.bodyLarge?.color?.withAlpha(160)), 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:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:simplecloudnotifier/api/api_client.dart'; import 'package:simplecloudnotifier/api/api_client.dart';
@ -21,9 +20,6 @@ class MessageListPage extends StatefulWidget {
final bool isVisiblePage; final bool isVisiblePage;
//TODO reload on switch to tab
//TODO reload on app to foreground
@override @override
State<MessageListPage> createState() => _MessageListPageState(); State<MessageListPage> createState() => _MessageListPageState();
} }
@ -111,15 +107,17 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
@override @override
void didPopNext() { void didPopNext() {
if (AppSettings().alwaysBackgroundRefreshMessageListOnPop) { if (AppSettings().backgroundRefreshMessageListOnPop) {
ApplicationLog.debug('[MessageList::RouteObserver] --> didPopNext (will background-refresh)'); ApplicationLog.debug('[MessageList::RouteObserver] --> didPopNext (will background-refresh)');
_backgroundRefresh(false); _backgroundRefresh(false);
} }
} }
void _onLifecycleResume() { void _onLifecycleResume() {
ApplicationLog.debug('[MessageList::_onLifecycleResume] --> (will background-refresh)'); if (AppSettings().alwaysBackgroundRefreshMessageListOnLifecycleResume) {
_backgroundRefresh(false); ApplicationLog.debug('[MessageList::_onLifecycleResume] --> (will background-refresh)');
_backgroundRefresh(false);
}
} }
Future<void> _fetchPage(String thisPageToken) async { Future<void> _fetchPage(String thisPageToken) async {

View File

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