Skip to content

Commit

Permalink
Update slidebar (MixinNetwork#347)
Browse files Browse the repository at this point in the history
* slide bar show unseen conversation count

* unseen mute conversation count
  • Loading branch information
YeungKC authored Oct 27, 2021
1 parent c73a7c7 commit 7ab9790
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 233 deletions.
28 changes: 1 addition & 27 deletions lib/blaze/vo/blaze_message_data.g.dart

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

41 changes: 2 additions & 39 deletions lib/blaze/vo/pin_message_payload.g.dart

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

28 changes: 1 addition & 27 deletions lib/blaze/vo/system_circle_message.g.dart

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

28 changes: 1 addition & 27 deletions lib/blaze/vo/system_session_message.g.dart

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

28 changes: 1 addition & 27 deletions lib/blaze/vo/system_user_message.g.dart

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

51 changes: 21 additions & 30 deletions lib/db/dao/conversation_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
.where((event) => event != null)
.map((event) => event!);

Selectable<int?> allUnseenIgnoreMuteMessageCount() => _baseUnseenMessageCount(
Selectable<int?> allUnseenIgnoreMuteMessageCount() =>
db.baseUnseenMessageCount(
(conversation, owner, __) {
final now = const MillisDateConverter().mapToSql(DateTime.now());
final groupExpression =
Expand All @@ -46,7 +47,6 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
owner.muteUntil.isSmallerOrEqualValue(now);
return groupExpression | userExpression;
},
useBaseWhere: false,
);

Future<int> insert(Insertable<Conversation> conversation) async {
Expand Down Expand Up @@ -84,22 +84,6 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
],
);

Selectable<int?> _baseUnseenMessageCount(
Expression<bool?> Function(Conversations conversation, Users owner,
CircleConversations circleConversation)
where, {
bool useBaseWhere = true,
}) =>
db.baseUnseenMessageCount((conversation, owner, circleConversation) {
final expression = where(conversation, owner, circleConversation);
if (useBaseWhere) {
return _baseConversationItemWhere(
conversation, owner, circleConversation) &
expression;
}
return expression;
});

Selectable<int> _baseConversationItemCount(
Expression<bool?> Function(Conversations conversation, Users owner,
CircleConversations circleConversation)
Expand Down Expand Up @@ -207,8 +191,17 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
owner.relationship.equalsValue(UserRelationship.friend) &
owner.appId.isNull();

Selectable<int?> contactConversationUnseenMessageCount() =>
_baseUnseenMessageCount(_contactWhere);
Selectable<BaseUnseenConversationCountResult> _baseUnseenConversationCount(
Expression<bool?> Function(Conversations conversation, Users owner)
where) =>
db.baseUnseenConversationCount((conversation, owner) =>
_baseConversationItemWhere(conversation, owner) &
conversation.unseenMessageCount.isBiggerThanValue(0) &
where(conversation, owner));

Selectable<BaseUnseenConversationCountResult>
contactUnseenConversationCount() =>
_baseUnseenConversationCount(_contactWhere);

Selectable<int> contactConversationCount() =>
_baseConversationItemCount(_contactWhere);
Expand Down Expand Up @@ -238,8 +231,9 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
owner.relationship.equalsValue(UserRelationship.stranger) &
owner.appId.isNull();

Selectable<int?> strangerConversationUnseenMessageCount() =>
_baseUnseenMessageCount(_strangerWhere);
Selectable<BaseUnseenConversationCountResult>
strangerUnseenConversationCount() =>
_baseUnseenConversationCount(_strangerWhere);

Selectable<int> strangerConversationCount() =>
_baseConversationItemCount(_strangerWhere);
Expand Down Expand Up @@ -267,8 +261,9 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
]) =>
conversation.category.equalsValue(ConversationCategory.group);

Selectable<int?> groupConversationUnseenMessageCount() =>
_baseUnseenMessageCount(_groupWhere);
Selectable<BaseUnseenConversationCountResult>
groupUnseenConversationCount() =>
_baseUnseenConversationCount(_groupWhere);

Selectable<int> groupConversationCount() =>
_baseConversationItemCount(_groupWhere);
Expand Down Expand Up @@ -297,8 +292,8 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
conversation.category.equalsValue(ConversationCategory.contact) &
owner.appId.isNotNull();

Selectable<int?> botConversationUnseenMessageCount() =>
_baseUnseenMessageCount(_botWhere);
Selectable<BaseUnseenConversationCountResult> botUnseenConversationCount() =>
_baseUnseenConversationCount(_botWhere);

Selectable<int> botConversationCount() =>
_baseConversationItemCount(_botWhere);
Expand Down Expand Up @@ -329,10 +324,6 @@ class ConversationDao extends DatabaseAccessor<MixinDatabase>
(_, __, ___, ____, ______, _______, ________) => maxLimit,
);

Selectable<int?> conversationUnseenMessageCountByCircleId(String circleId) =>
_baseUnseenMessageCount((_, __, circleConversation) =>
circleConversation.circleId.equals(circleId));

Selectable<int> conversationsCountByCircleId(String circleId) =>
_baseConversationItemCount((_, __, circleConversation) =>
circleConversation.circleId.equals(circleId));
Expand Down
Loading

0 comments on commit 7ab9790

Please sign in to comment.