Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update article history, diff, watchlist for temp accounts #5162

Merged
merged 12 commits into from
Feb 13, 2025
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "temp.svg",
"idiom" : "universal",
"language-direction" : "left-to-right"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class WMFSmallMenuButton: WMFComponentView {
// MARK: - Properties

public var title: String?
let image: UIImage?
var image: UIImage?
let primaryColor: KeyPath<WMFTheme, UIColor>
public let menuItems: [MenuItem]
public var metadata: [String: Any] = [:]
Expand Down Expand Up @@ -80,6 +80,12 @@ public class WMFSmallMenuButton: WMFComponentView {
let buttonConfig = createButtonConfig()
button.configuration = buttonConfig
}

public func updateImage(_ image: UIImage?) {
configuration.image = image
let buttonConfig = createButtonConfig()
button.configuration = buttonConfig
}

// MARK: - Setup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ fileprivate struct WMFWatchlistViewCell: View {
var editSummaryCommentFont: UIFont {
return itemViewModel.comment.isEmpty ? WMFFont.for(.italicFootnote) : WMFFont.for(.footnote)
}

var userIcon: UIImage? {
return itemViewModel.isTemp ? WMFIcon.temp : WMFSFSymbolIcon.for(symbol: .personFilled)
}

var body: some View {
ZStack {
Expand Down Expand Up @@ -172,10 +176,11 @@ fileprivate struct WMFWatchlistViewCell: View {
.frame(maxWidth: .infinity, alignment: .topLeading)
.accessibilityHidden(true)


HStack {
WMFSmallSwiftUIMenuButton(configuration: WMFSmallMenuButton.Configuration(
title: itemViewModel.username,
image: WMFSFSymbolIcon.for(symbol: .personFilled),
image: userIcon,
primaryColor: \.link,
menuItems: menuItemsForRevisionAuthor,
metadata: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,22 @@ public final class WMFWatchlistViewModel: ObservableObject {
let timestamp: Date
let username: String
let isAnonymous: Bool
let isTemp: Bool
let isBot: Bool
let revisionID: UInt
let oldRevisionID: UInt
let byteChange: Int
let project: WMFProject
private let htmlStripped: ((String) -> String)

public init(title: String, commentHTML: String, commentWikitext: String, timestamp: Date, username: String, isAnonymous: Bool, isBot: Bool, revisionID: UInt, oldRevisionID: UInt, byteChange: Int, project: WMFProject, htmlStripped: @escaping ((String) -> String)) {
public init(title: String, commentHTML: String, commentWikitext: String, timestamp: Date, username: String, isAnonymous: Bool, isTemp: Bool, isBot: Bool, revisionID: UInt, oldRevisionID: UInt, byteChange: Int, project: WMFProject, htmlStripped: @escaping ((String) -> String)) {
self.title = title
self.commentHTML = commentHTML
self.commentWikitext = commentWikitext
self.timestamp = timestamp
self.username = username
self.isAnonymous = isAnonymous
self.isTemp = isTemp
self.isBot = isBot
self.revisionID = revisionID
self.oldRevisionID = oldRevisionID
Expand Down Expand Up @@ -159,7 +161,7 @@ public final class WMFWatchlistViewModel: ObservableObject {
switch result {
case .success(let watchlist):
self.items = watchlist.items.map { item in
let viewModel = ItemViewModel(title: item.title, commentHTML: item.commentHtml, commentWikitext: item.commentWikitext, timestamp: item.timestamp, username: item.username, isAnonymous: item.isAnon, isBot: item.isBot, revisionID: item.revisionID, oldRevisionID: item.oldRevisionID, byteChange: Int(item.byteLength) - Int(item.oldByteLength), project: item.project, htmlStripped: self.localizedStrings.htmlStripped)
let viewModel = ItemViewModel(title: item.title, commentHTML: item.commentHtml, commentWikitext: item.commentWikitext, timestamp: item.timestamp, username: item.username, isAnonymous: item.isAnon, isTemp: item.isTemp, isBot: item.isBot, revisionID: item.revisionID, oldRevisionID: item.oldRevisionID, byteChange: Int(item.byteLength) - Int(item.oldByteLength), project: item.project, htmlStripped: self.localizedStrings.htmlStripped)
return viewModel
}
self.sections = self.sortWatchlistItems()
Expand Down
1 change: 1 addition & 0 deletions WMFComponents/Sources/WMFComponents/Style/WMFIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum WMFIcon {
static let userContributions = UIImage(named: "user-contributions", in: .module, with: nil)
public static let externalLink = UIImage(named: "external-link", in: .module, with: nil)
static let bot = UIImage(named: "bot", in: .module, with: nil)
public static let temp = UIImage(named: "temp", in: .module, with: nil)
public static let checkPhoto = UIImage(named: "photo-badge-checkmark", in: .module, with: nil) // Use SFSymbol once target is iOS17+
public static let addPhoto = UIImage(named: "photo-badge-plus", in: .module, with: nil) // Use SFSymbol once target is iOS17+
public static let error = UIImage(named: "error", in: .module, with: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public class WMFWatchlistDataController {
username: item.username,
isAnon: item.isAnon,
isBot: item.isBot,
isTemp: item.isTemp,
timestamp: timestamp,
commentWikitext: item.commentWikitext ?? "",
commentHtml: item.commentHtml ?? "",
Expand Down Expand Up @@ -603,6 +604,7 @@ private extension WMFWatchlistDataController {
let username: String
let isAnon: Bool
let isBot: Bool
let isTemp: Bool
let timestampString: String
let commentWikitext: String?
let commentHtml: String?
Expand All @@ -616,6 +618,7 @@ private extension WMFWatchlistDataController {
case username = "user"
case isAnon = "anon"
case isBot = "bot"
case isTemp = "temp"
case timestampString = "timestamp"
case commentWikitext = "comment"
case commentHtml = "parsedcomment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public struct WMFWatchlist {
public let username: String
public let isAnon: Bool
public let isBot: Bool
public let isTemp: Bool
public let timestamp: Date
public let commentWikitext: String
public let commentHtml: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"revid": 788965394,
"old_revid": 783793577,
"user": "YukiKoKo",
"temp": false,
"anon": false,
"bot": false,
"new": false,
Expand All @@ -28,6 +29,7 @@
"revid": 783793577,
"old_revid": 779606423,
"user": "باسم",
"temp": false,
"anon": false,
"bot": false,
"new": false,
Expand All @@ -46,6 +48,7 @@
"revid": 780713726,
"old_revid": 780625411,
"user": "Till.niermann",
"temp": false,
"anon": false,
"bot": false,
"new": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"revid": 1154241383,
"old_revid": 1154236179,
"user": "Lowercase sigmabot III",
"temp": false,
"anon": false,
"bot": true,
"new": false,
Expand All @@ -28,6 +29,7 @@
"revid": 1154108862,
"old_revid": 1154108789,
"user": "SineBot",
"temp": false,
"anon": false,
"bot": true,
"new": false,
Expand Down
Loading