Revert "Mention badge + badge behaviour redesign" (#2283)

This commit is contained in:
Mauro
2023-12-22 10:44:10 +01:00
committed by GitHub
parent fe9bee6c31
commit 5e4df72173
19 changed files with 83 additions and 212 deletions

View File

@@ -6650,7 +6650,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = {
kind = exactVersion;
version = 1.1.30;
version = 1.1.29;
};
};
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {

View File

@@ -130,8 +130,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : {
"revision" : "9b63f21292be70ca13c57ccbd89cd9478daa8cdc",
"version" : "1.1.30"
"revision" : "82a58f61f5d01d90b364a3aad28597fd703cea71",
"version" : "1.1.29"
}
},
{

View File

@@ -147,8 +147,6 @@ struct HomeScreenRoom: Identifiable, Equatable {
var hasUnreads = false
var hasMentions = false
var hasOngoingCall = false
var timestamp: String?
@@ -166,7 +164,6 @@ struct HomeScreenRoom: Identifiable, Equatable {
roomId: nil,
name: "Placeholder room name",
hasUnreads: false,
hasMentions: false,
timestamp: "Now",
lastMessage: placeholderLastMessage,
isPlaceholder: true)

View File

@@ -288,16 +288,17 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
private func buildRoom(with details: RoomSummaryDetails, invalidated: Bool) -> HomeScreenRoom {
let identifier = invalidated ? "invalidated-" + details.id : details.id
let notificationMode = details.notificationMode == .allMessages ? nil : details.notificationMode
return HomeScreenRoom(id: identifier,
roomId: details.id,
name: details.name,
hasUnreads: details.unreadMessagesCount > 0,
hasMentions: details.unreadMentionsCount > 0,
hasUnreads: details.unreadNotificationCount > 0,
hasOngoingCall: details.hasOngoingCall,
timestamp: details.lastMessageFormattedTimestamp,
lastMessage: details.lastMessage,
avatarURL: details.avatarURL,
notificationMode: details.notificationMode)
notificationMode: notificationMode)
}
private func updateVisibleRange(_ range: Range<Int>) {

View File

@@ -95,8 +95,8 @@ struct HomeScreenRoomCell: View {
if let timestamp = room.timestamp {
Text(timestamp)
.font(isHighlighted ? .compound.bodySMSemibold : .compound.bodySM)
.foregroundColor(isHighlighted ? .compound.textActionAccent : .compound.textSecondary)
.font(room.hasUnreads ? .compound.bodySMSemibold : .compound.bodySM)
.foregroundColor(room.hasUnreads ? .compound.textActionAccent : .compound.textSecondary)
}
}
}
@@ -119,48 +119,33 @@ struct HomeScreenRoomCell: View {
HStack(spacing: 8) {
if room.hasOngoingCall {
CompoundIcon(\.videoCallSolid, size: .xSmall, relativeTo: .compound.bodySM)
.foregroundColor(isHighlighted ? .compound.iconAccentTertiary : .compound.iconQuaternary)
}
if room.notificationMode == .mute {
CompoundIcon(\.notificationsSolidOff, size: .custom(15), relativeTo: .compound.bodyMD)
.accessibilityLabel(L10n.a11yNotificationsMuted)
.foregroundColor(.compound.iconQuaternary)
.foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary)
}
if room.hasMentions, room.notificationMode != .mute {
mentionIcon
.foregroundColor(.compound.iconAccentTertiary)
}
notificationModeIcon
.foregroundColor(room.hasUnreads ? .compound.iconAccentTertiary : .compound.iconQuaternary)
if hasNewContent {
if room.hasUnreads {
Circle()
.frame(width: 12, height: 12)
.foregroundColor(isHighlighted ? .compound.iconAccentTertiary : .compound.iconQuaternary)
.foregroundColor(.compound.iconAccentTertiary)
}
}
}
}
private var hasNewContent: Bool {
room.hasUnreads || room.hasMentions
}
private var isHighlighted: Bool {
guard !room.isPlaceholder else {
return false
@ViewBuilder
private var notificationModeIcon: some View {
switch room.notificationMode {
case .none, .allMessages:
EmptyView()
case .mentionsAndKeywordsOnly:
CompoundIcon(\.mention, size: .custom(15), relativeTo: .compound.bodyMD)
.accessibilityLabel(L10n.a11yNotificationsMentionsOnly)
case .mute:
CompoundIcon(\.notificationsSolidOff, size: .custom(15), relativeTo: .compound.bodyMD)
.accessibilityLabel(L10n.a11yNotificationsMuted)
}
return (isNotificationModeUnrestricted && hasNewContent) ||
(room.notificationMode == .mentionsAndKeywordsOnly && room.hasMentions)
}
private var isNotificationModeUnrestricted: Bool {
room.notificationMode == nil || room.notificationMode == .allMessages
}
private var mentionIcon: some View {
CompoundIcon(\.mention, size: .custom(15), relativeTo: .compound.bodyMD)
.accessibilityLabel(L10n.a11yNotificationsMentionsOnly)
}
@ViewBuilder
@@ -193,67 +178,41 @@ private extension View {
}
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
static let summaryProviderGeneric = MockRoomSummaryProvider(state: .loaded(.mockRooms))
static let viewModelGeneric = {
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProviderGeneric),
mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
}()
static let summaryProviderForNotificationsState = MockRoomSummaryProvider(state: .loaded(.mockRoomsWithNotificationsState))
static let viewModelForNotificationsState = {
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProviderForNotificationsState),
mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
return HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
}()
static func mockRoom(summary: RoomSummary) -> HomeScreenRoom? {
switch summary {
case .empty:
return nil
case .invalidated(let details), .filled(let details):
return HomeScreenRoom(id: UUID().uuidString,
roomId: details.id,
name: details.name,
hasUnreads: details.unreadMessagesCount > 0, hasMentions: details.unreadMentionsCount > 0,
hasOngoingCall: details.hasOngoingCall,
timestamp: Date(timeIntervalSinceReferenceDate: 0).formattedMinimal(),
lastMessage: details.lastMessage,
notificationMode: details.notificationMode)
}
}
static var previews: some View {
let genericRooms: [HomeScreenRoom] = summaryProviderGeneric.roomListPublisher.value.compactMap(mockRoom)
let notificationsStateRooms: [HomeScreenRoom] = summaryProviderForNotificationsState.roomListPublisher.value.compactMap(mockRoom)
let summaryProvider = MockRoomSummaryProvider(state: .loaded(.mockRooms))
VStack(spacing: 0) {
ForEach(genericRooms) { room in
HomeScreenRoomCell(room: room, context: viewModelGeneric.context, isSelected: false)
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe", roomSummaryProvider: summaryProvider),
mediaProvider: MockMediaProvider(),
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
let viewModel = HomeScreenViewModel(userSession: userSession,
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
let rooms: [HomeScreenRoom] = summaryProvider.roomListPublisher.value.compactMap { summary -> HomeScreenRoom? in
switch summary {
case .empty:
return nil
case .invalidated(let details), .filled(let details):
return HomeScreenRoom(id: UUID().uuidString,
roomId: details.id,
name: details.name,
hasUnreads: details.unreadNotificationCount > 0,
hasOngoingCall: details.hasOngoingCall,
timestamp: Date(timeIntervalSinceReferenceDate: 0).formattedMinimal(),
lastMessage: details.lastMessage,
notificationMode: details.notificationMode)
}
}
return VStack(spacing: 0) {
ForEach(rooms) { room in
HomeScreenRoomCell(room: room, context: viewModel.context, isSelected: false)
}
HomeScreenRoomCell(room: .placeholder(), context: viewModelGeneric.context, isSelected: false)
HomeScreenRoomCell(room: .placeholder(), context: viewModel.context, isSelected: false)
.redacted(reason: .placeholder)
}
.previewDisplayName("Generic")
VStack(spacing: 0) {
ForEach(notificationsStateRooms) { room in
HomeScreenRoomCell(room: room, context: viewModelForNotificationsState.context, isSelected: false)
}
}
.previewLayout(.sizeThatFits)
.previewDisplayName("Notifications State")
}
}

View File

@@ -186,8 +186,7 @@ private extension InvitesScreenRoomDetails {
avatarURL: nil,
lastMessage: nil,
lastMessageFormattedTimestamp: nil,
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: nil,
canonicalAlias: "#footest:somewhere.org",
inviter: inviter,
@@ -207,8 +206,7 @@ private extension InvitesScreenRoomDetails {
avatarURL: avatarURL,
lastMessage: nil,
lastMessageFormattedTimestamp: nil,
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: nil,
canonicalAlias: alias,
inviter: inviter,

View File

@@ -17,7 +17,7 @@
import Foundation
import MatrixRustSDK
enum RoomNotificationModeProxy: String {
enum RoomNotificationModeProxy {
case allMessages
case mentionsAndKeywordsOnly
case mute

View File

@@ -83,8 +83,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: AttributedString("I do not wish to take the trouble to understand mysticism"),
lastMessageFormattedTimestamp: "14:56",
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: .allMessages,
canonicalAlias: nil,
inviter: nil,
@@ -95,8 +94,7 @@ extension Array where Element == RoomSummary {
avatarURL: URL.picturesDirectory,
lastMessage: AttributedString("How do you see the Emperor then? You think he keeps office hours?"),
lastMessageFormattedTimestamp: "2:56 PM",
unreadMessagesCount: 2,
unreadMentionsCount: 0,
unreadNotificationCount: 2,
notificationMode: .mute,
canonicalAlias: nil,
inviter: nil,
@@ -107,8 +105,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: try? AttributedString(markdown: "He certainly seemed no *mental genius* to me"),
lastMessageFormattedTimestamp: "Some time ago",
unreadMessagesCount: 3,
unreadMentionsCount: 0,
unreadNotificationCount: 3,
notificationMode: .mentionsAndKeywordsOnly,
canonicalAlias: nil,
inviter: nil,
@@ -119,8 +116,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: AttributedString("There's an archaic measure of time that's called the month"),
lastMessageFormattedTimestamp: "Just now",
unreadMessagesCount: 2,
unreadMentionsCount: 2,
unreadNotificationCount: 4,
notificationMode: .allMessages,
canonicalAlias: nil,
inviter: nil,
@@ -131,8 +127,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: AttributedString("Clearly, if Earth is powerful enough to do that, it might also be capable of adjusting minds in order to force belief in its radioactivity"),
lastMessageFormattedTimestamp: "1986",
unreadMessagesCount: 1,
unreadMentionsCount: 1,
unreadNotificationCount: 5,
notificationMode: .allMessages,
canonicalAlias: nil,
inviter: nil,
@@ -143,8 +138,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: AttributedString("Are you groping for the word 'paranoia'?"),
lastMessageFormattedTimestamp: "きょうはじゅういちがつじゅういちにちです",
unreadMessagesCount: 6,
unreadMentionsCount: 0,
unreadNotificationCount: 6,
notificationMode: .mute,
canonicalAlias: nil,
inviter: nil,
@@ -155,8 +149,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: nil,
lastMessageFormattedTimestamp: nil,
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: nil,
canonicalAlias: nil,
inviter: nil,
@@ -164,65 +157,13 @@ extension Array where Element == RoomSummary {
.empty
]
static let mockRoomsWithNotificationsState: [Element] = [
.filled(details: RoomSummaryDetails(id: "1",
settingsMode: .allMessages,
hasUnreadMessages: false,
hasUnreadMentions: false)),
.filled(details: RoomSummaryDetails(id: "2",
settingsMode: .allMessages,
hasUnreadMessages: true,
hasUnreadMentions: false)),
.filled(details: RoomSummaryDetails(id: "3",
settingsMode: .allMessages,
hasUnreadMessages: true,
hasUnreadMentions: true)),
.filled(details: RoomSummaryDetails(id: "4",
settingsMode: .allMessages,
hasUnreadMessages: false,
hasUnreadMentions: true)),
.filled(details: RoomSummaryDetails(id: "5",
settingsMode: .mentionsAndKeywordsOnly,
hasUnreadMessages: false,
hasUnreadMentions: false)),
.filled(details: RoomSummaryDetails(id: "6",
settingsMode: .mentionsAndKeywordsOnly,
hasUnreadMessages: true,
hasUnreadMentions: false)),
.filled(details: RoomSummaryDetails(id: "7",
settingsMode: .mentionsAndKeywordsOnly,
hasUnreadMessages: true,
hasUnreadMentions: true)),
.filled(details: RoomSummaryDetails(id: "8",
settingsMode: .mentionsAndKeywordsOnly,
hasUnreadMessages: false,
hasUnreadMentions: true)),
.filled(details: RoomSummaryDetails(id: "9",
settingsMode: .mute,
hasUnreadMessages: false,
hasUnreadMentions: false)),
.filled(details: RoomSummaryDetails(id: "10",
settingsMode: .mute,
hasUnreadMessages: true,
hasUnreadMentions: false)),
.filled(details: RoomSummaryDetails(id: "11",
settingsMode: .mute,
hasUnreadMessages: true,
hasUnreadMentions: true)),
.filled(details: RoomSummaryDetails(id: "12",
settingsMode: .mute,
hasUnreadMessages: false,
hasUnreadMentions: true))
]
static let mockInvites: [Element] = [
.filled(details: RoomSummaryDetails(id: "someAwesomeRoomId1", name: "First room",
isDirect: false,
avatarURL: URL.picturesDirectory,
lastMessage: nil,
lastMessageFormattedTimestamp: nil,
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: nil,
canonicalAlias: "#footest:somewhere.org",
inviter: RoomMemberProxyMock.mockCharlie,
@@ -233,8 +174,7 @@ extension Array where Element == RoomSummary {
avatarURL: nil,
lastMessage: nil,
lastMessageFormattedTimestamp: nil,
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: nil,
canonicalAlias: nil,
inviter: RoomMemberProxyMock.mockCharlie,

View File

@@ -24,8 +24,7 @@ struct RoomSummaryDetails {
let avatarURL: URL?
let lastMessage: AttributedString?
let lastMessageFormattedTimestamp: String?
let unreadMessagesCount: UInt
let unreadMentionsCount: UInt
let unreadNotificationCount: UInt
let notificationMode: RoomNotificationModeProxy?
let canonicalAlias: String?
let inviter: RoomMemberProxyProtocol?
@@ -34,24 +33,6 @@ struct RoomSummaryDetails {
extension RoomSummaryDetails: CustomStringConvertible {
var description: String {
"RoomSummaryDetails: - id: \(id) - isDirect: \(isDirect) - unreadMessagesCount: \(unreadMessagesCount) - unreadMentionsCount: \(unreadMentionsCount) - notificationMode: \(notificationMode?.rawValue ?? "nil")"
}
}
extension RoomSummaryDetails {
init(id: String, settingsMode: RoomNotificationModeProxy, hasUnreadMessages: Bool, hasUnreadMentions: Bool) {
self.id = id
let string = "\(settingsMode) - hasUnreadMessages: \(hasUnreadMessages) - hasUnreadMentions: \(hasUnreadMentions)"
name = string
isDirect = true
avatarURL = nil
lastMessage = AttributedString(string)
lastMessageFormattedTimestamp = "Now"
unreadMessagesCount = hasUnreadMessages ? 1 : 0
unreadMentionsCount = hasUnreadMentions ? 1 : 0
notificationMode = settingsMode
canonicalAlias = nil
inviter = nil
hasOngoingCall = false
"id: \"\(id)\", isDirect: \"\(isDirect)\", unreadNotificationCount: \"\(unreadNotificationCount)\""
}
}

View File

@@ -245,8 +245,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
avatarURL: roomInfo.avatarUrl.flatMap(URL.init(string:)),
lastMessage: attributedLastMessage,
lastMessageFormattedTimestamp: lastMessageFormattedTimestamp,
unreadMessagesCount: UInt(roomInfo.numUnreadMessages),
unreadMentionsCount: UInt(roomInfo.numUnreadMentions),
unreadNotificationCount: UInt(roomInfo.notificationCount),
notificationMode: notificationMode,
canonicalAlias: roomInfo.canonicalAlias,
inviter: inviterProxy,

View File

@@ -229,8 +229,7 @@ class LoggingTests: XCTestCase {
avatarURL: nil,
lastMessage: AttributedString(lastMessage),
lastMessageFormattedTimestamp: "Now",
unreadMessagesCount: 0,
unreadMentionsCount: 0,
unreadNotificationCount: 0,
notificationMode: nil,
canonicalAlias: nil,
inviter: nil,

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0e9cc69f6a7d59b4b39ff0f0e1d610425f6d26d8582e6fcda4c6773c8bc9f426
size 294065
oid sha256:5d6d5a6fa799a80f4057b45c490d47fd32d191034a7f035d30bd5b31e1a6855b
size 297086

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0ca50932a6c958e8b4ae292ab0068f673424993a8a3b02a7ed8982c976dfa2cb
size 96097
oid sha256:213d0979ea41ce5e5a5bbaf91864818b72cbc279d4ac488ffdf01c5e456949dc
size 97007

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c2c1eeb6d42077fb58bd4bd9e27adff438d443eb33f140e9846caf911eb8319e
size 152467
oid sha256:c2ca57c531d847da14ab639cabe6a1eb37e615cf3a28db4749e6c6ca88f26800
size 151676

View File

@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c518b7d94108cc9852a5158e963894c1c809ba326a6c33aa731b8c99e4935916
size 104897
oid sha256:a2dafbdd32b395dd007ba56f506e2bde32f4c9817ed31d11d76067f93c34055f
size 104560

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:144567bde78b790121261ea07309fb16470310564a23f38d91117b83034b07fc
size 243748

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0a008adeae6b250d84187e72067a734e213b2a7557258f4bcd251b45b64c9dc3
size 241273

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:280155439f431f4f3694c9482807857e053088a6afd904da0027ec06b39fdb66
size 421031

View File

@@ -47,7 +47,7 @@ packages:
# Element/Matrix dependencies
MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.1.30
exactVersion: 1.1.29
# path: ../matrix-rust-sdk
Compound:
url: https://github.com/element-hq/compound-ios