Add preference for status reply icons
This commit is contained in:
parent
3aef7d4d93
commit
00bf99334f
|
@ -41,6 +41,7 @@ class Preferences: Codable, ObservableObject {
|
|||
self.showRepliesInProfiles = try container.decode(Bool.self, forKey: .showRepliesInProfiles)
|
||||
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
|
||||
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
|
||||
self.showIsStatusReplyIcon = try container.decode(Bool.self, forKey: .showIsStatusReplyIcon)
|
||||
|
||||
self.defaultPostVisibility = try container.decode(Status.Visibility.self, forKey: .defaultPostVisibility)
|
||||
self.automaticallySaveDrafts = try container.decode(Bool.self, forKey: .automaticallySaveDrafts)
|
||||
|
@ -69,6 +70,7 @@ class Preferences: Codable, ObservableObject {
|
|||
try container.encode(showRepliesInProfiles, forKey: .showRepliesInProfiles)
|
||||
try container.encode(avatarStyle, forKey: .avatarStyle)
|
||||
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
|
||||
try container.encode(showIsStatusReplyIcon, forKey: .showIsStatusReplyIcon)
|
||||
|
||||
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
|
||||
try container.encode(automaticallySaveDrafts, forKey: .automaticallySaveDrafts)
|
||||
|
@ -95,6 +97,7 @@ class Preferences: Codable, ObservableObject {
|
|||
@Published var showRepliesInProfiles = false
|
||||
@Published var avatarStyle = AvatarStyle.roundRect
|
||||
@Published var hideCustomEmojiInUsernames = false
|
||||
@Published var showIsStatusReplyIcon = false
|
||||
|
||||
// MARK: Composing
|
||||
@Published var defaultPostVisibility = Status.Visibility.public
|
||||
|
@ -125,6 +128,7 @@ class Preferences: Codable, ObservableObject {
|
|||
case showRepliesInProfiles
|
||||
case avatarStyle
|
||||
case hideCustomEmojiInUsernames
|
||||
case showIsStatusReplyIcon
|
||||
|
||||
case defaultPostVisibility
|
||||
case automaticallySaveDrafts
|
||||
|
|
|
@ -39,6 +39,9 @@ struct AppearancePrefsView : View {
|
|||
Toggle(isOn: $preferences.hideCustomEmojiInUsernames) {
|
||||
Text("Hide Custom Emoji in Usernames")
|
||||
}
|
||||
Toggle(isOn: $preferences.showIsStatusReplyIcon) {
|
||||
Text("Show Status Reply Icons")
|
||||
}
|
||||
}
|
||||
.listStyle(GroupedListStyle())
|
||||
.navigationBarTitle(Text("Appearance"))
|
||||
|
|
|
@ -90,15 +90,19 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
pinImageView.isHidden = !pinned
|
||||
}
|
||||
|
||||
replyImageView.isHidden = !showReplyIndicator || status.inReplyToID == nil
|
||||
updateStatusIcons(status)
|
||||
}
|
||||
|
||||
@objc override func preferencesChanged() {
|
||||
super.preferencesChanged()
|
||||
|
||||
if let rebloggerID = rebloggerID,
|
||||
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
|
||||
updateRebloggerLabel(reblogger: reblogger)
|
||||
}
|
||||
|
||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else { return }
|
||||
updateStatusIcons(status)
|
||||
}
|
||||
|
||||
private func updateRebloggerLabel(reblogger: AccountMO) {
|
||||
|
@ -111,6 +115,10 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
private func updateStatusIcons(_ status: StatusMO) {
|
||||
replyImageView.isHidden = !Preferences.shared.showIsStatusReplyIcon || !showReplyIndicator || status.inReplyToID == nil
|
||||
}
|
||||
|
||||
func updateTimestamp() {
|
||||
// if the mastodonController is nil (i.e. the delegate is nil), then the screen this cell was a part of has been deallocated
|
||||
// so we bail out immediately, since there's nothing to update
|
||||
|
|
Loading…
Reference in New Issue