Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions lib/account/notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:stream_transform/stream_transform.dart';

import '../blaze/vo/pin_message_minimal.dart';
import '../db/database_event_bus.dart';
import '../db/extension/conversation.dart';
import '../enum/message_category.dart';
import '../generated/l10n.dart';

Expand Down Expand Up @@ -85,17 +84,9 @@ class NotificationService {
// quote current user
if (await quotedCurrentUser()) return true;

final muteUntil = event.category == ConversationCategory.group
? event.muteUntil
: event.ownerMuteUntil;
return muteUntil?.isAfter(DateTime.now()) != true;
return event.muteUntil?.isAfter(DateTime.now()) != true;
})
.asyncMap((event) async {
final name = conversationValidName(
event.groupName,
event.ownerFullName,
);

String? body;
if (context.settingChangeNotifier.messagePreview) {
final mentionCache =
Expand Down Expand Up @@ -153,7 +144,7 @@ class NotificationService {
}

await showNotification(
title: name,
title: event.name ?? '',
body: body,
uri: Uri(
scheme: enumConvertToString(NotificationScheme.conversation),
Expand Down
267 changes: 98 additions & 169 deletions lib/db/dao/conversation_dao.g.dart

Large diffs are not rendered by default.

95 changes: 33 additions & 62 deletions lib/db/dao/message_dao.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions lib/db/extension/conversation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import '../dao/conversation_dao.dart';
extension SearchConversationItemExtension on SearchConversationItem {
bool get isGroupConversation => category == ConversationCategory.group;

bool get isMute =>
(isGroupConversation && muteUntil?.isAfter(DateTime.now()) == true) ||
(!isGroupConversation && ownerMuteUntil?.isAfter(DateTime.now()) == true);

String get validName => conversationValidName(groupName, fullName);
bool get isMute => muteUntil?.isAfter(DateTime.now()) == true;
}

extension ConversationItemExtension on ConversationItem {
Expand All @@ -28,20 +24,10 @@ extension ConversationItemExtension on ConversationItem {
relationship == UserRelationship.stranger &&
appId == null;

String get validName => conversationValidName(groupName, name);

bool get isMute =>
(isGroupConversation && muteUntil?.isAfter(DateTime.now()) == true) ||
(!isGroupConversation && ownerMuteUntil?.isAfter(DateTime.now()) == true);

DateTime? get validMuteUntil =>
isGroupConversation ? muteUntil : ownerMuteUntil;
bool get isMute => muteUntil?.isAfter(DateTime.now()) == true;

Duration get expireDuration {
final expireIn = this.expireIn ?? 0;
return expireIn == 0 ? Duration.zero : Duration(seconds: expireIn);
}
}

String conversationValidName(String? groupName, String? fullName) =>
groupName?.trim().isNotEmpty == true ? groupName! : fullName ?? '';
Loading