Merge remote-tracking branch 'upstream/develop' into status-cards

This commit is contained in:
Jed Fox 2022-12-03 13:48:40 -05:00
commit 7e74b4beb3
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
53 changed files with 1960 additions and 78 deletions

View File

@ -96,7 +96,7 @@
},
"tabs": {
"home": "Home",
"search": "Search",
"search_and_explore": "Search and Explore",
"notifications": "Notifications",
"profile": "Profile"
},
@ -726,6 +726,19 @@
},
"bookmark": {
"title": "Bookmarks"
},
"followed_tags": {
"title": "Followed Tags",
"header": {
"posts": "posts",
"participants": "participants",
"posts_today": "posts today"
},
"actions": {
"follow": "Follow",
"unfollow": "Unfollow"
}
}
}
}

View File

@ -96,7 +96,7 @@
},
"tabs": {
"home": "Home",
"search": "Search",
"search_and_explore": "Search and Explore",
"notifications": "Notifications",
"profile": "Profile"
},
@ -726,6 +726,19 @@
},
"bookmark": {
"title": "Bookmarks"
},
"followed_tags": {
"title": "Followed Tags",
"header": {
"posts": "posts",
"participants": "participants",
"posts_today": "posts today"
},
"actions": {
"follow": "Follow",
"unfollow": "Unfollow"
}
}
}
}

View File

@ -24,6 +24,13 @@
164F0EBC267D4FE400249499 /* BoopSound.caf in Resources */ = {isa = PBXBuildFile; fileRef = 164F0EBB267D4FE400249499 /* BoopSound.caf */; };
18BC7629F65E6DB12CB8416D /* Pods_Mastodon_MastodonUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C030226D3C73DCC23D67452 /* Pods_Mastodon_MastodonUITests.framework */; };
27D701F5292FC2D60031BCBB /* DataSourceFacade+URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */; };
2A1FE47C2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */; };
2A1FE47E2938C11200784BF1 /* Collection+IsNotEmpty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */; };
2A3F6FE3292ECB5E002E6DA7 /* FollowedTagsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3F6FE2292ECB5E002E6DA7 /* FollowedTagsViewModel.swift */; };
2A3F6FE5292F6E44002E6DA7 /* FollowedTagsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A3F6FE4292F6E44002E6DA7 /* FollowedTagsTableViewCell.swift */; };
2A506CF4292CD85800059C37 /* FollowedTagsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A506CF3292CD85800059C37 /* FollowedTagsViewController.swift */; };
2A506CF6292D040100059C37 /* HashtagTimelineHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A506CF5292D040100059C37 /* HashtagTimelineHeaderView.swift */; };
2A76F75C2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */; };
2A82294F29262EE000D2A1F7 /* AppContext+NextAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */; };
2AE244482927831100BDBF7C /* UIImage+SFSymbols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AE244472927831100BDBF7C /* UIImage+SFSymbols.swift */; };
2D198643261BF09500F0B013 /* SearchResultItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D198642261BF09500F0B013 /* SearchResultItem.swift */; };
@ -524,6 +531,13 @@
164F0EBB267D4FE400249499 /* BoopSound.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = BoopSound.caf; sourceTree = "<group>"; };
1D6D967E77A5357E2C6110D9 /* Pods-Mastodon.asdk - debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon.asdk - debug.xcconfig"; path = "Target Support Files/Pods-Mastodon/Pods-Mastodon.asdk - debug.xcconfig"; sourceTree = "<group>"; };
27D701F4292FC2D60031BCBB /* DataSourceFacade+URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataSourceFacade+URL.swift"; sourceTree = "<group>"; };
2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FollowedTagsViewModel+DiffableDataSource.swift"; sourceTree = "<group>"; };
2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+IsNotEmpty.swift"; sourceTree = "<group>"; };
2A3F6FE2292ECB5E002E6DA7 /* FollowedTagsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowedTagsViewModel.swift; sourceTree = "<group>"; };
2A3F6FE4292F6E44002E6DA7 /* FollowedTagsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowedTagsTableViewCell.swift; sourceTree = "<group>"; };
2A506CF3292CD85800059C37 /* FollowedTagsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowedTagsViewController.swift; sourceTree = "<group>"; };
2A506CF5292D040100059C37 /* HashtagTimelineHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineHeaderView.swift; sourceTree = "<group>"; };
2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineHeaderViewActionButton.swift; sourceTree = "<group>"; };
2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppContext+NextAccount.swift"; sourceTree = "<group>"; };
2AE244472927831100BDBF7C /* UIImage+SFSymbols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+SFSymbols.swift"; sourceTree = "<group>"; };
2D198642261BF09500F0B013 /* SearchResultItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultItem.swift; sourceTree = "<group>"; };
@ -1130,6 +1144,8 @@
0F202200261326E6000C64BF /* HashtagTimelineViewModel.swift */,
0F20220626134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift */,
0F20222C261457EE000C64BF /* HashtagTimelineViewModel+State.swift */,
2A506CF5292D040100059C37 /* HashtagTimelineHeaderView.swift */,
2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */,
);
path = HashtagTimeline;
sourceTree = "<group>";
@ -1232,6 +1248,17 @@
path = Pods;
sourceTree = "<group>";
};
2A506CF2292CD83B00059C37 /* FollowedTags */ = {
isa = PBXGroup;
children = (
2A506CF3292CD85800059C37 /* FollowedTagsViewController.swift */,
2A3F6FE2292ECB5E002E6DA7 /* FollowedTagsViewModel.swift */,
2A1FE47B2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift */,
2A3F6FE4292F6E44002E6DA7 /* FollowedTagsTableViewCell.swift */,
);
path = FollowedTags;
sourceTree = "<group>";
};
2D152A8A25C295B8009AA50C /* Content */ = {
isa = PBXGroup;
children = (
@ -2257,6 +2284,7 @@
DBCC3B2F261440A50045B23D /* UITabBarController.swift */,
DB73BF4827140BA300781945 /* UICollectionViewDiffableDataSource.swift */,
DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */,
2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */,
);
path = Extension;
sourceTree = "<group>";
@ -2376,6 +2404,7 @@
DB9D6C0825E4F5A60051B173 /* Profile */ = {
isa = PBXGroup;
children = (
2A506CF2292CD83B00059C37 /* FollowedTags */,
62047EBE28874C8F00A3BA5D /* Bookmark */,
DBB525462611ED57002F1F29 /* Header */,
DBB525262611EBDA002F1F29 /* Paging */,
@ -3301,17 +3330,20 @@
2D82B9FF25E7863200E36F0F /* OnboardingViewControllerAppearance.swift in Sources */,
DB025B78278D606A002F581E /* StatusItem.swift in Sources */,
DB697DD4278F4927004EF2F7 /* StatusTableViewCellDelegate.swift in Sources */,
2A506CF6292D040100059C37 /* HashtagTimelineHeaderView.swift in Sources */,
DBA5E7A5263BD28C004598BB /* ContextMenuImagePreviewViewModel.swift in Sources */,
DB3E6FF52807C40300B035AE /* DiscoveryForYouViewController.swift in Sources */,
2D38F1E525CD46C100561493 /* HomeTimelineViewModel.swift in Sources */,
DB0FCB842796B2A2006C02E2 /* FavoriteViewController+DataSourceProvider.swift in Sources */,
DB0FCB68279507EF006C02E2 /* DataSourceFacade+Meta.swift in Sources */,
2A1FE47E2938C11200784BF1 /* Collection+IsNotEmpty.swift in Sources */,
2D84350525FF858100EECE90 /* UIScrollView.swift in Sources */,
6213AF5A28939C8400BCADB6 /* BookmarkViewModel.swift in Sources */,
5B24BBDB262DB14800A9381B /* ReportStatusViewModel+Diffable.swift in Sources */,
DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */,
0FB3D2FE25E4CB6400AAD544 /* OnboardingHeadlineTableViewCell.swift in Sources */,
5DA732CC2629CEF500A92342 /* UIView+Remove.swift in Sources */,
2A506CF4292CD85800059C37 /* FollowedTagsViewController.swift in Sources */,
DB1D843026566512000346B3 /* KeyboardPreference.swift in Sources */,
DB852D1926FAEB6B00FC9D81 /* SidebarViewController.swift in Sources */,
2D206B9225F60EA700143C56 /* UIControl.swift in Sources */,
@ -3385,6 +3417,7 @@
DB938EED2623F79B00E5B6C1 /* ThreadViewModel.swift in Sources */,
DB6988DE2848D11C002398EF /* PagerTabStripNavigateable.swift in Sources */,
2DCB73FD2615C13900EC03D4 /* SearchRecommendCollectionHeader.swift in Sources */,
2A1FE47C2938BB2600784BF1 /* FollowedTagsViewModel+DiffableDataSource.swift in Sources */,
DB852D1C26FB021500FC9D81 /* RootSplitViewController.swift in Sources */,
DB697DD1278F4871004EF2F7 /* AutoGenerateTableViewDelegate.swift in Sources */,
DB02CDBF2625AE5000D0A2AF /* AdaptiveUserInterfaceStyleBarButtonItem.swift in Sources */,
@ -3476,6 +3509,7 @@
DBCC3B30261440A50045B23D /* UITabBarController.swift in Sources */,
DB3E6FE42806A5B800B035AE /* DiscoverySection.swift in Sources */,
DB8190C62601FF0400020C08 /* AttachmentContainerView.swift in Sources */,
2A76F75C2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift in Sources */,
DB697DDB278F4DE3004EF2F7 /* DataSourceProvider+StatusTableViewCellDelegate.swift in Sources */,
DB87D4512609CF1E00D12C0D /* ComposeStatusPollOptionAppendEntryCollectionViewCell.swift in Sources */,
DBB45B5627B39FC9002DC5A7 /* MediaPreviewVideoViewController.swift in Sources */,
@ -3484,6 +3518,7 @@
DB67D08627312E67006A36CF /* WizardViewController.swift in Sources */,
DB6746EB278ED8B0008A6B94 /* PollOptionView+Configuration.swift in Sources */,
DB0F9D54283EB3C000379AF8 /* ProfileHeaderView+ViewModel.swift in Sources */,
2A3F6FE3292ECB5E002E6DA7 /* FollowedTagsViewModel.swift in Sources */,
DBFEEC99279BDCDE004F81DD /* ProfileAboutViewModel.swift in Sources */,
2D198649261C0B8500F0B013 /* SearchResultSection.swift in Sources */,
DB4F097B26A039FF00D62E92 /* SearchHistorySection.swift in Sources */,
@ -3514,6 +3549,7 @@
5BB04FF5262F0E6D0043BFF6 /* ReportSection.swift in Sources */,
DBEFCD82282A2AB100C0ABEA /* ReportServerRulesView.swift in Sources */,
DBA94436265CBB7400C537E1 /* ProfileFieldItem.swift in Sources */,
2A3F6FE5292F6E44002E6DA7 /* FollowedTagsTableViewCell.swift in Sources */,
C24C97032922F30500BAE8CB /* RefreshControl.swift in Sources */,
DB023D2A27A0FE5C005AC798 /* DataSourceProvider+NotificationTableViewCellDelegate.swift in Sources */,
DB98EB6027B10E150082E365 /* ReportCommentTableViewCell.swift in Sources */,

View File

@ -173,6 +173,7 @@ extension SceneCoordinator {
case rebloggedBy(viewModel: UserListViewModel)
case favoritedBy(viewModel: UserListViewModel)
case bookmark(viewModel: BookmarkViewModel)
case followedTags(viewModel: FollowedTagsViewModel)
// setting
case settings(viewModel: SettingsViewModel)
@ -448,6 +449,10 @@ private extension SceneCoordinator {
let _viewController = BookmarkViewController()
_viewController.viewModel = viewModel
viewController = _viewController
case .followedTags(let viewModel):
let _viewController = FollowedTagsViewController()
_viewController.viewModel = viewModel
viewController = _viewController
case .favorite(let viewModel):
let _viewController = FavoriteViewController()
_viewController.viewModel = viewModel

View File

@ -0,0 +1,14 @@
//
// Array+IsNotEmpty.swift
// Mastodon
//
// Created by Marcus Kida on 01.12.22.
//
import Foundation
extension Collection {
var isNotEmpty: Bool {
!isEmpty
}
}

View File

@ -16,10 +16,17 @@ extension DataSourceFacade {
) async throws {
let selectionFeedbackGenerator = await UISelectionFeedbackGenerator()
await selectionFeedbackGenerator.selectionChanged()
_ = try await dependency.context.apiService.toggleBlock(
let apiService = dependency.context.apiService
let authBox = dependency.authContext.mastodonAuthenticationBox
_ = try await apiService.toggleBlock(
user: user,
authenticationBox: dependency.authContext.mastodonAuthenticationBox
authenticationBox: authBox
)
try await dependency.context.apiService.getBlocked(
authenticationBox: authBox
)
} // end func
}

View File

@ -0,0 +1,173 @@
//
// HashtagTimelineHeaderView.swift
// Mastodon
//
// Created by Marcus Kida on 22.11.22.
//
import UIKit
import CoreDataStack
import MastodonSDK
import MastodonUI
import MastodonAsset
import MastodonLocalization
fileprivate extension CGFloat {
static let padding: CGFloat = 16
static let descriptionLabelSpacing: CGFloat = 12
}
final class HashtagTimelineHeaderView: UIView {
struct Data {
let name: String
let following: Bool
let postCount: Int
let participantsCount: Int
let postsTodayCount: Int
static func from(_ entity: Mastodon.Entity.Tag) -> Self {
Data(
name: entity.name,
following: entity.following == true,
postCount: (entity.history ?? []).reduce(0) { res, acc in
res + (Int(acc.uses) ?? 0)
},
participantsCount: (entity.history ?? []).reduce(0) { res, acc in
res + (Int(acc.accounts) ?? 0)
},
postsTodayCount: Int(entity.history?.first?.uses ?? "0") ?? 0
)
}
static func from(_ entity: Tag) -> Self {
Data(
name: entity.name,
following: entity.following,
postCount: entity.histories.reduce(0) { res, acc in
res + (Int(acc.uses) ?? 0)
},
participantsCount: entity.histories.reduce(0) { res, acc in
res + (Int(acc.accounts) ?? 0)
},
postsTodayCount: Int(entity.histories.first?.uses ?? "0") ?? 0
)
}
}
let titleLabel = UILabel()
let postCountLabel = UILabel()
let participantsLabel = UILabel()
let postsTodayLabel = UILabel()
let postCountDescLabel = UILabel()
let participantsDescLabel = UILabel()
let postsTodayDescLabel = UILabel()
private var widthConstraint: NSLayoutConstraint!
var onButtonTapped: (() -> Void)?
let followButton: UIButton = {
let button = HashtagTimelineHeaderViewActionButton()
button.cornerRadius = 10
button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 16, bottom: 5, right: 16) // set 28pt height
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .bold)
return button
}()
init() {
super.init(frame: .zero)
setupLayout()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
private extension HashtagTimelineHeaderView {
func setupLayout() {
[titleLabel, postCountLabel, participantsLabel, postsTodayLabel, postCountDescLabel, participantsDescLabel, postsTodayDescLabel, followButton].forEach {
$0.translatesAutoresizingMaskIntoConstraints = false
addSubview($0)
}
// hashtag name / title
titleLabel.font = UIFontMetrics(forTextStyle: .title2).scaledFont(for: .systemFont(ofSize: 22, weight: .bold))
[postCountLabel, participantsLabel, postsTodayLabel].forEach {
$0.font = UIFontMetrics(forTextStyle: .title3).scaledFont(for: .systemFont(ofSize: 20, weight: .bold))
$0.text = "999"
}
[postCountDescLabel, participantsDescLabel, postsTodayDescLabel].forEach {
$0.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .regular))
}
postCountDescLabel.text = L10n.Scene.FollowedTags.Header.posts
participantsDescLabel.text = L10n.Scene.FollowedTags.Header.participants
postsTodayDescLabel.text = L10n.Scene.FollowedTags.Header.postsToday
followButton.addAction(UIAction(handler: { [weak self] _ in
self?.onButtonTapped?()
}), for: .touchUpInside)
widthConstraint = widthAnchor.constraint(greaterThanOrEqualToConstant: 0)
NSLayoutConstraint.activate([
widthConstraint,
titleLabel.topAnchor.constraint(equalTo: topAnchor, constant: .padding),
titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: .padding),
titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -CGFloat.padding),
postCountLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: .padding),
postCountLabel.centerXAnchor.constraint(equalTo: postCountDescLabel.centerXAnchor),
postCountDescLabel.leadingAnchor.constraint(equalTo: titleLabel.leadingAnchor),
participantsDescLabel.leadingAnchor.constraint(equalTo: postCountDescLabel.trailingAnchor, constant: .descriptionLabelSpacing),
participantsLabel.centerXAnchor.constraint(equalTo: participantsDescLabel.centerXAnchor),
participantsLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: .padding),
postsTodayDescLabel.leadingAnchor.constraint(equalTo: participantsDescLabel.trailingAnchor, constant: .descriptionLabelSpacing),
postsTodayLabel.centerXAnchor.constraint(equalTo: postsTodayDescLabel.centerXAnchor),
postsTodayLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: .padding),
postCountDescLabel.topAnchor.constraint(equalTo: postCountLabel.bottomAnchor),
participantsDescLabel.topAnchor.constraint(equalTo: participantsLabel.bottomAnchor),
postsTodayDescLabel.topAnchor.constraint(equalTo: postsTodayLabel.bottomAnchor),
postCountDescLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -CGFloat.padding),
participantsDescLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -CGFloat.padding),
postsTodayDescLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -CGFloat.padding),
followButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -CGFloat.padding),
followButton.bottomAnchor.constraint(equalTo: postsTodayDescLabel.bottomAnchor),
followButton.topAnchor.constraint(equalTo: postsTodayLabel.topAnchor)
])
}
}
extension HashtagTimelineHeaderView {
func update(_ entity: HashtagTimelineHeaderView.Data) {
titleLabel.text = "#\(entity.name)"
followButton.setTitle(entity.following == true ? L10n.Scene.FollowedTags.Actions.unfollow : L10n.Scene.FollowedTags.Actions.follow, for: .normal)
followButton.backgroundColor = entity.following == true ? Asset.Colors.Button.tagUnfollow.color : Asset.Colors.Button.tagFollow.color
followButton.setTitleColor(
entity.following == true ? Asset.Colors.Button.tagFollow.color : Asset.Colors.Button.tagUnfollow.color,
for: .normal
)
postCountLabel.text = String(entity.postCount)
participantsLabel.text = String(entity.participantsCount)
postsTodayLabel.text = String(entity.postsTodayCount)
}
func updateWidthConstraint(_ constant: CGFloat) {
widthConstraint.constant = constant
}
}

