mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
chore: rename hashTag to hashtag
This commit is contained in:
parent
d800e10bd7
commit
33016d9cf4
@ -148,7 +148,7 @@
|
||||
<attribute name="createAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
|
||||
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser"/>
|
||||
<relationship name="hashTag" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Tag"/>
|
||||
<relationship name="hashtag" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Tag"/>
|
||||
</entity>
|
||||
<entity name="Status" representedClassName=".Status" syncable="YES">
|
||||
<attribute name="content" attributeType="String"/>
|
||||
@ -197,19 +197,19 @@
|
||||
<relationship name="statuses" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="tags" inverseEntity="Status"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="Application" positionX="160" positionY="192" width="128" height="104"/>
|
||||
<element name="Attachment" positionX="72" positionY="162" width="128" height="254"/>
|
||||
<element name="Emoji" positionX="45" positionY="135" width="128" height="149"/>
|
||||
<element name="History" positionX="27" positionY="126" width="128" height="119"/>
|
||||
<element name="HomeTimelineIndex" positionX="0" positionY="0" width="128" height="134"/>
|
||||
<element name="MastodonAuthentication" positionX="18" positionY="162" width="128" height="209"/>
|
||||
<element name="MastodonUser" positionX="0" positionY="0" width="128" height="629"/>
|
||||
<element name="Mention" positionX="9" positionY="108" width="128" height="134"/>
|
||||
<element name="Poll" positionX="72" positionY="162" width="128" height="194"/>
|
||||
<element name="PollOption" positionX="81" positionY="171" width="128" height="134"/>
|
||||
<element name="PrivateNote" positionX="72" positionY="153" width="128" height="89"/>
|
||||
<element name="Status" positionX="0" positionY="0" width="128" height="569"/>
|
||||
<element name="Tag" positionX="18" positionY="117" width="128" height="119"/>
|
||||
<element name="SearchHistory" positionX="72" positionY="162" width="128" height="89"/>
|
||||
<element name="Application" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Attachment" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Emoji" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="History" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="HomeTimelineIndex" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="MastodonAuthentication" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="MastodonUser" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Mention" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Poll" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="PollOption" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="PrivateNote" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="SearchHistory" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Status" positionX="0" positionY="0" width="0" height="0"/>
|
||||
<element name="Tag" positionX="0" positionY="0" width="0" height="0"/>
|
||||
</elements>
|
||||
</model>
|
@ -14,7 +14,7 @@ public final class SearchHistory: NSManagedObject {
|
||||
@NSManaged public private(set) var createAt: Date
|
||||
|
||||
@NSManaged public private(set) var account: MastodonUser?
|
||||
@NSManaged public private(set) var hashTag: Tag?
|
||||
@NSManaged public private(set) var hashtag: Tag?
|
||||
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@ extension SearchHistory {
|
||||
@discardableResult
|
||||
public static func insert(
|
||||
into context: NSManagedObjectContext,
|
||||
hashTag: Tag
|
||||
hashtag: Tag
|
||||
) -> SearchHistory {
|
||||
let searchHistory: SearchHistory = context.insertObject()
|
||||
searchHistory.hashTag = hashTag
|
||||
searchHistory.hashtag = hashtag
|
||||
searchHistory.createAt = Date()
|
||||
return searchHistory
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ import Foundation
|
||||
import MastodonSDK
|
||||
|
||||
enum SearchResultItem {
|
||||
case hashTag(tag: Mastodon.Entity.Tag)
|
||||
case hashtag(tag: Mastodon.Entity.Tag)
|
||||
|
||||
case account(account: Mastodon.Entity.Account)
|
||||
|
||||
case accountObjectID(accountObjectID: NSManagedObjectID)
|
||||
|
||||
case hashTagObjectID(hashTagObjectID: NSManagedObjectID)
|
||||
case hashtagObjectID(hashtagObjectID: NSManagedObjectID)
|
||||
|
||||
case bottomLoader
|
||||
}
|
||||
@ -24,7 +24,7 @@ enum SearchResultItem {
|
||||
extension SearchResultItem: Equatable {
|
||||
static func == (lhs: SearchResultItem, rhs: SearchResultItem) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (.hashTag(let tagLeft), .hashTag(let tagRight)):
|
||||
case (.hashtag(let tagLeft), .hashtag(let tagRight)):
|
||||
return tagLeft == tagRight
|
||||
case (.account(let accountLeft), .account(let accountRight)):
|
||||
return accountLeft == accountRight
|
||||
@ -32,7 +32,7 @@ extension SearchResultItem: Equatable {
|
||||
return true
|
||||
case (.accountObjectID(let idLeft),.accountObjectID(let idRight)):
|
||||
return idLeft == idRight
|
||||
case (.hashTagObjectID(let idLeft),.hashTagObjectID(let idRight)):
|
||||
case (.hashtagObjectID(let idLeft),.hashtagObjectID(let idRight)):
|
||||
return idLeft == idRight
|
||||
default:
|
||||
return false
|
||||
@ -45,11 +45,11 @@ extension SearchResultItem: Hashable {
|
||||
switch self {
|
||||
case .account(let account):
|
||||
hasher.combine(account)
|
||||
case .hashTag(let tag):
|
||||
case .hashtag(let tag):
|
||||
hasher.combine(tag)
|
||||
case .accountObjectID(let id):
|
||||
hasher.combine(id)
|
||||
case .hashTagObjectID(let id):
|
||||
case .hashtagObjectID(let id):
|
||||
hasher.combine(id)
|
||||
case .bottomLoader:
|
||||
hasher.combine(String(describing: SearchResultItem.bottomLoader.self))
|
||||
|
@ -13,7 +13,7 @@ import CoreDataStack
|
||||
|
||||
enum SearchResultSection: Equatable, Hashable {
|
||||
case account
|
||||
case hashTag
|
||||
case hashtag
|
||||
case mixed
|
||||
case bottomLoader
|
||||
}
|
||||
@ -29,13 +29,13 @@ extension SearchResultSection {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SearchingTableViewCell.self), for: indexPath) as! SearchingTableViewCell
|
||||
cell.config(with: account)
|
||||
return cell
|
||||
case .hashTag(let tag):
|
||||
case .hashtag(let tag):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SearchingTableViewCell.self), for: indexPath) as! SearchingTableViewCell
|
||||
cell.config(with: tag)
|
||||
return cell
|
||||
case .hashTagObjectID(let hashTagObjectID):
|
||||
case .hashtagObjectID(let hashtagObjectID):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: SearchingTableViewCell.self), for: indexPath) as! SearchingTableViewCell
|
||||
let tag = dependency.context.managedObjectContext.object(with: hashTagObjectID) as! Tag
|
||||
let tag = dependency.context.managedObjectContext.object(with: hashtagObjectID) as! Tag
|
||||
cell.config(with: tag)
|
||||
return cell
|
||||
case .accountObjectID(let accountObjectID):
|
||||
|
@ -43,7 +43,6 @@ internal enum Asset {
|
||||
internal static let danger = ColorAsset(name: "Colors/Background/danger")
|
||||
internal static let mediaTypeIndicotor = ColorAsset(name: "Colors/Background/media.type.indicotor")
|
||||
internal static let onboardingBackground = ColorAsset(name: "Colors/Background/onboarding.background")
|
||||
internal static let search = ColorAsset(name: "Colors/Background/search")
|
||||
internal static let secondaryGroupedSystemBackground = ColorAsset(name: "Colors/Background/secondary.grouped.system.background")
|
||||
internal static let secondarySystemBackground = ColorAsset(name: "Colors/Background/secondary.system.background")
|
||||
internal static let success = ColorAsset(name: "Colors/Background/success")
|
||||
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "232",
|
||||
"green" : "225",
|
||||
"red" : "217"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ class SearchRecommendTagsCollectionViewCell: UICollectionViewCell {
|
||||
return imageView
|
||||
}()
|
||||
|
||||
let hashTagTitleLabel: UILabel = {
|
||||
let hashtagTitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = .white
|
||||
label.font = .systemFont(ofSize: 20, weight: .semibold)
|
||||
@ -66,8 +66,8 @@ extension SearchRecommendTagsCollectionViewCell {
|
||||
contentView.addSubview(backgroundImageView)
|
||||
backgroundImageView.constrain(toSuperviewEdges: nil)
|
||||
|
||||
contentView.addSubview(hashTagTitleLabel)
|
||||
hashTagTitleLabel.pin(top: 16, left: 16, bottom: nil, right: 42)
|
||||
contentView.addSubview(hashtagTitleLabel)
|
||||
hashtagTitleLabel.pin(top: 16, left: 16, bottom: nil, right: 42)
|
||||
|
||||
contentView.addSubview(peopleLabel)
|
||||
peopleLabel.pinTopLeft(top: 46, left: 16)
|
||||
@ -77,7 +77,7 @@ extension SearchRecommendTagsCollectionViewCell {
|
||||
}
|
||||
|
||||
func config(with tag: Mastodon.Entity.Tag) {
|
||||
hashTagTitleLabel.text = "# " + tag.name
|
||||
hashtagTitleLabel.text = "# " + tag.name
|
||||
guard let historys = tag.history else {
|
||||
peopleLabel.text = ""
|
||||
return
|
||||
@ -98,7 +98,7 @@ struct SearchRecommendTagsCollectionViewCell_Previews: PreviewProvider {
|
||||
Group {
|
||||
UIViewPreview {
|
||||
let cell = SearchRecommendTagsCollectionViewCell()
|
||||
cell.hashTagTitleLabel.text = "# test"
|
||||
cell.hashtagTitleLabel.text = "# test"
|
||||
cell.peopleLabel.text = "128 people are talking"
|
||||
return cell
|
||||
}
|
||||
|
@ -15,15 +15,15 @@ extension SearchViewController {
|
||||
let header = SearchRecommendCollectionHeader()
|
||||
header.titleLabel.text = L10n.Scene.Search.Recommend.HashTag.title
|
||||
header.descriptionLabel.text = L10n.Scene.Search.Recommend.HashTag.description
|
||||
header.seeAllButton.addTarget(self, action: #selector(SearchViewController.hashTagSeeAllButtonPressed(_:)), for: .touchUpInside)
|
||||
header.seeAllButton.addTarget(self, action: #selector(SearchViewController.hashtagSeeAllButtonPressed(_:)), for: .touchUpInside)
|
||||
stackView.addArrangedSubview(header)
|
||||
|
||||
hashTagCollectionView.register(SearchRecommendTagsCollectionViewCell.self, forCellWithReuseIdentifier: String(describing: SearchRecommendTagsCollectionViewCell.self))
|
||||
hashTagCollectionView.delegate = self
|
||||
hashtagCollectionView.register(SearchRecommendTagsCollectionViewCell.self, forCellWithReuseIdentifier: String(describing: SearchRecommendTagsCollectionViewCell.self))
|
||||
hashtagCollectionView.delegate = self
|
||||
|
||||
stackView.addArrangedSubview(hashTagCollectionView)
|
||||
hashTagCollectionView.constrain([
|
||||
hashTagCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: 130)
|
||||
stackView.addArrangedSubview(hashtagCollectionView)
|
||||
hashtagCollectionView.constrain([
|
||||
hashtagCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: 130)
|
||||
])
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ extension SearchViewController {
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
hashTagCollectionView.collectionViewLayout.invalidateLayout()
|
||||
hashtagCollectionView.collectionViewLayout.invalidateLayout()
|
||||
accountsCollectionView.collectionViewLayout.invalidateLayout()
|
||||
}
|
||||
}
|
||||
@ -65,7 +65,7 @@ extension SearchViewController: UICollectionViewDelegateFlowLayout {
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
||||
if collectionView == hashTagCollectionView {
|
||||
if collectionView == hashtagCollectionView {
|
||||
return 6
|
||||
} else {
|
||||
return 12
|
||||
@ -73,7 +73,7 @@ extension SearchViewController: UICollectionViewDelegateFlowLayout {
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||
if collectionView == hashTagCollectionView {
|
||||
if collectionView == hashtagCollectionView {
|
||||
return CGSize(width: 228, height: 130)
|
||||
} else {
|
||||
return CGSize(width: 257, height: 202)
|
||||
@ -82,7 +82,7 @@ extension SearchViewController: UICollectionViewDelegateFlowLayout {
|
||||
}
|
||||
|
||||
extension SearchViewController {
|
||||
@objc func hashTagSeeAllButtonPressed(_ sender: UIButton) {}
|
||||
@objc func hashtagSeeAllButtonPressed(_ sender: UIButton) {}
|
||||
|
||||
@objc func accountSeeAllButtonPressed(_ sender: UIButton) {}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ final class SearchViewController: UIViewController, NeedsDependency {
|
||||
return stackView
|
||||
}()
|
||||
|
||||
let hashTagCollectionView: UICollectionView = {
|
||||
let hashtagCollectionView: UICollectionView = {
|
||||
let flowLayout = UICollectionViewFlowLayout()
|
||||
flowLayout.scrollDirection = .horizontal
|
||||
let view = ControlContainableCollectionView(frame: .zero, collectionViewLayout: flowLayout)
|
||||
@ -141,7 +141,7 @@ extension SearchViewController {
|
||||
}
|
||||
|
||||
func setupDataSource() {
|
||||
viewModel.hashTagDiffableDataSource = RecommendHashTagSection.collectionViewDiffableDataSource(for: hashTagCollectionView)
|
||||
viewModel.hashtagDiffableDataSource = RecommendHashTagSection.collectionViewDiffableDataSource(for: hashtagCollectionView)
|
||||
viewModel.accountDiffableDataSource = RecommendAccountSection.collectionViewDiffableDataSource(for: accountsCollectionView)
|
||||
viewModel.searchResultDiffableDataSource = SearchResultSection.tableViewDiffableDataSource(for: searchingTableView, dependency: self)
|
||||
}
|
||||
@ -187,7 +187,7 @@ extension SearchViewController: UISearchBarDelegate {
|
||||
case 1:
|
||||
viewModel.searchScope.value = Mastodon.API.Search.Scope.accounts.rawValue
|
||||
case 2:
|
||||
viewModel.searchScope.value = Mastodon.API.Search.Scope.hashTags.rawValue
|
||||
viewModel.searchScope.value = Mastodon.API.Search.Scope.hashtags.rawValue
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ extension SearchViewModel.LoadOldestState {
|
||||
switch viewModel.searchScope.value {
|
||||
case Mastodon.API.Search.Scope.accounts.rawValue:
|
||||
offset = oldSearchResult.accounts.count
|
||||
case Mastodon.API.Search.Scope.hashTags.rawValue:
|
||||
case Mastodon.API.Search.Scope.hashtags.rawValue:
|
||||
offset = oldSearchResult.hashtags.count
|
||||
default:
|
||||
return
|
||||
@ -91,7 +91,7 @@ extension SearchViewModel.LoadOldestState {
|
||||
viewModel.searchResult.value = Mastodon.Entity.SearchResult(accounts: newAccounts.removeDuplicate(), statuses: oldSearchResult.statuses, hashtags: oldSearchResult.hashtags)
|
||||
stateMachine.enter(Idle.self)
|
||||
}
|
||||
case Mastodon.API.Search.Scope.hashTags.rawValue:
|
||||
case Mastodon.API.Search.Scope.hashtags.rawValue:
|
||||
if result.value.hashtags.isEmpty {
|
||||
stateMachine.enter(NoMore.self)
|
||||
} else {
|
||||
|
@ -31,7 +31,7 @@ final class SearchViewModel: NSObject {
|
||||
var recommendHashTags = [Mastodon.Entity.Tag]()
|
||||
var recommendAccounts = [Mastodon.Entity.Account]()
|
||||
|
||||
var hashTagDiffableDataSource: UICollectionViewDiffableDataSource<RecommendHashTagSection, Mastodon.Entity.Tag>?
|
||||
var hashtagDiffableDataSource: UICollectionViewDiffableDataSource<RecommendHashTagSection, Mastodon.Entity.Tag>?
|
||||
var accountDiffableDataSource: UICollectionViewDiffableDataSource<RecommendAccountSection, Mastodon.Entity.Account>?
|
||||
var searchResultDiffableDataSource: UITableViewDiffableDataSource<SearchResultSection, SearchResultItem>?
|
||||
|
||||
@ -112,13 +112,13 @@ final class SearchViewModel: NSObject {
|
||||
|
||||
searchHistories.forEach { searchHistory in
|
||||
let containsAccount = scope == Mastodon.API.Search.Scope.accounts.rawValue || scope == ""
|
||||
let containsHashTag = scope == Mastodon.API.Search.Scope.hashTags.rawValue || scope == ""
|
||||
let containsHashTag = scope == Mastodon.API.Search.Scope.hashtags.rawValue || scope == ""
|
||||
if let mastodonUser = searchHistory.account, containsAccount {
|
||||
let item = SearchResultItem.accountObjectID(accountObjectID: mastodonUser.objectID)
|
||||
snapshot.appendItems([item], toSection: .mixed)
|
||||
}
|
||||
if let tag = searchHistory.hashTag, containsHashTag {
|
||||
let item = SearchResultItem.hashTagObjectID(hashTagObjectID: tag.objectID)
|
||||
if let tag = searchHistory.hashtag, containsHashTag {
|
||||
let item = SearchResultItem.hashtagObjectID(hashtagObjectID: tag.objectID)
|
||||
snapshot.appendItems([item], toSection: .mixed)
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ final class SearchViewModel: NSObject {
|
||||
.sink { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
if !self.recommendHashTags.isEmpty {
|
||||
guard let dataSource = self.hashTagDiffableDataSource else { return }
|
||||
guard let dataSource = self.hashtagDiffableDataSource else { return }
|
||||
var snapshot = NSDiffableDataSourceSnapshot<RecommendHashTagSection, Mastodon.Entity.Tag>()
|
||||
snapshot.appendSections([.main])
|
||||
snapshot.appendItems(self.recommendHashTags, toSection: .main)
|
||||
@ -166,16 +166,16 @@ final class SearchViewModel: NSObject {
|
||||
snapshot.appendSections([.account])
|
||||
let items = accounts.compactMap { SearchResultItem.account(account: $0) }
|
||||
snapshot.appendItems(items, toSection: .account)
|
||||
if self.searchScope.value == Mastodon.API.Search.Scope.accounts.rawValue {
|
||||
if self.searchScope.value == Mastodon.API.Search.Scope.accounts.rawValue && !items.isEmpty {
|
||||
snapshot.appendItems([.bottomLoader], toSection: .account)
|
||||
}
|
||||
}
|
||||
if let tags = searchResult?.hashtags {
|
||||
snapshot.appendSections([.hashTag])
|
||||
let items = tags.compactMap { SearchResultItem.hashTag(tag: $0) }
|
||||
snapshot.appendItems(items, toSection: .hashTag)
|
||||
if self.searchScope.value == Mastodon.API.Search.Scope.hashTags.rawValue {
|
||||
snapshot.appendItems([.bottomLoader], toSection: .hashTag)
|
||||
snapshot.appendSections([.hashtag])
|
||||
let items = tags.compactMap { SearchResultItem.hashtag(tag: $0) }
|
||||
snapshot.appendItems(items, toSection: .hashtag)
|
||||
if self.searchScope.value == Mastodon.API.Search.Scope.hashtags.rawValue && !items.isEmpty {
|
||||
snapshot.appendItems([.bottomLoader], toSection: .hashtag)
|
||||
}
|
||||
}
|
||||
dataSource.apply(snapshot, animatingDifferences: false, completion: nil)
|
||||
@ -255,12 +255,12 @@ final class SearchViewModel: NSObject {
|
||||
let (mastodonUser, _) = APIService.CoreData.createOrMergeMastodonUser(into: self.context.managedObjectContext, for: requestMastodonUser, in: activeMastodonAuthenticationBox.domain, entity: account, userCache: nil, networkDate: Date(), log: OSLog.api)
|
||||
SearchHistory.insert(into: self.context.managedObjectContext, account: mastodonUser)
|
||||
|
||||
case .hashTag(let tag):
|
||||
case .hashtag(let tag):
|
||||
let histories = tag.history?[0 ... 2].compactMap { history -> History in
|
||||
History.insert(into: self.context.managedObjectContext, property: History.Property(day: history.day, uses: history.uses, accounts: history.accounts))
|
||||
}
|
||||
let tagInCoreData = Tag.insert(into: self.context.managedObjectContext, property: Tag.Property(name: tag.name, url: tag.url, histories: histories))
|
||||
SearchHistory.insert(into: self.context.managedObjectContext, hashTag: tagInCoreData)
|
||||
SearchHistory.insert(into: self.context.managedObjectContext, hashtag: tagInCoreData)
|
||||
|
||||
default:
|
||||
break
|
||||
|
@ -97,13 +97,13 @@ public extension Mastodon.API.Search {
|
||||
public extension Mastodon.API.Search {
|
||||
enum Scope: String {
|
||||
case accounts
|
||||
case hashTags
|
||||
case hashtags
|
||||
|
||||
public var rawValue: String {
|
||||
switch self {
|
||||
case .accounts:
|
||||
return "accounts"
|
||||
case .hashTags:
|
||||
case .hashtags:
|
||||
return "hashtags"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user