finish sender_list && plain-text-search

This commit is contained in:
2025-04-13 17:43:18 +02:00
parent c1e465020f
commit 6ec1d80f49
9 changed files with 219 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
enum MessageFilterChipletType {
search,
plainSearch,
channel,
sender,
timeRange,
@@ -21,6 +22,8 @@ class MessageFilterChiplet {
switch (type) {
case MessageFilterChipletType.search:
return FontAwesomeIcons.magnifyingGlass;
case MessageFilterChipletType.plainSearch:
return FontAwesomeIcons.magnifyingGlassPlus;
case MessageFilterChipletType.channel:
return FontAwesomeIcons.snake;
case MessageFilterChipletType.sender:

View File

@@ -30,6 +30,7 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
PagingController<String, SCNMessage> _pagingController = PagingController.fromValue(PagingState(nextPageKey: null, itemList: [], error: null), firstPageKey: '@start');
Map<String, Channel>? _channels = null;
bool _channelsFetched = false;
bool _isInitialized = false;
@@ -135,9 +136,12 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
}
try {
if (_channels == null) {
if (_channels == null || !_channelsFetched) {
final channels = await APIClient.getChannelList(acc, ChannelSelector.allAny);
_channels = <String, Channel>{for (var v in channels) v.channel.channelID: v.channel};
setState(() {
_channels = <String, Channel>{for (var v in channels) v.channel.channelID: v.channel};
_channelsFetched = true;
});
SCNDataCache().setChannelCache(channels); // no await
}
@@ -314,6 +318,11 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
filter.searchFilter = chipletsSearch.map((p) => p.value as String).toList();
}
var chipletsPlainSearch = _filterChiplets.where((p) => p.type == MessageFilterChipletType.plainSearch).toList();
if (chipletsPlainSearch.isNotEmpty) {
filter.plainSearchFilter = chipletsPlainSearch.map((p) => p.value as String).toList();
}
var chipletsKeyTokens = _filterChiplets.where((p) => p.type == MessageFilterChipletType.sendkey).toList();
if (chipletsKeyTokens.isNotEmpty) {
filter.usedKeys = chipletsKeyTokens.map((p) => p.value as String).toList();
@@ -329,6 +338,13 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
filter.senderNames = chipletSender.map((p) => p.value as String).toList();
}
var chipletsTimeRange = _filterChiplets.where((p) => p.type == MessageFilterChipletType.timeRange).toList();
if (chipletsTimeRange.isNotEmpty) {
//TODO
//filter.timeAfter = chipletsTimeRange[0].value1 as DateTime;
//filter.timeBefore = chipletsTimeRange[0].value2 as DateTime;
}
return filter;
}
}