style: rename `Id` to `ID`

This commit is contained in:
ihugo 2021-04-25 15:48:37 +08:00
parent cbc828eec2
commit 85014802c4
3 changed files with 26 additions and 25 deletions

View File

@ -88,7 +88,7 @@ extension ReportViewModel {
} }
if status.id == self.statusId { if status.id == self.statusId {
attribute.isSelected = true attribute.isSelected = true
self.reportQuery.append(statusId: status.id) self.reportQuery.append(statusID: status.id)
self.continueEnableSubject.send(true) self.continueEnableSubject.send(true)
} }
} }

View File

@ -66,8 +66,8 @@ class ReportViewModel: NSObject {
) )
self.reportQuery = FileReportQuery( self.reportQuery = FileReportQuery(
accountId: userId, accountID: userId,
statusIds: [], statusIDs: [],
comment: nil, comment: nil,
forward: nil forward: nil
) )
@ -121,15 +121,15 @@ class ReportViewModel: NSObject {
attribute.isSelected = !attribute.isSelected attribute.isSelected = !attribute.isSelected
if attribute.isSelected { if attribute.isSelected {
self.reportQuery.append(statusId: status.id) self.reportQuery.append(statusID: status.id)
} else { } else {
self.reportQuery.remove(statusId: status.id) self.reportQuery.remove(statusID: status.id)
} }
snapshot.reloadItems([item]) snapshot.reloadItems([item])
self.diffableDataSource?.apply(snapshot, animatingDifferences: false) self.diffableDataSource?.apply(snapshot, animatingDifferences: false)
let continueEnable = (self.reportQuery.statusIds?.count ?? 0) > 0 let continueEnable = (self.reportQuery.statusIDs?.count ?? 0) > 0
self.continueEnableSubject.send(continueEnable) self.continueEnableSubject.send(continueEnable)
} }
.store(in: &disposeBag) .store(in: &disposeBag)
@ -150,7 +150,7 @@ class ReportViewModel: NSObject {
func bindForStep1(input: Input) { func bindForStep1(input: Input) {
let skip = input.step1Skip.map { [weak self] value -> Void in let skip = input.step1Skip.map { [weak self] value -> Void in
guard let self = self else { return value } guard let self = self else { return value }
self.reportQuery.statusIds?.removeAll() self.reportQuery.statusIDs?.removeAll()
return value return value
} }

View File

@ -65,40 +65,41 @@ extension Mastodon.API.Reports {
public extension Mastodon.API.Reports { public extension Mastodon.API.Reports {
class FileReportQuery: Codable, PostQuery { class FileReportQuery: Codable, PostQuery {
public let accountId: String public let accountID: Mastodon.Entity.Account.ID
public var statusIds: [String]? public var statusIDs: [Mastodon.Entity.Status.ID]?
public var comment: String? public var comment: String?
public let forward: Bool? public let forward: Bool?
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case accountId = "account_id" case accountID = "account_id"
case statusIds = "status_ids" case statusIDs = "status_ids"
case comment case comment
case forward case forward
} }
public init(accountId: String, public init(
statusIds: [String]?, accountID: Mastodon.Entity.Account.ID,
comment: String?, statusIDs: [Mastodon.Entity.Status.ID]?,
forward: Bool?) { comment: String?,
self.accountId = accountId forward: Bool?) {
self.statusIds = statusIds self.accountID = accountID
self.statusIDs = statusIDs
self.comment = comment self.comment = comment
self.forward = forward self.forward = forward
} }
public func append(statusId: String) { public func append(statusID: Mastodon.Entity.Status.ID) {
guard self.statusIds?.contains(statusId) != true else { return } guard self.statusIDs?.contains(statusID) != true else { return }
if self.statusIds == nil { if self.statusIDs == nil {
self.statusIds = [] self.statusIDs = []
} }
self.statusIds?.append(statusId) self.statusIDs?.append(statusID)
} }
public func remove(statusId: String) { public func remove(statusID: String) {
guard let index = self.statusIds?.firstIndex(of: statusId) else { return } guard let index = self.statusIDs?.firstIndex(of: statusID) else { return }
self.statusIds?.remove(at: index) self.statusIDs?.remove(at: index)
} }
} }
} }