mobile: remove item status alerts (#2883)

This commit is contained in:
Evgeny Poberezkin
2023-08-09 22:38:18 +01:00
committed by GitHub
parent 9543af4784
commit 2ab938db60
6 changed files with 53 additions and 117 deletions

View File

@@ -24,11 +24,11 @@ struct ChatItemInfoView: View {
}
enum CIInfoViewAlert: Identifiable {
case deliveryStatusAlert(status: CIStatus)
case alert(title: String, text: String)
var id: String {
switch self {
case .deliveryStatusAlert: return "deliveryStatusAlert"
case let .alert(title, text): return "alert \(title) \(text)"
}
}
}
@@ -43,9 +43,9 @@ struct ChatItemInfoView: View {
}
}
}
.alert(item: $alert) { alertItem in
switch(alertItem) {
case let .deliveryStatusAlert(status): return deliveryStatusAlert(status)
.alert(item: $alert) { a in
switch(a) {
case let .alert(title, text): return Alert(title: Text(title), message: Text(text))
}
}
}
@@ -306,7 +306,7 @@ struct ChatItemInfoView: View {
Text(member.chatViewName)
.lineLimit(1)
Spacer()
Group {
let v = Group {
if let (icon, statusColor) = status.statusIcon(Color.secondary) {
switch status {
case .sndRcvd:
@@ -326,19 +326,17 @@ struct ChatItemInfoView: View {
.foregroundColor(Color.secondary)
}
}
.onTapGesture {
alert = .deliveryStatusAlert(status: status)
if let (title, text) = status.statusInfo {
v.onTapGesture {
alert = .alert(title: title, text: text)
}
} else {
v
}
}
}
func deliveryStatusAlert(_ status: CIStatus) -> Alert {
Alert(
title: Text(status.statusText),
message: Text(status.statusDescription)
)
}
private func itemInfoShareText() -> String {
let meta = ci.meta
var shareText: [String] = [String.localizedStringWithFormat(NSLocalizedString("# %@", comment: "copied message info title, # <title>"), title), ""]
@@ -384,20 +382,6 @@ struct ChatItemInfoView: View {
}
shareText += [t != "" ? t : NSLocalizedString("no text", comment: "copied message info in history")]
}
if let mdss = chatItemInfo?.memberDeliveryStatuses {
let mss = membersStatuses(mdss)
if !mss.isEmpty {
shareText += ["", NSLocalizedString("## Delivery", comment: "copied message info")]
shareText += [""]
for (member, status) in mss {
shareText += [String.localizedStringWithFormat(
NSLocalizedString("%@: %@", comment: "copied message info, <recipient>: <message delivery status description>"),
member.chatViewName,
status.statusDescription
)]
}
}
}
if let chatItemInfo = chatItemInfo,
!chatItemInfo.itemVersions.isEmpty {
shareText += ["", NSLocalizedString("## History", comment: "copied message info")]

View File

@@ -208,7 +208,7 @@ struct PrivacySettings: View {
}
}
} catch let error {
alert = .error(title: "Error setting contact delivery receipts!", error: "Error: \(responseError(error))")
alert = .error(title: "Error setting delivery receipts!", error: "Error: \(responseError(error))")
}
}
}
@@ -256,7 +256,7 @@ struct PrivacySettings: View {
}
}
} catch let error {
alert = .error(title: "Error setting group delivery receipts!", error: "Error: \(responseError(error))")
alert = .error(title: "Error setting delivery receipts!", error: "Error: \(responseError(error))")
}
}
}

View File

@@ -2371,29 +2371,25 @@ public enum CIStatus: Decodable {
}
}
public var statusText: String {
public var statusInfo: (String, String)? {
switch self {
case .sndNew: return NSLocalizedString("Sending message", comment: "item status text")
case .sndSent: return NSLocalizedString("Message sent", comment: "item status text")
case .sndRcvd: return NSLocalizedString("Sent message received", comment: "item status text")
case .sndErrorAuth: return NSLocalizedString("Error sending message", comment: "item status text")
case .sndError: return NSLocalizedString("Error sending message", comment: "item status text")
case .rcvNew: return NSLocalizedString("Message received", comment: "item status text")
case .rcvRead: return NSLocalizedString("Message read", comment: "item status text")
case .invalid: return NSLocalizedString("Invalid status", comment: "item status text")
}
}
public var statusDescription: String {
switch self {
case .sndNew: return NSLocalizedString("Sending message is in progress or pending.", comment: "item status description")
case .sndSent: return NSLocalizedString("Message has been sent to the recipient's relay.", comment: "item status description")
case .sndRcvd: return NSLocalizedString("Message has been received by the recipient.", comment: "item status description")
case .sndErrorAuth: return NSLocalizedString("Message delivery error. Most likely this recipient has deleted the connection with you.", comment: "item status description")
case let .sndError(agentError): return String.localizedStringWithFormat(NSLocalizedString("Unexpected message delivery error: %@", comment: "item status description"), agentError)
case .rcvNew: return NSLocalizedString("New message from this sender.", comment: "item status description")
case .rcvRead: return NSLocalizedString("You've read this received message.", comment: "item status description")
case let .invalid(text): return text
case .sndNew: return nil
case .sndSent: return nil
case .sndRcvd: return nil
case .sndErrorAuth: return (
NSLocalizedString("Message delivery error.", comment: "item status text"),
NSLocalizedString("Most likely this connection is deleted.", comment: "item status description")
)
case let .sndError(agentError): return (
NSLocalizedString("Message delivery error", comment: "item status text"),
String.localizedStringWithFormat(NSLocalizedString("Unexpected error: %@", comment: "item status description"), agentError)
)
case .rcvNew: return nil
case .rcvRead: return nil
case let .invalid(text): return (
NSLocalizedString("Invalid status", comment: "item status text"),
text
)
}
}
}