View File

@ -0,0 +1,47 @@
//
// HashtagTimelineHeaderViewActionButton.swift
// Mastodon
//
// Created by Marcus Kida on 25.11.22.
//
import UIKit
import MastodonUI
import MastodonAsset
class HashtagTimelineHeaderViewActionButton: RoundedEdgesButton {
init() {
super.init(frame: .zero)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func layoutSubviews() {
super.layoutSubviews()
let shadowColor: UIColor = {
switch traitCollection.userInterfaceStyle {
case .dark:
return .darkGray
default:
return .lightGray
}
}()
layer.setupShadow(
color: shadowColor,
alpha: 1,
x: 0,
y: 1,
blur: 2,
spread: 0,
roundedRect: bounds,
byRoundingCorners: .allCorners,
cornerRadii: CGSize(width: cornerRadius, height: cornerRadius)
)
}
}

View File

@ -15,6 +15,7 @@ import MastodonAsset
import MastodonCore
import MastodonUI
import MastodonLocalization
import MastodonSDK
final class HashtagTimelineViewController: UIViewController, NeedsDependency, MediaPreviewableViewController {
@ -27,6 +28,17 @@ final class HashtagTimelineViewController: UIViewController, NeedsDependency, Me
var disposeBag = Set<AnyCancellable>()
var viewModel: HashtagTimelineViewModel!
private lazy var headerView: HashtagTimelineHeaderView = {
let headerView = HashtagTimelineHeaderView()
headerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
headerView.heightAnchor.constraint(equalToConstant: 118),
])
return headerView
}()
let composeBarButtonItem: UIBarButtonItem = {
let barButtonItem = UIBarButtonItem()
@ -114,11 +126,20 @@ extension HashtagTimelineViewController {
self?.updatePromptTitle()
}
.store(in: &disposeBag)
viewModel.hashtagDetails
.receive(on: DispatchQueue.main)
.sink { [weak self] tag in
guard let tag = tag else { return }
self?.updateHeaderView(with: tag)
}
.store(in: &disposeBag)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
viewModel.viewWillAppear()
tableView.deselectRow(with: transitionCoordinator, animated: animated)
}
@ -148,7 +169,30 @@ extension HashtagTimelineViewController {
subtitle = L10n.Plural.peopleTalking(peopleTalkingNumber)
}
}
}
extension HashtagTimelineViewController {
private func updateHeaderView(with tag: Mastodon.Entity.Tag) {
if tableView.tableHeaderView == nil {
tableView.tableHeaderView = headerView
}
headerView.update(HashtagTimelineHeaderView.Data.from(tag))
headerView.onButtonTapped = { [weak self] in
switch tag.following {
case .some(false):
self?.viewModel.followTag()
case .some(true):
self?.viewModel.unfollowTag()
default:
break
}
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
headerView.updateWidthConstraint(tableView.bounds.width)
}
}
extension HashtagTimelineViewController {

View File

@ -23,7 +23,7 @@ final class HashtagTimelineViewModel {
var disposeBag = Set<AnyCancellable>()
var needLoadMiddleIndex: Int? = nil
// input
let context: AppContext
let authContext: AuthContext
@ -32,10 +32,11 @@ final class HashtagTimelineViewModel {
let timelinePredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
let hashtagEntity = CurrentValueSubject<Mastodon.Entity.Tag?, Never>(nil)
let listBatchFetchViewModel = ListBatchFetchViewModel()
// output
var diffableDataSource: UITableViewDiffableDataSource<StatusSection, StatusItem>?
let didLoadLatest = PassthroughSubject<Void, Never>()
let hashtagDetails = CurrentValueSubject<Mastodon.Entity.Tag?, Never>(nil)
// bottom loader
private(set) lazy var stateMachine: GKStateMachine = {
@ -61,6 +62,7 @@ final class HashtagTimelineViewModel {
domain: authContext.mastodonAuthenticationBox.domain,
additionalTweetPredicate: nil
)
updateTagInformation()
// end init
}
@ -68,5 +70,55 @@ final class HashtagTimelineViewModel {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s:", ((#file as NSString).lastPathComponent), #line, #function)
}
func viewWillAppear() {
let predicate = Tag.predicate(
domain: authContext.mastodonAuthenticationBox.domain,
name: hashtag
)
guard
let object = Tag.findOrFetch(in: context.managedObjectContext, matching: predicate)
else {
return hashtagDetails.send(hashtagDetails.value?.copy(following: false))
}
hashtagDetails.send(hashtagDetails.value?.copy(following: object.following))
}
}
extension HashtagTimelineViewModel {
func followTag() {
self.hashtagDetails.send(hashtagDetails.value?.copy(following: true))
Task { @MainActor in
let tag = try? await context.apiService.followTag(
for: hashtag,
authenticationBox: authContext.mastodonAuthenticationBox
).value
self.hashtagDetails.send(tag)
}
}
func unfollowTag() {
self.hashtagDetails.send(hashtagDetails.value?.copy(following: false))
Task { @MainActor in
let tag = try? await context.apiService.unfollowTag(
for: hashtag,
authenticationBox: authContext.mastodonAuthenticationBox
).value
self.hashtagDetails.send(tag)
}
}
}
private extension HashtagTimelineViewModel {
func updateTagInformation() {
Task { @MainActor in
let tag = try? await context.apiService.getTagInformation(
for: hashtag,
authenticationBox: authContext.mastodonAuthenticationBox
).value
self.hashtagDetails.send(tag)
}
}
}

View File

@ -41,7 +41,7 @@ extension HomeTimelineViewModel {
guard let self = self else { return }
guard let diffableDataSource = self.diffableDataSource else { return }
self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): incoming \(records.count) objects")
Task {
Task { @MainActor in
let start = CACurrentMediaTime()
defer {
let end = CACurrentMediaTime()
@ -98,22 +98,22 @@ extension HomeTimelineViewModel {
self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): snapshot has changes")
}
guard let difference = await self.calculateReloadSnapshotDifference(
guard let difference = self.calculateReloadSnapshotDifference(
tableView: tableView,
oldSnapshot: oldSnapshot,
newSnapshot: newSnapshot
) else {
await self.updateSnapshotUsingReloadData(snapshot: newSnapshot)
self.updateSnapshotUsingReloadData(snapshot: newSnapshot)
self.didLoadLatest.send()
self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): applied new snapshot")
return
}
await self.updateSnapshotUsingReloadData(snapshot: newSnapshot)
await tableView.scrollToRow(at: difference.targetIndexPath, at: .top, animated: false)
var contentOffset = await tableView.contentOffset
contentOffset.y = await tableView.contentOffset.y - difference.sourceDistanceToTableViewTopEdge
await tableView.setContentOffset(contentOffset, animated: false)
self.updateSnapshotUsingReloadData(snapshot: newSnapshot)
tableView.scrollToRow(at: difference.targetIndexPath, at: .top, animated: false)
var contentOffset = tableView.contentOffset
contentOffset.y = tableView.contentOffset.y - difference.sourceDistanceToTableViewTopEdge
tableView.setContentOffset(contentOffset, animated: false)
self.didLoadLatest.send()
self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): applied new snapshot")
} // end Task
@ -135,9 +135,9 @@ extension HomeTimelineViewModel {
@MainActor func updateSnapshotUsingReloadData(
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>
) async {
) {
if #available(iOS 15.0, *) {
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
} else {
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
}

View File

@ -86,6 +86,8 @@ extension HomeTimelineViewModel.LoadLatestState {
await enter(state: Idle.self)
viewModel.homeTimelineNavigationBarTitleViewModel.receiveLoadingStateCompletion(.finished)
viewModel.context.instanceService.updateMutesAndBlocks()
// stop refresher if no new statuses
let statuses = response.value
let newStatuses = statuses.filter { !latestStatusIDs.contains($0.id) }

View File

@ -68,6 +68,11 @@ extension ProfileFieldCollectionViewCell {
checkmark.addInteraction(editMenuInteraction)
}
// Setup Accessibility
checkmark.isAccessibilityElement = true
checkmark.accessibilityTraits = .none
keyMetaLabel.accessibilityTraits = .none
// containerStackView: V - [ metaContainer | plainContainer ]
let containerStackView = UIStackView()
containerStackView.axis = .vertical

View File

@ -0,0 +1,78 @@
//
// FollowedTagsTableViewCell.swift
// Mastodon
//
// Created by Marcus Kida on 24.11.22.
//
import UIKit
import CoreDataStack
final class FollowedTagsTableViewCell: UITableViewCell {
private var hashtagView: HashtagTimelineHeaderView!
private let separatorLine = UIView.separatorLine
private weak var viewModel: FollowedTagsViewModel?
private weak var hashtag: Tag?
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
required init?(coder: NSCoder) {
fatalError("Not implemented")
}
override func prepareForReuse() {
hashtagView.removeFromSuperview()
viewModel = nil
hashtagView = nil
super.prepareForReuse()
setup()
}
}
private extension FollowedTagsTableViewCell {
func setup() {
selectionStyle = .none
hashtagView = HashtagTimelineHeaderView()
hashtagView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(hashtagView)
contentView.backgroundColor = .clear
NSLayoutConstraint.activate([
hashtagView.heightAnchor.constraint(equalToConstant: 118).priority(.required),
hashtagView.topAnchor.constraint(equalTo: contentView.topAnchor),
hashtagView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
hashtagView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
hashtagView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
])
separatorLine.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(separatorLine)
NSLayoutConstraint.activate([
separatorLine.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
separatorLine.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
separatorLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
separatorLine.heightAnchor.constraint(equalToConstant: UIView.separatorLineHeight(of: contentView)),
])
hashtagView.onButtonTapped = { [weak self] in
guard let self = self, let tag = self.hashtag else { return }
self.viewModel?.followOrUnfollow(tag)
}
}
}
extension FollowedTagsTableViewCell {
func populate(with tag: Tag) {
self.hashtag = tag
hashtagView.update(HashtagTimelineHeaderView.Data.from(tag))
}
func setup(_ viewModel: FollowedTagsViewModel) {
self.viewModel = viewModel
}
}

View File

@ -0,0 +1,77 @@
//
// FollowedTagsViewController.swift
// Mastodon
//
// Created by Marcus Kida on 22.11.22.
//
import os
import UIKit
import Combine
import MastodonAsset
import MastodonCore
import MastodonUI
import MastodonLocalization
final class FollowedTagsViewController: UIViewController, NeedsDependency {
let logger = Logger(subsystem: String(describing: FollowedTagsViewController.self), category: "ViewController")
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
var disposeBag = Set<AnyCancellable>()
var viewModel: FollowedTagsViewModel!
let titleView = DoubleTitleLabelNavigationBarTitleView()
lazy var tableView: UITableView = {
let tableView = UITableView()
tableView.register(FollowedTagsTableViewCell.self, forCellReuseIdentifier: String(describing: FollowedTagsTableViewCell.self))
tableView.rowHeight = UITableView.automaticDimension
tableView.separatorStyle = .none
tableView.backgroundColor = .clear
return tableView
}()
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
}
extension FollowedTagsViewController {
override func viewDidLoad() {
super.viewDidLoad()
let _title = L10n.Scene.FollowedTags.title
title = _title
titleView.update(title: _title, subtitle: nil)
navigationItem.titleView = titleView
view.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
ThemeService.shared.currentTheme
.receive(on: RunLoop.main)
.sink { [weak self] theme in
guard let self = self else { return }
self.view.backgroundColor = theme.secondarySystemBackgroundColor
}
.store(in: &disposeBag)
tableView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(tableView)
tableView.pinToParent()
viewModel.setupTableView(tableView)
viewModel.presentHashtagTimeline
.receive(on: DispatchQueue.main)
.sink { [weak self] hashtagTimelineViewModel in
guard let self = self else { return }
_ = self.coordinator.present(
scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel),
from: self,
transition: .show
)
}
.store(in: &disposeBag)
}
}

View File

@ -0,0 +1,51 @@
//
// FollowedTagsViewModel+DiffableDataSource.swift
// Mastodon
//
// Created by Marcus Kida on 01.12.22.
//
import UIKit
import Combine
import CoreData
import CoreDataStack
import MastodonSDK
import MastodonCore
extension FollowedTagsViewModel {
enum Section: Hashable {
case main
}
enum Item: Hashable {
case hashtag(Tag)
}
func tableViewDiffableDataSource(
for tableView: UITableView
) -> UITableViewDiffableDataSource<Section, Item> {
UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item in
switch item {
case let .hashtag(tag):
guard let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: FollowedTagsTableViewCell.self), for: indexPath) as? FollowedTagsTableViewCell else {
assertionFailure()
return UITableViewCell()
}
cell.setup(self)
cell.populate(with: tag)
return cell
}
}
}
func setupDiffableDataSource(
tableView: UITableView
) {
diffableDataSource = tableViewDiffableDataSource(for: tableView)
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.main])
diffableDataSource?.apply(snapshot)
}
}

