simplify: dedupe boilerplate and remove dead code across all layers
This commit is contained in:
@@ -4,18 +4,6 @@ import '../../../../theming/app_theme.dart';
|
||||
import '../widgets/bubble.dart';
|
||||
|
||||
extension ColorExtensions on Color {
|
||||
Color invert() {
|
||||
final invertedR = 1.0 - r;
|
||||
final invertedG = 1.0 - g;
|
||||
final invertedB = 1.0 - b;
|
||||
return Color.from(
|
||||
alpha: a,
|
||||
red: invertedR,
|
||||
green: invertedG,
|
||||
blue: invertedB,
|
||||
);
|
||||
}
|
||||
|
||||
Color withWhite(int whiteValue) {
|
||||
final value = whiteValue / 255.0;
|
||||
return Color.from(alpha: a, red: value, green: value, blue: value);
|
||||
|
||||
@@ -16,8 +16,6 @@ class ChatMessage {
|
||||
RichObjectString? file;
|
||||
String content = '';
|
||||
|
||||
bool get containsFile => file != null;
|
||||
|
||||
ChatMessage({required this.originalMessage, this.originalData}) {
|
||||
if (originalData?.containsKey('file') ?? false) {
|
||||
file = originalData?['file'];
|
||||
|
||||
@@ -10,6 +10,14 @@ class ChatSearchMatch {
|
||||
}
|
||||
|
||||
class ChatSearchController {
|
||||
/// System messages that are folded into other bubbles (reactions, poll
|
||||
/// votes, deletions) and therefore never rendered nor searched as their own
|
||||
/// entry.
|
||||
static bool isHiddenSystemMessage(GetChatResponseObject element) =>
|
||||
element.systemMessage.contains('reaction') ||
|
||||
element.systemMessage.contains('poll_voted') ||
|
||||
element.systemMessage.contains('message_deleted');
|
||||
|
||||
static List<ChatSearchMatch> findMatches(
|
||||
GetChatResponse response,
|
||||
String query,
|
||||
@@ -19,9 +27,7 @@ class ChatSearchController {
|
||||
|
||||
final matches = <ChatSearchMatch>[];
|
||||
for (final element in response.sortByTimestamp()) {
|
||||
if (element.systemMessage.contains('reaction')) continue;
|
||||
if (element.systemMessage.contains('poll_voted')) continue;
|
||||
if (element.systemMessage.contains('message_deleted')) continue;
|
||||
if (isHiddenSystemMessage(element)) continue;
|
||||
|
||||
final haystackText = RichObjectStringProcessor.parseToString(
|
||||
element.message,
|
||||
|
||||
Reference in New Issue
Block a user