View File

@@ -1740,26 +1740,15 @@ sealed class CIStatus {
is CIStatus.Invalid -> MR.images.ic_question_mark to metaColor
}
val statusText: String get() = when (this) {
is SndNew -> generalGetString(MR.strings.item_status_snd_new_text)
is SndSent -> generalGetString(MR.strings.item_status_snd_sent_text)
is SndRcvd -> generalGetString(MR.strings.item_status_snd_rcvd_text)
is SndErrorAuth -> generalGetString(MR.strings.item_status_snd_error_text)
is SndError -> generalGetString(MR.strings.item_status_snd_error_text)
is RcvNew -> generalGetString(MR.strings.item_status_rcv_new_text)
is RcvRead -> generalGetString(MR.strings.item_status_rcv_read_text)
is Invalid -> "Invalid status"
}
val statusDescription: String get() = when (this) {
is SndNew -> generalGetString(MR.strings.item_status_snd_new_desc)
is SndSent -> generalGetString(MR.strings.item_status_snd_sent_desc)
is SndRcvd -> generalGetString(MR.strings.item_status_snd_rcvd_desc)
is SndErrorAuth -> generalGetString(MR.strings.item_status_snd_error_auth_desc)
is SndError -> String.format(generalGetString(MR.strings.item_status_snd_error_unexpected_desc), this.agentError)
is RcvNew -> generalGetString(MR.strings.item_status_rcv_new_desc)
is RcvRead -> generalGetString(MR.strings.item_status_rcv_read_desc)
is Invalid -> this.text
val statusInto: Pair<String, String>? get() = when (this) {
is SndNew -> null
is SndSent -> null
is SndRcvd -> null
is SndErrorAuth -> generalGetString(MR.strings.message_delivery_error_title) to generalGetString(MR.strings.message_delivery_error_desc)
is SndError -> generalGetString(MR.strings.message_delivery_error_title) to (generalGetString(MR.strings.unknown_error) + ": $agentError")
is RcvNew -> null
is RcvRead -> null
is Invalid -> "Invalid status" to this.text
}
}

View File

@@ -234,18 +234,17 @@ fun ChatItemInfoView(chatModel: ChatModel, ci: ChatItem, ciInfo: ChatItemInfo, d
)
Spacer(Modifier.fillMaxWidth().weight(1f))
val statusIcon = status.statusIcon(MaterialTheme.colors.primary, CurrentColors.value.colors.secondary)
Box(
Modifier
.size(36.dp)
.clip(RoundedCornerShape(20.dp))
.clickable {
AlertManager.shared.showAlertMsg(
title = status.statusText,
text = status.statusDescription
)
},
contentAlignment = Alignment.Center
) {
var modifier = Modifier.size(36.dp).clip(RoundedCornerShape(20.dp))
val info = status.statusInto
if (info != null) {
modifier = modifier.clickable {
AlertManager.shared.showAlertMsg(
title = info.first,
text = info.second
)
}
}
Box(modifier, contentAlignment = Alignment.Center) {
if (statusIcon != null) {
val (icon, statusColor) = statusIcon
Icon(
@@ -434,22 +433,6 @@ fun itemInfoShareText(chatModel: ChatModel, ci: ChatItem, chatItemInfo: ChatItem
val t = qi.text
shareText.add(if (t != "") t else generalGetString(MR.strings.item_info_no_text))
}
val mdss = chatItemInfo.memberDeliveryStatuses
if (mdss != null) {
val mss = membersStatuses(chatModel, mdss)
if (mss.isNotEmpty()) {
shareText.add("")
shareText.add("## " + generalGetString(MR.strings.delivery))
shareText.add("")
mss.forEach { (member, status) ->
shareText.add(String.format(
generalGetString(MR.strings.recipient_colon_delivery_status),
member.chatViewName,
status.statusDescription
))
}
}
}
val versions = chatItemInfo.itemVersions
if (versions.isNotEmpty()) {
shareText.add("")

View File

@@ -1553,22 +1553,6 @@
<string name="you_can_enable_delivery_receipts_later_alert">You can enable them later via app Privacy &amp; Security settings.</string>
<string name="error_enabling_delivery_receipts">Error enabling delivery receipts!</string>
<!-- CIStatus texts -->
<string name="item_status_snd_new_text">Sending message</string>
<string name="item_status_snd_sent_text">Message sent</string>
<string name="item_status_snd_rcvd_text">Sent message received</string>
<string name="item_status_snd_error_text">Error sending message</string>
<string name="item_status_rcv_new_text">Message received</string>
<string name="item_status_rcv_read_text">Message read</string>
<string name="item_status_snd_new_desc">Sending message is in progress or pending.</string>
<string name="item_status_snd_sent_desc">Message has been sent to the recipient\'s relay.</string>
<string name="item_status_snd_rcvd_desc">Message has been received by the recipient.</string>
<string name="item_status_snd_error_auth_desc">Message delivery error. Most likely this recipient has deleted the connection with you.</string>
<string name="item_status_snd_error_unexpected_desc">Unexpected message delivery error: %1$s</string>
<string name="item_status_rcv_new_desc">New message from this sender.</string>
<string name="item_status_rcv_read_desc">You\'ve read this received message.</string>
<!-- Under development -->
<string name="in_developing_title">Coming soon!</string>
<string name="in_developing_desc">This feature is not yet supported. Try the next release.</string>