View File

@ -0,0 +1,109 @@
//
// FollowedTagsViewModel.swift
// Mastodon
//
// Created by Marcus Kida on 23.11.22.
//
import os
import UIKit
import Combine
import CoreData
import CoreDataStack
import MastodonSDK
import MastodonCore
final class FollowedTagsViewModel: NSObject {
let logger = Logger(subsystem: String(describing: FollowedTagsViewModel.self), category: "ViewModel")
var disposeBag = Set<AnyCancellable>()
let fetchedResultsController: FollowedTagsFetchedResultController
private weak var tableView: UITableView?
var diffableDataSource: UITableViewDiffableDataSource<Section, Item>?
// input
let context: AppContext
let authContext: AuthContext
// output
let presentHashtagTimeline = PassthroughSubject<HashtagTimelineViewModel, Never>()
init(context: AppContext, authContext: AuthContext) {
self.context = context
self.authContext = authContext
self.fetchedResultsController = FollowedTagsFetchedResultController(
managedObjectContext: context.managedObjectContext,
domain: authContext.mastodonAuthenticationBox.domain,
user: authContext.mastodonAuthenticationBox.authenticationRecord.object(in: context.managedObjectContext)!.user
)
super.init()
self.fetchedResultsController
.$records
.receive(on: DispatchQueue.main)
.sink { [weak self] records in
guard let self = self else { return }
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
snapshot.appendSections([.main])
snapshot.appendItems(records.map {.hashtag($0) })
self.diffableDataSource?.applySnapshot(snapshot, animated: true)
}
.store(in: &disposeBag)
}
}
extension FollowedTagsViewModel {
func setupTableView(_ tableView: UITableView) {
self.tableView = tableView
setupDiffableDataSource(tableView: tableView)
tableView.delegate = self
fetchFollowedTags()
}
func fetchFollowedTags() {
Task { @MainActor in
try await context.apiService.getFollowedTags(
domain: authContext.mastodonAuthenticationBox.domain,
query: Mastodon.API.Account.FollowedTagsQuery(limit: nil),
authenticationBox: authContext.mastodonAuthenticationBox
)
}
}
func followOrUnfollow(_ tag: Tag) {
Task { @MainActor in
switch tag.following {
case true:
_ = try? await context.apiService.unfollowTag(
for: tag.name,
authenticationBox: authContext.mastodonAuthenticationBox
)
case false:
_ = try? await context.apiService.followTag(
for: tag.name,
authenticationBox: authContext.mastodonAuthenticationBox
)
}
fetchFollowedTags()
}
}
}
extension FollowedTagsViewModel: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): \(indexPath)")
tableView.deselectRow(at: indexPath, animated: true)
let object = fetchedResultsController.records[indexPath.row]
let hashtagTimelineViewModel = HashtagTimelineViewModel(
context: self.context,
authContext: self.authContext,
hashtag: object.name
)
presentHashtagTimeline.send(hashtagTimelineViewModel)
}
}

View File

@ -104,6 +104,13 @@ final class ProfileViewController: UIViewController, NeedsDependency, MediaPrevi
barButtonItem.accessibilityLabel = L10n.Common.Controls.Actions.seeMore
return barButtonItem
}()
private(set) lazy var followedTagsBarButtonItem: UIBarButtonItem = {
let barButtonItem = UIBarButtonItem(image: UIImage(systemName: "number"), style: .plain, target: self, action: #selector(ProfileViewController.followedTagsItemPressed(_:)))
barButtonItem.tintColor = .white
barButtonItem.accessibilityLabel = L10n.Scene.FollowedTags.title
return barButtonItem
}()
let refreshControl: RefreshControl = {
let refreshControl = RefreshControl()
@ -243,6 +250,11 @@ extension ProfileViewController {
items.append(self.shareBarButtonItem)
items.append(self.favoriteBarButtonItem)
items.append(self.bookmarkBarButtonItem)
if self.currentInstance?.canFollowTags == true {
items.append(self.followedTagsBarButtonItem)
}
return
}
@ -548,6 +560,13 @@ extension ProfileViewController {
)
_ = coordinator.present(scene: .compose(viewModel: composeViewModel), from: self, transition: .modal(animated: true, completion: nil))
}
@objc private func followedTagsItemPressed(_ sender: UIBarButtonItem) {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
let followedTagsViewModel = FollowedTagsViewModel(context: context, authContext: viewModel.authContext)
_ = coordinator.present(scene: .followedTags(viewModel: followedTagsViewModel), from: self, transition: .show)
}
@objc private func refreshControlValueChanged(_ sender: RefreshControl) {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
@ -888,7 +907,7 @@ extension ProfileViewController: MastodonMenuDelegate {
// MARK: - ScrollViewContainer
extension ProfileViewController: ScrollViewContainer {
var scrollView: UIScrollView {
return tabBarPagerController.containerScrollView
return tabBarPagerController.relayScrollView
}
}
@ -917,3 +936,13 @@ extension ProfileViewController: PagerTabStripNavigateable {
}
private extension ProfileViewController {
var currentInstance: Instance? {
guard let authenticationRecord = authContext.mastodonAuthenticationBox
.authenticationRecord
.object(in: context.managedObjectContext)
else { return nil }
return authenticationRecord.instance
}
}

View File

@ -61,7 +61,7 @@ class MainTabBarController: UITabBarController {
var title: String {
switch self {
case .home: return L10n.Common.Controls.Tabs.home
case .search: return L10n.Common.Controls.Tabs.search
case .search: return L10n.Common.Controls.Tabs.searchAndExplore
case .compose: return L10n.Common.Controls.Actions.compose
case .notifications: return L10n.Common.Controls.Tabs.notifications
case .me: return L10n.Common.Controls.Tabs.profile
@ -569,25 +569,24 @@ extension MainTabBarController: UITabBarControllerDelegate {
composeButtonDidPressed(tabBarController)
return false
}
// Assert index is as same as the tab rawValue. This check needs to be done `shouldSelect`
// because the nav controller has already popped in `didSelect`.
if currentTab.rawValue == tabBarController.selectedIndex,
let navigationController = viewController as? UINavigationController,
navigationController.viewControllers.count == 1,
let scrollViewContainer = navigationController.topViewController as? ScrollViewContainer {
scrollViewContainer.scrollToTop(animated: true)
}
return true
}
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: select %s", ((#file as NSString).lastPathComponent), #line, #function, viewController.debugDescription)
defer {
if let tab = Tab(rawValue: viewController.tabBarItem.tag) {
currentTab = tab
}
if let tab = Tab(rawValue: viewController.tabBarItem.tag) {
currentTab = tab
}
// assert index is as same as the tab rawValue
guard currentTab.rawValue == tabBarController.selectedIndex,
let navigationController = viewController as? UINavigationController,
navigationController.viewControllers.count == 1,
let scrollViewContainer = navigationController.topViewController as? ScrollViewContainer else {
return
}
scrollViewContainer.scrollToTop(animated: true)
}
}

View File

@ -86,7 +86,7 @@ extension SettingsToggleTableViewCell {
return nil
default:
// set tint black for Light Mode
return self.contentView.window?.tintColor ?? nil
return self.contentView.window?.tintColor
}
}()
}

View File

@ -112,6 +112,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// trigger authenticated user account update
AppContext.shared.authenticationService.updateActiveUserAccountPublisher.send()
// update mutes and blocks and remove related data
AppContext.shared.instanceService.updateMutesAndBlocks()
if let shortcutItem = savedShortCutItem {
Task {

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21509" systemVersion="21G217" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21512" systemVersion="22A400" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Application" representedClassName="CoreDataStack.Application" syncable="YES">
<attribute name="identifier" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="name" attributeType="String"/>
@ -7,23 +7,6 @@
<attribute name="website" optional="YES" attributeType="String"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="application" inverseEntity="Status"/>
</entity>
<entity name="Card" representedClassName="CoreDataStack.Card" syncable="YES">
<attribute name="authorName" optional="YES" attributeType="String"/>
<attribute name="authorURLRaw" optional="YES" attributeType="String"/>
<attribute name="blurhash" optional="YES" attributeType="String"/>
<attribute name="desc" attributeType="String"/>
<attribute name="embedURLRaw" optional="YES" attributeType="String"/>
<attribute name="height" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="html" optional="YES" attributeType="String"/>
<attribute name="image" optional="YES" attributeType="String"/>
<attribute name="providerName" optional="YES" attributeType="String"/>
<attribute name="providerURLRaw" optional="YES" attributeType="String"/>
<attribute name="title" attributeType="String"/>
<attribute name="typeRaw" attributeType="String"/>
<attribute name="urlRaw" attributeType="String"/>
<attribute name="width" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="card" inverseEntity="Status"/>
</entity>
<entity name="DomainBlock" representedClassName="CoreDataStack.DomainBlock" syncable="YES">
<attribute name="blockedDomain" attributeType="String"/>
<attribute name="createAt" attributeType="Date" usesScalarValueType="NO"/>
@ -61,6 +44,7 @@
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="version" optional="YES" attributeType="String"/>
<relationship name="authentications" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonAuthentication" inverseName="instance" inverseEntity="MastodonAuthentication"/>
</entity>
<entity name="MastodonAuthentication" representedClassName="CoreDataStack.MastodonAuthentication" syncable="YES">
@ -109,6 +93,7 @@
<relationship name="endorsed" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="endorsedBy" inverseEntity="MastodonUser"/>
<relationship name="endorsedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="endorsed" inverseEntity="MastodonUser"/>
<relationship name="favourite" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="favouritedBy" inverseEntity="Status"/>
<relationship name="followedTags" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Tag" inverseName="followedBy" inverseEntity="Tag"/>
<relationship name="following" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="followingBy" inverseEntity="MastodonUser"/>
<relationship name="followingBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="following" inverseEntity="MastodonUser"/>
<relationship name="followRequested" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="followRequestedBy" inverseEntity="MastodonUser"/>
@ -222,7 +207,6 @@
<relationship name="application" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Application" inverseName="status" inverseEntity="Application"/>
<relationship name="author" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="statuses" inverseEntity="MastodonUser"/>
<relationship name="bookmarkedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="bookmarked" inverseEntity="MastodonUser"/>
<relationship name="card" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Card" inverseName="status" inverseEntity="Card"/>
<relationship name="favouritedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="favourite" inverseEntity="MastodonUser"/>
<relationship name="feeds" toMany="YES" deletionRule="Cascade" destinationEntity="Feed" inverseName="status" inverseEntity="Feed"/>
<relationship name="mutedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="muted" inverseEntity="MastodonUser"/>
@ -262,11 +246,13 @@
<entity name="Tag" representedClassName="CoreDataStack.Tag" syncable="YES">
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String" defaultValueString=""/>
<attribute name="following" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="histories" optional="YES" attributeType="Binary"/>
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="name" attributeType="String"/>
<attribute name="updatedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="url" attributeType="String"/>
<relationship name="followedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="followedTags" inverseEntity="MastodonUser"/>
<relationship name="searchHistories" toMany="YES" deletionRule="Nullify" destinationEntity="SearchHistory" inverseName="hashtag" inverseEntity="SearchHistory"/>
</entity>
</model>

View File

@ -0,0 +1,274 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21509" systemVersion="21G217" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Application" representedClassName="CoreDataStack.Application" syncable="YES">
<attribute name="identifier" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="name" attributeType="String"/>
<attribute name="vapidKey" optional="YES" attributeType="String"/>
<attribute name="website" optional="YES" attributeType="String"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="application" inverseEntity="Status"/>
</entity>
<entity name="Card" representedClassName="CoreDataStack.Card" syncable="YES">
<attribute name="authorName" optional="YES" attributeType="String"/>
<attribute name="authorURLRaw" optional="YES" attributeType="String"/>
<attribute name="blurhash" optional="YES" attributeType="String"/>
<attribute name="desc" attributeType="String"/>
<attribute name="embedURLRaw" optional="YES" attributeType="String"/>
<attribute name="height" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="html" optional="YES" attributeType="String"/>
<attribute name="image" optional="YES" attributeType="String"/>
<attribute name="providerName" optional="YES" attributeType="String"/>
<attribute name="providerURLRaw" optional="YES" attributeType="String"/>
<attribute name="title" attributeType="String"/>
<attribute name="typeRaw" attributeType="String"/>
<attribute name="urlRaw" attributeType="String"/>
<attribute name="width" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="card" inverseEntity="Status"/>
</entity>
<entity name="DomainBlock" representedClassName="CoreDataStack.DomainBlock" syncable="YES">
<attribute name="blockedDomain" attributeType="String"/>
<attribute name="createAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="userID" attributeType="String"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="userID"/>
<constraint value="domain"/>
<constraint value="blockedDomain"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="Emoji" representedClassName="CoreDataStack.Emoji" syncable="YES">
<attribute name="category" optional="YES" attributeType="String"/>
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="shortcode" attributeType="String"/>
<attribute name="staticURL" attributeType="String"/>
<attribute name="url" attributeType="String"/>
<attribute name="visibleInPicker" attributeType="Boolean" usesScalarValueType="YES"/>
</entity>
<entity name="Feed" representedClassName="CoreDataStack.Feed" syncable="YES">
<attribute name="acctRaw" optional="YES" attributeType="String"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="hasMore" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="isLoadingMore" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="kindRaw" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<relationship name="notification" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Notification" inverseName="feeds" inverseEntity="Notification"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="feeds" inverseEntity="Status"/>
</entity>
<entity name="Instance" representedClassName="CoreDataStack.Instance" syncable="YES">
<attribute name="configurationRaw" optional="YES" attributeType="Binary"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="version" optional="YES" attributeType="String"/>
<relationship name="authentications" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonAuthentication" inverseName="instance" inverseEntity="MastodonAuthentication"/>
</entity>
<entity name="MastodonAuthentication" representedClassName="CoreDataStack.MastodonAuthentication" syncable="YES">
<attribute name="activedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="appAccessToken" attributeType="String"/>
<attribute name="clientID" attributeType="String"/>
<attribute name="clientSecret" attributeType="String"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="userAccessToken" attributeType="String"/>
<attribute name="userID" attributeType="String"/>
<attribute name="username" attributeType="String"/>
<relationship name="instance" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Instance" inverseName="authentications" inverseEntity="Instance"/>
<relationship name="user" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="mastodonAuthentication" inverseEntity="MastodonUser"/>
</entity>
<entity name="MastodonUser" representedClassName="CoreDataStack.MastodonUser" syncable="YES">
<attribute name="acct" attributeType="String"/>
<attribute name="avatar" attributeType="String"/>
<attribute name="avatarStatic" optional="YES" attributeType="String"/>
<attribute name="bot" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="displayName" attributeType="String"/>
<attribute name="domain" attributeType="String"/>
<attribute name="emojis" optional="YES" attributeType="Binary"/>
<attribute name="fields" optional="YES" attributeType="Binary"/>
<attribute name="followersCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="followingCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="header" attributeType="String"/>
<attribute name="headerStatic" optional="YES" attributeType="String"/>
<attribute name="id" attributeType="String"/>
<attribute name="identifier" attributeType="String"/>
<attribute name="locked" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="note" optional="YES" attributeType="String"/>
<attribute name="statusesCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="suspended" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="url" optional="YES" attributeType="String"/>
<attribute name="username" attributeType="String"/>
<relationship name="blocking" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="blockingBy" inverseEntity="MastodonUser"/>
<relationship name="blockingBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="blocking" inverseEntity="MastodonUser"/>
<relationship name="bookmarked" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="bookmarkedBy" inverseEntity="Status"/>
<relationship name="domainBlocking" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="domainBlockingBy" inverseEntity="MastodonUser"/>
<relationship name="domainBlockingBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="domainBlocking" inverseEntity="MastodonUser"/>
<relationship name="endorsed" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="endorsedBy" inverseEntity="MastodonUser"/>
<relationship name="endorsedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="endorsed" inverseEntity="MastodonUser"/>
<relationship name="favourite" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="favouritedBy" inverseEntity="Status"/>
<relationship name="followedTags" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Tag" inverseName="followedBy" inverseEntity="Tag"/>
<relationship name="following" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="followingBy" inverseEntity="MastodonUser"/>
<relationship name="followingBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="following" inverseEntity="MastodonUser"/>
<relationship name="followRequested" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="followRequestedBy" inverseEntity="MastodonUser"/>
<relationship name="followRequestedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="followRequested" inverseEntity="MastodonUser"/>
<relationship name="mastodonAuthentication" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonAuthentication" inverseName="user" inverseEntity="MastodonAuthentication"/>
<relationship name="muted" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="mutedBy" inverseEntity="Status"/>
<relationship name="muting" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="mutingBy" inverseEntity="MastodonUser"/>
<relationship name="mutingBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="muting" inverseEntity="MastodonUser"/>
<relationship name="notifications" toMany="YES" deletionRule="Nullify" destinationEntity="Notification" inverseName="account" inverseEntity="Notification"/>
<relationship name="pinnedStatus" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="pinnedBy" inverseEntity="Status"/>
<relationship name="privateNotes" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PrivateNote" inverseName="to" inverseEntity="PrivateNote"/>
<relationship name="privateNotesTo" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="PrivateNote" inverseName="from" inverseEntity="PrivateNote"/>
<relationship name="reblogged" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="rebloggedBy" inverseEntity="Status"/>
<relationship name="searchHistories" toMany="YES" deletionRule="Nullify" destinationEntity="SearchHistory" inverseName="account" inverseEntity="SearchHistory"/>
<relationship name="showingReblogs" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="showingReblogsBy" inverseEntity="MastodonUser"/>
<relationship name="showingReblogsBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="showingReblogs" inverseEntity="MastodonUser"/>
<relationship name="statuses" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="author" inverseEntity="Status"/>
<relationship name="votePollOptions" toMany="YES" deletionRule="Nullify" destinationEntity="PollOption" inverseName="votedBy" inverseEntity="PollOption"/>
<relationship name="votePolls" toMany="YES" deletionRule="Nullify" destinationEntity="Poll" inverseName="votedBy" inverseEntity="Poll"/>
</entity>
<entity name="Notification" representedClassName="CoreDataStack.Notification" syncable="YES">
<attribute name="createAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="followRequestState" optional="YES" attributeType="Binary"/>
<attribute name="id" attributeType="String"/>
<attribute name="transientFollowRequestState" optional="YES" transient="YES" attributeType="Binary"/>
<attribute name="typeRaw" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="userID" attributeType="String"/>
<relationship name="account" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="notifications" inverseEntity="MastodonUser"/>
<relationship name="feeds" toMany="YES" deletionRule="Cascade" destinationEntity="Feed" inverseName="notification" inverseEntity="Feed"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="notifications" inverseEntity="Status"/>
</entity>
<entity name="Poll" representedClassName="CoreDataStack.Poll" syncable="YES">
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String" defaultValueString=""/>
<attribute name="expired" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="expiresAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="id" attributeType="String"/>
<attribute name="isVoting" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="multiple" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="votersCount" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="votesCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<relationship name="options" toMany="YES" deletionRule="Cascade" destinationEntity="PollOption" inverseName="poll" inverseEntity="PollOption"/>
<relationship name="status" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="poll" inverseEntity="Status"/>
<relationship name="votedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="votePolls" inverseEntity="MastodonUser"/>
</entity>
<entity name="PollOption" representedClassName="CoreDataStack.PollOption" syncable="YES">
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="index" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="isSelected" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="title" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="votesCount" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<relationship name="poll" maxCount="1" deletionRule="Nullify" destinationEntity="Poll" inverseName="options" inverseEntity="Poll"/>
<relationship name="votedBy" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="votePollOptions" inverseEntity="MastodonUser"/>
</entity>
<entity name="PrivateNote" representedClassName="CoreDataStack.PrivateNote" syncable="YES">
<attribute name="note" optional="YES" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<relationship name="from" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="privateNotesTo" inverseEntity="MastodonUser"/>
<relationship name="to" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="privateNotes" inverseEntity="MastodonUser"/>
</entity>
<entity name="SearchHistory" representedClassName="CoreDataStack.SearchHistory" syncable="YES">
<attribute name="createAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String" defaultValueString=""/>
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="updatedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="userID" attributeType="String" defaultValueString=""/>
<relationship name="account" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="searchHistories" inverseEntity="MastodonUser"/>
<relationship name="hashtag" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Tag" inverseName="searchHistories" inverseEntity="Tag"/>
<relationship name="status" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="searchHistories" inverseEntity="Status"/>
</entity>
<entity name="Setting" representedClassName="CoreDataStack.Setting" syncable="YES">
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="preferredStaticAvatar" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="preferredStaticEmoji" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="preferredTrueBlackDarkMode" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="preferredUsingDefaultBrowser" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="userID" attributeType="String"/>
<relationship name="subscriptions" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Subscription" inverseName="setting" inverseEntity="Subscription"/>
</entity>
<entity name="Status" representedClassName="CoreDataStack.Status" syncable="YES">
<attribute name="attachments" optional="YES" attributeType="Binary"/>
<attribute name="content" attributeType="String"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="deletedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String"/>
<attribute name="emojis" optional="YES" attributeType="Binary"/>
<attribute name="favouritesCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="id" attributeType="String"/>
<attribute name="identifier" attributeType="String"/>
<attribute name="inReplyToAccountID" optional="YES" attributeType="String"/>
<attribute name="inReplyToID" optional="YES" attributeType="String"/>
<attribute name="isSensitiveToggled" transient="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="language" optional="YES" attributeType="String"/>
<attribute name="mentions" optional="YES" attributeType="Binary"/>
<attribute name="reblogsCount" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="repliesCount" optional="YES" attributeType="Integer 64" usesScalarValueType="NO"/>
<attribute name="revealedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="sensitive" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="spoilerText" optional="YES" attributeType="String"/>
<attribute name="text" optional="YES" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="uri" attributeType="String"/>
<attribute name="url" optional="YES" attributeType="String"/>
<attribute name="visibilityRaw" optional="YES" attributeType="String" elementID="visibility"/>
<relationship name="application" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Application" inverseName="status" inverseEntity="Application"/>
<relationship name="author" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="statuses" inverseEntity="MastodonUser"/>
<relationship name="bookmarkedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="bookmarked" inverseEntity="MastodonUser"/>
<relationship name="favouritedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="favourite" inverseEntity="MastodonUser"/>
<relationship name="feeds" toMany="YES" deletionRule="Cascade" destinationEntity="Feed" inverseName="status" inverseEntity="Feed"/>
<relationship name="mutedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="muted" inverseEntity="MastodonUser"/>
<relationship name="notifications" toMany="YES" deletionRule="Cascade" destinationEntity="Notification" inverseName="status" inverseEntity="Notification"/>
<relationship name="pinnedBy" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="pinnedStatus" inverseEntity="MastodonUser"/>
<relationship name="poll" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="Poll" inverseName="status" inverseEntity="Poll"/>
<relationship name="reblog" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="reblogFrom" inverseEntity="Status"/>
<relationship name="reblogFrom" toMany="YES" deletionRule="Cascade" destinationEntity="Status" inverseName="reblog" inverseEntity="Status"/>
<relationship name="rebloggedBy" toMany="YES" deletionRule="Nullify" destinationEntity="MastodonUser" inverseName="reblogged" inverseEntity="MastodonUser"/>
<relationship name="replyFrom" toMany="YES" deletionRule="Nullify" destinationEntity="Status" inverseName="replyTo" inverseEntity="Status"/>
<relationship name="replyTo" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Status" inverseName="replyFrom" inverseEntity="Status"/>
<relationship name="searchHistories" toMany="YES" deletionRule="Cascade" destinationEntity="SearchHistory" inverseName="status" inverseEntity="SearchHistory"/>
</entity>
<entity name="Subscription" representedClassName="CoreDataStack.Subscription" syncable="YES">
<attribute name="activedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="endpoint" optional="YES" attributeType="String"/>
<attribute name="id" optional="YES" attributeType="String"/>
<attribute name="policyRaw" attributeType="String"/>
<attribute name="serverKey" optional="YES" attributeType="String"/>
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="userToken" optional="YES" attributeType="String"/>
<relationship name="alert" maxCount="1" deletionRule="Cascade" destinationEntity="SubscriptionAlerts" inverseName="subscription" inverseEntity="SubscriptionAlerts"/>
<relationship name="setting" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Setting" inverseName="subscriptions" inverseEntity="Setting"/>
</entity>
<entity name="SubscriptionAlerts" representedClassName="CoreDataStack.SubscriptionAlerts" syncable="YES">
<attribute name="createdAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="favouriteRaw" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="followRaw" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="followRequestRaw" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="mentionRaw" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="pollRaw" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="reblogRaw" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="updatedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<relationship name="subscription" maxCount="1" deletionRule="Nullify" destinationEntity="Subscription" inverseName="alert" inverseEntity="Subscription"/>
</entity>
<entity name="Tag" representedClassName="CoreDataStack.Tag" syncable="YES">
<attribute name="createAt" attributeType="Date" defaultDateTimeInterval="631123200" usesScalarValueType="NO"/>
<attribute name="domain" attributeType="String" defaultValueString=""/>
<attribute name="following" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="histories" optional="YES" attributeType="Binary"/>
<attribute name="identifier" attributeType="UUID" usesScalarValueType="NO"/>
<attribute name="name" attributeType="String"/>
<attribute name="updatedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="url" attributeType="String"/>
<relationship name="searchHistories" toMany="YES" deletionRule="Nullify" destinationEntity="SearchHistory" inverseName="hashtag" inverseEntity="SearchHistory"/>
</entity>
</model>

View File

@ -10,7 +10,8 @@ import CoreData
public final class Instance: NSManagedObject {
@NSManaged public var domain: String
@NSManaged public var version: String?
@NSManaged public private(set) var createdAt: Date
@NSManaged public private(set) var updatedAt: Date
@ -35,6 +36,7 @@ extension Instance {
) -> Instance {
let instance: Instance = context.insertObject()
instance.domain = property.domain
instance.version = property.version
return instance
}
@ -50,9 +52,11 @@ extension Instance {
extension Instance {
public struct Property {
public let domain: String
public init(domain: String) {
public let version: String?
public init(domain: String, version: String?) {
self.domain = domain
self.version = version
}
}
}

View File

@ -77,6 +77,7 @@ final public class MastodonUser: NSManagedObject {
@NSManaged public private(set) var votePollOptions: Set<PollOption>
@NSManaged public private(set) var votePolls: Set<Poll>
// relationships
@NSManaged public private(set) var followedTags: Set<Tag>
@NSManaged public private(set) var following: Set<MastodonUser>
@NSManaged public private(set) var followingBy: Set<MastodonUser>
@NSManaged public private(set) var followRequested: Set<MastodonUser>

View File

@ -24,10 +24,13 @@ public final class Tag: NSManagedObject {
@NSManaged public private(set) var name: String
// sourcery: autoUpdatableObject, autoGenerateProperty
@NSManaged public private(set) var url: String
// sourcery: autoUpdatableObject, autoGenerateProperty
@NSManaged public private(set) var following: Bool
// one-to-one relationship
// many-to-many relationship
@NSManaged public private(set) var followedBy: Set<MastodonUser>
// one-to-many relationship
@NSManaged public private(set) var searchHistories: Set<SearchHistory>
@ -88,7 +91,16 @@ public extension Tag {
}
static func predicate(name: String) -> NSPredicate {
NSPredicate(format: "%K == %@", #keyPath(Tag.name), name)
// use case-insensitive query as tags #CaN #BE #speLLed #USiNG #arbITRARy #cASe
NSPredicate(format: "%K MATCHES[c] %@", #keyPath(Tag.name), name)
}
static func predicate(domain: String, following: Bool) -> NSPredicate {
NSPredicate(format: "%K == %@ AND %K == %d", #keyPath(Tag.domain), domain, #keyPath(Tag.following), following)
}
static func predicate(followedBy user: MastodonUser) -> NSPredicate {
NSPredicate(format: "ANY %K.%K == %@", #keyPath(Tag.followedBy), #keyPath(MastodonUser.id), user.id)
}
static func predicate(domain: String, name: String) -> NSPredicate {
@ -97,6 +109,13 @@ public extension Tag {
predicate(name: name),
])
}
static func predicate(domain: String, following: Bool, by user: MastodonUser) -> NSPredicate {
NSCompoundPredicate(andPredicateWithSubpredicates: [
predicate(domain: domain, following: following),
predicate(followedBy: user)
])
}
}
// MARK: - AutoGenerateProperty
@ -112,6 +131,7 @@ extension Tag: AutoGenerateProperty {
public let updatedAt: Date
public let name: String
public let url: String
public let following: Bool
public let histories: [MastodonTagHistory]
public init(
@ -121,6 +141,7 @@ extension Tag: AutoGenerateProperty {
updatedAt: Date,
name: String,
url: String,
following: Bool,
histories: [MastodonTagHistory]
) {
self.identifier = identifier
@ -129,6 +150,7 @@ extension Tag: AutoGenerateProperty {
self.updatedAt = updatedAt
self.name = name
self.url = url
self.following = following
self.histories = histories
}
}
@ -140,12 +162,14 @@ extension Tag: AutoGenerateProperty {
self.updatedAt = property.updatedAt
self.name = property.name
self.url = property.url
self.following = property.following
self.histories = property.histories
}
public func update(property: Property) {
update(updatedAt: property.updatedAt)
update(url: property.url)
update(following: property.following)
update(histories: property.histories)
}
// sourcery:end
@ -167,12 +191,30 @@ extension Tag: AutoUpdatableObject {
self.url = url
}
}
public func update(following: Bool) {
if self.following != following {
self.following = following
}
}
public func update(histories: [MastodonTagHistory]) {
if self.histories != histories {
self.histories = histories
}
}
// sourcery:end
public func update(followed: Bool, by mastodonUser: MastodonUser) {
if following {
if !self.followedBy.contains(mastodonUser) {
self.mutableSetValue(forKey: #keyPath(Tag.followedBy)).add(mastodonUser)
}
} else {
if self.followedBy.contains(mastodonUser) {
self.mutableSetValue(forKey: #keyPath(Tag.followedBy)).remove(mastodonUser)
}
}
}
}

View File

@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x38",
"green" : "0x29",
"red" : "0x2B"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFF"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x38",
"green" : "0x29",
"red" : "0x2B"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -49,6 +49,8 @@ public enum Asset {
public static let actionToolbar = ColorAsset(name: "Colors/Button/action.toolbar")
public static let disabled = ColorAsset(name: "Colors/Button/disabled")
public static let inactive = ColorAsset(name: "Colors/Button/inactive")
public static let tagFollow = ColorAsset(name: "Colors/Button/tagFollow")
public static let tagUnfollow = ColorAsset(name: "Colors/Button/tagUnfollow")
}
public enum Icon {
public static let plus = ColorAsset(name: "Colors/Icon/plus")

View File

@ -115,6 +115,10 @@ public class AppContext: ObservableObject {
.store(in: &disposeBag)
}
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
}
extension AppContext {

View File

@ -23,3 +23,10 @@ extension Instance {
return try? JSONEncoder().encode(configuration)
}
}
extension Instance {
public var canFollowTags: Bool {
guard let majorVersionString = version?.split(separator: ".").first else { return false }
return Int(majorVersionString) == 4 // following Tags is support beginning with Mastodon v4.0.0
}
}

View File

@ -22,6 +22,7 @@ extension Tag.Property {
updatedAt: networkDate,
name: entity.name,
url: entity.url,
following: entity.following ?? false,
histories: {
guard let histories = entity.history else { return [] }
let result: [MastodonTagHistory] = histories.map { history in

View File

@ -0,0 +1,77 @@
//
// FollowedTagsFetchedResultController.swift
//
//
// Created by Marcus Kida on 23.11.22.
//
import os.log
import UIKit
import Combine
import CoreData
import CoreDataStack
import MastodonSDK
public final class FollowedTagsFetchedResultController: NSObject {
var disposeBag = Set<AnyCancellable>()
let fetchedResultsController: NSFetchedResultsController<Tag>
// input
@Published public var domain: String? = nil
@Published public var user: MastodonUser? = nil
// output
@Published public private(set) var records: [Tag] = []
public init(managedObjectContext: NSManagedObjectContext, domain: String, user: MastodonUser) {
self.domain = domain
self.fetchedResultsController = {
let fetchRequest = Tag.sortedFetchRequest
fetchRequest.predicate = Tag.predicate(domain: domain, following: true, by: user)
fetchRequest.sortDescriptors = Tag.defaultSortDescriptors
fetchRequest.returnsObjectsAsFaults = false
fetchRequest.fetchBatchSize = 20
let controller = NSFetchedResultsController(
fetchRequest: fetchRequest,
managedObjectContext: managedObjectContext,
sectionNameKeyPath: nil,
cacheName: nil
)
return controller
}()
super.init()
fetchedResultsController.delegate = self
try? fetchedResultsController.performFetch()
Publishers.CombineLatest(
self.$domain,
self.$user
)
.receive(on: DispatchQueue.main)
.sink { [weak self] domain, user in
guard let self = self, let domain = domain, let user = user else { return }
self.fetchedResultsController.fetchRequest.predicate = Tag.predicate(domain: domain, following: true, by: user)
do {
try self.fetchedResultsController.performFetch()
} catch {
assertionFailure(error.localizedDescription)
}
}
.store(in: &disposeBag)
}
}
// MARK: - NSFetchedResultsControllerDelegate
extension FollowedTagsFetchedResultController: NSFetchedResultsControllerDelegate {
public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) {
os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
let objects = fetchedResultsController.fetchedObjects ?? []
self.records = objects
}
}

View File

@ -103,6 +103,9 @@ extension Persistence.Tag {
property: property
)
update(tag: object, context: context)
if let followingUser = context.me {
object.update(followed: property.following, by: followingUser)
}
return object
}
@ -116,7 +119,11 @@ extension Persistence.Tag {
domain: context.domain,
networkDate: context.networkDate
)
tag.update(property: property)
if let followingUser = context.me {
tag.update(followed: property.following, by: followingUser)
}
update(tag: tag, context: context)
}

View File

@ -161,3 +161,41 @@ extension APIService {
}
}
extension APIService {
@discardableResult
public func getFollowedTags(
domain: String,
query: Mastodon.API.Account.FollowedTagsQuery,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Tag]> {
let domain = authenticationBox.domain
let authorization = authenticationBox.userAuthorization
let response = try await Mastodon.API.Account.followedTags(
session: session,
domain: domain,
query: query,
authorization: authorization
).singleOutput()
let managedObjectContext = self.backgroundManagedObjectContext
try await managedObjectContext.performChanges {
let me = authenticationBox.authenticationRecord.object(in: managedObjectContext)?.user
for entity in response.value {
_ = Persistence.Tag.createOrMerge(
in: managedObjectContext,
context: Persistence.Tag.PersistContext(
domain: domain,
entity: entity,
me: me,
networkDate: response.networkDate
)
)
}
}
return response
} // end func
}

View File

@ -22,6 +22,45 @@ extension APIService {
let isFollowing: Bool
}
@discardableResult
public func getBlocked(
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
try await _getBlocked(sinceID: nil, limit: nil, authenticationBox: authenticationBox)
}
private func _getBlocked(
sinceID: Mastodon.Entity.Status.ID?,
limit: Int?,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
let managedObjectContext = backgroundManagedObjectContext
let response = try await Mastodon.API.Account.blocks(
session: session,
domain: authenticationBox.domain,
sinceID: sinceID,
limit: limit,
authorization: authenticationBox.userAuthorization
).singleOutput()
let userIDs = response.value.map { $0.id }
let predicate = MastodonUser.predicate(domain: authenticationBox.domain, ids: userIDs)
let fetchRequest = MastodonUser.fetchRequest()
fetchRequest.predicate = predicate
fetchRequest.includesPropertyValues = false
try await managedObjectContext.performChanges {
let users = try managedObjectContext.fetch(fetchRequest) as! [MastodonUser]
for user in users {
user.deleteStatusAndNotificationFeeds(in: managedObjectContext)
}
}
return response
}
public func toggleBlock(
user: ManagedObjectRecord<MastodonUser>,
authenticationBox: MastodonAuthenticationBox
@ -110,3 +149,21 @@ extension APIService {
}
}
extension MastodonUser {
func deleteStatusAndNotificationFeeds(in context: NSManagedObjectContext) {
statuses.map {
$0.feeds
.union($0.reblogFrom.map { $0.feeds }.flatMap { $0 })
.union($0.notifications.map { $0.feeds }.flatMap { $0 })
}
.flatMap { $0 }
.forEach(context.delete)
notifications.map {
$0.feeds
}
.flatMap { $0 }
.forEach(context.delete)
}
}

View File

@ -21,6 +21,45 @@ extension APIService {
let isMuting: Bool
}
@discardableResult
public func getMutes(
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
try await _getMutes(sinceID: nil, limit: nil, authenticationBox: authenticationBox)
}
private func _getMutes(
sinceID: Mastodon.Entity.Status.ID?,
limit: Int?,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Account]> {
let managedObjectContext = backgroundManagedObjectContext
let response = try await Mastodon.API.Account.mutes(
session: session,
domain: authenticationBox.domain,
sinceID: sinceID,
limit: limit,
authorization: authenticationBox.userAuthorization
).singleOutput()
let userIDs = response.value.map { $0.id }
let predicate = MastodonUser.predicate(domain: authenticationBox.domain, ids: userIDs)
let fetchRequest = MastodonUser.fetchRequest()
fetchRequest.predicate = predicate
fetchRequest.includesPropertyValues = false
try await managedObjectContext.performChanges {
let users = try managedObjectContext.fetch(fetchRequest) as! [MastodonUser]
for user in users {
user.deleteStatusAndNotificationFeeds(in: managedObjectContext)
}
}
return response
}
public func toggleMute(
user: ManagedObjectRecord<MastodonUser>,
authenticationBox: MastodonAuthenticationBox
@ -58,6 +97,7 @@ extension APIService {
accountID: muteContext.targetUserID,
authorization: authenticationBox.userAuthorization
).singleOutput()
try await getMutes(authenticationBox: authenticationBox)
result = .success(response)
} else {
let response = try await Mastodon.API.Account.mute(
@ -66,6 +106,7 @@ extension APIService {
accountID: muteContext.targetUserID,
authorization: authenticationBox.userAuthorization
).singleOutput()
try await getMutes(authenticationBox: authenticationBox)
result = .success(response)
}
} catch {

View File

@ -0,0 +1,92 @@
//
// APIService+Tags.swift
//
//
// Created by Marcus Kida on 23.11.22.
//
import os.log
import Foundation
import Combine
import CoreData
import CoreDataStack
import MastodonSDK
extension APIService {
public func getTagInformation(
for tag: String,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Tag> {
let domain = authenticationBox.domain
let authorization = authenticationBox.userAuthorization
let response = try await Mastodon.API.Tags.getTagInformation(
session: session,
domain: domain,
tagId: tag,
authorization: authorization
).singleOutput()
return try await persistTag(from: response, domain: domain, authenticationBox: authenticationBox)
} // end func
public func followTag(
for tag: String,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Tag> {
let domain = authenticationBox.domain
let authorization = authenticationBox.userAuthorization
let response = try await Mastodon.API.Tags.followTag(
session: session,
domain: domain,
tagId: tag,
authorization: authorization
).singleOutput()
return try await persistTag(from: response, domain: domain, authenticationBox: authenticationBox)
} // end func
public func unfollowTag(
for tag: String,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Tag> {
let domain = authenticationBox.domain
let authorization = authenticationBox.userAuthorization
let response = try await Mastodon.API.Tags.unfollowTag(
session: session,
domain: domain,
tagId: tag,
authorization: authorization
).singleOutput()
return try await persistTag(from: response, domain: domain, authenticationBox: authenticationBox)
} // end func
}
fileprivate extension APIService {
func persistTag(
from response: Mastodon.Response.Content<Mastodon.Entity.Tag>,
domain: String,
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<Mastodon.Entity.Tag> {
let managedObjectContext = self.backgroundManagedObjectContext
try await managedObjectContext.performChanges {
let me = authenticationBox.authenticationRecord.object(in: managedObjectContext)?.user
_ = Persistence.Tag.createOrMerge(
in: managedObjectContext,
context: Persistence.Tag.PersistContext(
domain: domain,
entity: response.value,
me: me,
networkDate: response.networkDate
)
)
}
return response
}
}

View File

@ -46,7 +46,7 @@ extension APIService.CoreData {
} else {
let instance = Instance.insert(
into: managedObjectContext,
property: Instance.Property(domain: domain)
property: Instance.Property(domain: domain, version: entity.version)
)
let configurationRaw = entity.configuration.flatMap { Instance.encode(configuration: $0) }
instance.update(configurationRaw: configurationRaw)
@ -69,7 +69,8 @@ extension APIService.CoreData {
let configurationRaw = entity.configuration.flatMap { Instance.encode(configuration: $0) }
instance.update(configurationRaw: configurationRaw)
instance.version = entity.version
instance.didUpdate(at: networkDate)
}

View File

@ -101,3 +101,25 @@ extension InstanceService {
.store(in: &disposeBag)
}
}
public extension InstanceService {
func updateMutesAndBlocks() {
Task {
for authBox in authenticationService?.mastodonAuthenticationBoxes ?? [] {
do {
try await apiService?.getMutes(
authenticationBox: authBox
)
try await apiService?.getBlocked(
authenticationBox: authBox
)
self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Instance] update mutes and blocks succeeded")
} catch {
self.logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): [Instance] update mutes and blocks failure: \(error.localizedDescription)")
}
}
}
}
}

View File

@ -380,8 +380,8 @@ public enum L10n {
public static let notifications = L10n.tr("Localizable", "Common.Controls.Tabs.Notifications", fallback: "Notifications")
/// Profile
public static let profile = L10n.tr("Localizable", "Common.Controls.Tabs.Profile", fallback: "Profile")
/// Search
public static let search = L10n.tr("Localizable", "Common.Controls.Tabs.Search", fallback: "Search")
/// Search and Explore
public static let searchAndExplore = L10n.tr("Localizable", "Common.Controls.Tabs.SearchAndExplore", fallback: "Search and Explore")
}
public enum Timeline {
/// Filtered
@ -643,6 +643,24 @@ public enum L10n {
/// Favorited By
public static let title = L10n.tr("Localizable", "Scene.FavoritedBy.Title", fallback: "Favorited By")
}
public enum FollowedTags {
/// Followed Tags
public static let title = L10n.tr("Localizable", "Scene.FollowedTags.Title", fallback: "Followed Tags")
public enum Actions {
/// Follow
public static let follow = L10n.tr("Localizable", "Scene.FollowedTags.Actions.Follow", fallback: "Follow")
/// Unfollow
public static let unfollow = L10n.tr("Localizable", "Scene.FollowedTags.Actions.Unfollow", fallback: "Unfollow")
}
public enum Header {
/// participants
public static let participants = L10n.tr("Localizable", "Scene.FollowedTags.Header.Participants", fallback: "participants")
/// posts
public static let posts = L10n.tr("Localizable", "Scene.FollowedTags.Header.Posts", fallback: "posts")
/// posts today
public static let postsToday = L10n.tr("Localizable", "Scene.FollowedTags.Header.PostsToday", fallback: "posts today")
}
}
public enum Follower {
/// Followers from other servers are not displayed.
public static let footer = L10n.tr("Localizable", "Scene.Follower.Footer", fallback: "Followers from other servers are not displayed.")

View File

@ -137,7 +137,7 @@ Please check your internet connection.";
"Common.Controls.Tabs.Home" = "Home";
"Common.Controls.Tabs.Notifications" = "Notifications";
"Common.Controls.Tabs.Profile" = "Profile";
"Common.Controls.Tabs.Search" = "Search";
"Common.Controls.Tabs.SearchAndExplore" = "Search and Explore";
"Common.Controls.Timeline.Filtered" = "Filtered";
"Common.Controls.Timeline.Header.BlockedWarning" = "You cant view this users profile
until they unblock you.";
@ -233,6 +233,12 @@ uploaded to Mastodon.";
"Scene.Familiarfollowers.Title" = "Followers you familiar";
"Scene.Favorite.Title" = "Your Favorites";
"Scene.FavoritedBy.Title" = "Favorited By";
"Scene.FollowedTags.Actions.Follow" = "Follow";
"Scene.FollowedTags.Actions.Unfollow" = "Unfollow";
"Scene.FollowedTags.Header.Participants" = "participants";
"Scene.FollowedTags.Header.Posts" = "posts";
"Scene.FollowedTags.Header.PostsToday" = "posts today";
"Scene.FollowedTags.Title" = "Followed Tags";
"Scene.Follower.Footer" = "Followers from other servers are not displayed.";
"Scene.Follower.Title" = "follower";
"Scene.Following.Footer" = "Follows from other servers are not displayed.";

View File

@ -0,0 +1,73 @@
//
// Mastodon+API+Account+FollowedTags.swift
//
//
// Created by Marcus Kida on 22.11.22.
//
import Foundation
import Combine
extension Mastodon.API.Account {
static func followedTagsEndpointURL(domain: String) -> URL {
return Mastodon.API.endpointURL(domain: domain)
.appendingPathComponent("followed_tags")
}
/// Followed Tags
///
/// View your followed hashtags.
///
/// - Since: 4.0.0
/// - Version: 4.0.3
/// # Reference
/// [Document](https://docs.joinmastodon.org/methods/followed_tags/)
/// - Parameters:
/// - session: `URLSession`
/// - domain: Mastodon instance domain. e.g. "example.com"
/// - authorization: User token
/// - Returns: `AnyPublisher` contains `[Tag]` nested in the response
public static func followedTags(
session: URLSession,
domain: String,
query: FollowedTagsQuery,
authorization: Mastodon.API.OAuth.Authorization
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Tag]>, Error> {
let request = Mastodon.API.get(
url: followedTagsEndpointURL(domain: domain),
query: query,
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Tag].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
}
public struct FollowedTagsQuery: Codable, GetQuery {
public let limit: Int? // default 100
enum CodingKeys: String, CodingKey {
case limit
}
public init(
limit: Int?
) {
self.limit = limit
}
var queryItems: [URLQueryItem]? {
var items: [URLQueryItem] = []
limit.flatMap { items.append(URLQueryItem(name: "limit", value: String($0))) }
guard !items.isEmpty else { return nil }
return items
}
}
}

View File

@ -215,6 +215,70 @@ extension Mastodon.API.Account {
}
public extension Mastodon.API.Account {
static func blocksEndpointURL(domain: String) -> URL {
return Mastodon.API.endpointURL(domain: domain).appendingPathComponent("blocks")
}
/// Block
///
/// Block the given account. Clients should filter statuses from this account if received (e.g. due to a boost in the Home timeline).
///
/// - Since: 0.0.0
/// - Version: 3.3.0
/// # Last Update
/// 2021/4/1
/// # Reference
/// [Document](https://docs.joinmastodon.org/methods/blocks/)
/// - Parameters:
/// - session: `URLSession`
/// - domain: Mastodon instance domain. e.g. "example.com"
/// - authorization: User token.
/// - Returns: `AnyPublisher` contains `Relationship` nested in the response
static func blocks(
session: URLSession,
domain: String,
sinceID: Mastodon.Entity.Status.ID?,
limit: Int?,
authorization: Mastodon.API.OAuth.Authorization
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> {
let request = Mastodon.API.get(
url: blocksEndpointURL(domain: domain),
query: BlocksQuery(sinceID: sinceID, limit: limit),
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Account].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
}
private struct BlocksQuery: GetQuery {
private let sinceID: Mastodon.Entity.Status.ID?
private let limit: Int?
public init(
sinceID: Mastodon.Entity.Status.ID?,
limit: Int?
) {
self.sinceID = sinceID
self.limit = limit
}
var queryItems: [URLQueryItem]? {
var items: [URLQueryItem] = []
sinceID.flatMap { items.append(URLQueryItem(name: "since_id", value: $0)) }
limit.flatMap { items.append(URLQueryItem(name: "limit", value: String($0))) }
guard !items.isEmpty else { return nil }
return items
}
}
}
extension Mastodon.API.Account {
static func blockEndpointURL(domain: String, accountID: Mastodon.Entity.Account.ID) -> URL {
@ -414,3 +478,70 @@ extension Mastodon.API.Account {
}
}
extension Mastodon.API.Account {
static func mutesEndpointURL(
domain: String
) -> URL {
return Mastodon.API.endpointURL(domain: domain)
.appendingPathComponent("mutes")
}
/// View all mutes
///
/// View your mutes. See also accounts/:id/{mute,unmute}.
///
/// - Since: 0.0.0
/// - Version: 3.3.0
/// # Last Update
/// 2021/4/1
/// # Reference
/// [Document](https://docs.joinmastodon.org/methods/accounts/)
/// - Parameters:
/// - session: `URLSession`
/// - domain: Mastodon instance domain. e.g. "example.com"
/// - accountID: id for account
/// - authorization: User token.
/// - Returns: `AnyPublisher` contains `Relationship` nested in the response
public static func mutes(
session: URLSession,
domain: String,
sinceID: Mastodon.Entity.Status.ID? = nil,
limit: Int?,
authorization: Mastodon.API.OAuth.Authorization
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> {
let request = Mastodon.API.get(
url: mutesEndpointURL(domain: domain),
query: MutesQuery(sinceID: sinceID, limit: limit),
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: [Mastodon.Entity.Account].self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
struct MutesQuery: GetQuery {
private let sinceID: Mastodon.Entity.Status.ID?
private let limit: Int?
public init(
sinceID: Mastodon.Entity.Status.ID?,
limit: Int?
) {
self.sinceID = sinceID
self.limit = limit
}
var queryItems: [URLQueryItem]? {
var items: [URLQueryItem] = []
sinceID.flatMap { items.append(URLQueryItem(name: "since_id", value: $0)) }
limit.flatMap { items.append(URLQueryItem(name: "limit", value: String($0))) }
guard !items.isEmpty else { return nil }
return items
}
}
}
}

View File

@ -0,0 +1,117 @@
//
// Mastodin+API+Tags.swift
//
//
// Created by Marcus Kida on 23.11.22.
//
import Combine
import Foundation
extension Mastodon.API.Tags {
static func tagsEndpointURL(domain: String) -> URL {
return Mastodon.API.endpointURL(domain: domain)
.appendingPathComponent("tags")
}
/// Tags
///
/// View information about a single tag.
///
/// - Since: 4.0.0
/// - Version: 4.0.3
/// # Reference
/// [Document](https://docs.joinmastodon.org/methods/tags/)
/// - Parameters:
/// - session: `URLSession`
/// - domain: Mastodon instance domain. e.g. "example.com"
/// - authorization: User token
/// - tagId: The Hashtag
/// - Returns: `AnyPublisher` contains `Tag` nested in the response
public static func getTagInformation(
session: URLSession,
domain: String,
tagId: String,
authorization: Mastodon.API.OAuth.Authorization
) -> AnyPublisher<Mastodon.Response.Content<Mastodon.Entity.Tag>, Error> {
let request = Mastodon.API.get(
url: tagsEndpointURL(domain: domain).appendingPathComponent(tagId),
query: nil,
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: Mastodon.Entity.Tag.self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
}
/// Tags
///
/// Follow a hashtag.
///
/// - Since: 4.0.0
/// - Version: 4.0.3
/// # Reference
/// [Document](https://docs.joinmastodon.org/methods/tags/)
/// - Parameters:
/// - session: `URLSession`
/// - domain: Mastodon instance domain. e.g. "example.com"
/// - authorization: User token
/// - tagId: The Hashtag
/// - Returns: `AnyPublisher` contains `Tag` nested in the response
public static func followTag(
session: URLSession,
domain: String,
tagId: String,
authorization: Mastodon.API.OAuth.Authorization
) -> AnyPublisher<Mastodon.Response.Content<Mastodon.Entity.Tag>, Error> {
let request = Mastodon.API.post(
url: tagsEndpointURL(domain: domain).appendingPathComponent(tagId)
.appendingPathComponent("follow"),
query: nil,
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: Mastodon.Entity.Tag.self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
}
/// Tags
///
/// Unfollow a hashtag.
///
/// - Since: 4.0.0
/// - Version: 4.0.3
/// # Reference
/// [Document](https://docs.joinmastodon.org/methods/tags/)
/// - Parameters:
/// - session: `URLSession`
/// - domain: Mastodon instance domain. e.g. "example.com"
/// - authorization: User token
/// - tagId: The Hashtag
/// - Returns: `AnyPublisher` contains `Tag` nested in the response
public static func unfollowTag(
session: URLSession,
domain: String,
tagId: String,
authorization: Mastodon.API.OAuth.Authorization
) -> AnyPublisher<Mastodon.Response.Content<Mastodon.Entity.Tag>, Error> {
let request = Mastodon.API.post(
url: tagsEndpointURL(domain: domain).appendingPathComponent(tagId)
.appendingPathComponent("unfollow"),
query: nil,
authorization: authorization
)
return session.dataTaskPublisher(for: request)
.tryMap { data, response in
let value = try Mastodon.API.decode(type: Mastodon.Entity.Tag.self, from: data, response: response)
return Mastodon.Response.Content(value: value, response: response)
}
.eraseToAnyPublisher()
}
}

View File

@ -112,6 +112,7 @@ extension Mastodon.API {
public enum Polls { }
public enum Reblog { }
public enum Statuses { }
public enum Tags {}
public enum Timeline { }
public enum Trends { }
public enum Suggestions { }

View File

@ -11,9 +11,9 @@ extension Mastodon.Entity {
/// Tag
///
/// - Since: 0.9.0
/// - Version: 3.3.0
/// - Version: 4.0.0
/// # Last Update
/// 2021/1/28
/// 2022/11/22
/// # Reference
/// [Document](https://docs.joinmastodon.org/entities/tag/)
public struct Tag: Hashable, Codable {
@ -23,11 +23,13 @@ extension Mastodon.Entity {
public let url: String
public let history: [History]?
public let following: Bool?
enum CodingKeys: String, CodingKey {
case name
case url
case history
case following
}
public static func == (lhs: Mastodon.Entity.Tag, rhs: Mastodon.Entity.Tag) -> Bool {
@ -39,5 +41,9 @@ extension Mastodon.Entity {
hasher.combine(name)
hasher.combine(url)
}
public func copy(following: Bool?) -> Self {
Tag(name: name, url: url, history: history, following: following)
}
}
}

View File

@ -106,6 +106,7 @@ extension Mastodon.Response {
public struct Link {
public let maxID: Mastodon.Entity.Status.ID?
public let minID: Mastodon.Entity.Status.ID?
public let linkIDs: [String: Mastodon.Entity.Status.ID]
public let offset: Int?
init(link: String) {
@ -135,6 +136,33 @@ extension Mastodon.Response {
let offset = link[range]
return Int(offset)
}()
self.linkIDs = {
var linkIDs = [String: Mastodon.Entity.Status.ID]()
let links = link.components(separatedBy: ", ")
for link in links {
guard let regex = try? NSRegularExpression(pattern: "<(.*)>; *rel=\"(.*)\"") else { return [:] }
let results = regex.matches(in: link, options: [], range: NSRange(link.startIndex..<link.endIndex, in: link))
for match in results {
guard
let labelRange = Range(match.range(at: 2), in: link),
let linkRange = Range(match.range(at: 1), in: link)
else {
continue
}
linkIDs[String(link[labelRange])] = String(link[linkRange])
}
}
return linkIDs
}()
}
}
}
public extension Mastodon.Entity.Status.ID {
static let linkPrev = "prev"
static let linkNext = "next"
var sinceId: String? {
components(separatedBy: "&since_id=").last
}
}

View File

@ -30,6 +30,7 @@ public struct AttachmentView: View {
Image(uiImage: image)
.resizable()
.aspectRatio(contentMode: .fill)
.allowsHitTesting(false)
}
)
.overlay(

View File

@ -13,17 +13,21 @@ extension MetaTextView {
public override func paste(_ sender: Any?) {
super.paste(sender)
var nextResponder = self.next;
// Force the event to bubble through ALL responders
// This is a workaround as somewhere down the chain the paste event gets eaten
while (nextResponder != nil) {
if let nextResponder = nextResponder {
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
// fix #660
// https://github.com/mastodon/mastodon-ios/issues/660
if #available(iOS 15.0, *) {
var nextResponder = self.next;
// Force the event to bubble through ALL responders
// This is a workaround as somewhere down the chain the paste event gets eaten
while (nextResponder != nil) {
if let nextResponder = nextResponder {
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
}
}
nextResponder = nextResponder?.next;
}
nextResponder = nextResponder?.next;
}
} // end if
}
}

View File

@ -462,7 +462,7 @@ extension StatusView.ViewModel {
pollCountdownDescription
)
.sink { pollVoteDescription, pollCountdownDescription in
statusView.pollVoteCountLabel.text = pollVoteDescription ?? "-"
statusView.pollVoteCountLabel.text = pollVoteDescription
statusView.pollCountdownLabel.text = pollCountdownDescription ?? "-"
}
.store(in: &disposeBag)

View File

@ -105,7 +105,7 @@ extension ActionToolbarContainer {
shareButton.setImage(ActionToolbarContainer.shareImage, for: .normal)
container.axis = .horizontal
container.distribution = .fill
container.distribution = .equalSpacing
replyButton.translatesAutoresizingMaskIntoConstraints = false
reblogButton.translatesAutoresizingMaskIntoConstraints = false

View File

@ -21,7 +21,7 @@ final class ShareViewController: UIViewController {
var disposeBag = Set<AnyCancellable>()
let context = AppContext()
let context = AppContext.shared
private(set) lazy var viewModel = ShareViewModel(context: context)
let publishButton: UIButton = {
@ -63,6 +63,10 @@ final class ShareViewController: UIViewController {
label.text = "No Available Account" // TODO: i18n
return label
}()
deinit {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
}
}
@ -156,7 +160,7 @@ extension ShareViewController {
_ = try await statusPublisher.publish(api: context.apiService, authContext: authContext)
self.publishButton.setTitle(L10n.Common.Controls.Actions.done, for: .normal)
try await Task.sleep(nanoseconds: 1 * .second)
try await Task.sleep(nanoseconds: 1 * .second)
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
@ -326,3 +330,7 @@ extension ShareViewController {
case missingAuthentication
}
}
extension AppContext {
static let shared = AppContext()
}