Compare commits
No commits in common. "e0d97cd2a8b2e6950a4552461575456ef630b184" and "1f37a5e7ebd98d3391f2f7809263e10ab91b93a0" have entirely different histories.
e0d97cd2a8
...
1f37a5e7eb
|
@ -298,9 +298,9 @@ public class Client {
|
|||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
public static func getNotifications(allowedTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
|
||||
public static func getNotifications(excludeTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
|
||||
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters:
|
||||
"types" => allowedTypes.map { $0.rawValue }
|
||||
"exclude_types" => excludeTypes.map { $0.rawValue }
|
||||
)
|
||||
request.range = range
|
||||
return request
|
||||
|
|
|
@ -45,12 +45,9 @@ class Filterer {
|
|||
var htmlConverter = HTMLConverter()
|
||||
private var hasSetup = false
|
||||
private var matchers = [(NSRegularExpression, Result)]()
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private var allFiltersObserver: AnyCancellable?
|
||||
private var filterObservers = Set<AnyCancellable>()
|
||||
|
||||
private var hideReblogsInTimelines: Bool
|
||||
private var hideRepliesInTimelines: Bool
|
||||
|
||||
// the generation is incremented when the matchers change, to indicate that older cached FilterStates
|
||||
// are no longer valid, without needing to go through and update each of them
|
||||
private var generation = 0
|
||||
|
@ -58,37 +55,13 @@ class Filterer {
|
|||
init(mastodonController: MastodonController, context: FilterV1.Context) {
|
||||
self.mastodonController = mastodonController
|
||||
self.context = context
|
||||
self.hideReblogsInTimelines = Preferences.shared.hideReblogsInTimelines
|
||||
self.hideRepliesInTimelines = Preferences.shared.hideRepliesInTimelines
|
||||
|
||||
mastodonController.$filters
|
||||
allFiltersObserver = mastodonController.$filters
|
||||
.sink { [unowned self] in
|
||||
if self.hasSetup {
|
||||
self.setupFilters(filters: $0)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
if context == .home {
|
||||
Preferences.shared.$hideReblogsInTimelines
|
||||
.sink { [unowned self] newValue in
|
||||
if newValue != hideReblogsInTimelines {
|
||||
self.hideReblogsInTimelines = newValue
|
||||
self.generation += 1
|
||||
self.filtersChanged?(true)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
Preferences.shared.$hideRepliesInTimelines
|
||||
.sink { [unowned self] newValue in
|
||||
if newValue != hideRepliesInTimelines {
|
||||
self.hideRepliesInTimelines = newValue
|
||||
self.generation += 1
|
||||
self.filtersChanged?(true)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
private func setupFilters(filters: [FilterMO]) {
|
||||
|
@ -113,7 +86,7 @@ class Filterer {
|
|||
}
|
||||
|
||||
if hasSetup {
|
||||
var allMatch: Bool = true
|
||||
var allMatch: Bool = false
|
||||
var actionsChanged: Bool = false
|
||||
if matchers.count != oldMatchers.count {
|
||||
allMatch = false
|
||||
|
@ -141,13 +114,12 @@ class Filterer {
|
|||
}
|
||||
|
||||
// Use a closure for the status in case the result is cached and we don't need to look it up
|
||||
func resolve(state: FilterState, status: () -> (StatusMO, Bool)) -> (Filterer.Result, NSAttributedString?) {
|
||||
func resolve(state: FilterState, status: () -> StatusMO) -> (Filterer.Result, NSAttributedString?) {
|
||||
switch state.state {
|
||||
case .known(_, generation: let knownGen) where knownGen < generation:
|
||||
fallthrough
|
||||
case .unknown:
|
||||
let (status, isReblog) = status()
|
||||
let (result, attributedString) = doResolve(status: status, isReblog: isReblog)
|
||||
let (result, attributedString) = doResolve(status: status())
|
||||
state.state = .known(result, generation: generation)
|
||||
return (result, attributedString)
|
||||
case .known(let result, _):
|
||||
|
@ -168,19 +140,10 @@ class Filterer {
|
|||
}
|
||||
}
|
||||
|
||||
private func doResolve(status: StatusMO, isReblog: Bool) -> (Result, NSAttributedString?) {
|
||||
private func doResolve(status: StatusMO) -> (Result, NSAttributedString?) {
|
||||
if !hasSetup {
|
||||
setupFilters(filters: mastodonController.filters)
|
||||
}
|
||||
if context == .home {
|
||||
if hideReblogsInTimelines,
|
||||
isReblog {
|
||||
return (.hide, nil)
|
||||
} else if hideRepliesInTimelines,
|
||||
status.inReplyToID != nil {
|
||||
return (.hide, nil)
|
||||
}
|
||||
}
|
||||
if matchers.isEmpty {
|
||||
return (.allow, nil)
|
||||
}
|
||||
|
|
|
@ -70,8 +70,6 @@ class Preferences: Codable, ObservableObject {
|
|||
self.oppositeCollapseKeywords = try container.decodeIfPresent([String].self, forKey: .oppositeCollapseKeywords) ?? []
|
||||
self.confirmBeforeReblog = try container.decodeIfPresent(Bool.self, forKey: .confirmBeforeReblog) ?? false
|
||||
self.timelineStateRestoration = try container.decodeIfPresent(Bool.self, forKey: .timelineStateRestoration) ?? true
|
||||
self.hideReblogsInTimelines = try container.decodeIfPresent(Bool.self, forKey: .hideReblogsInTimelines) ?? false
|
||||
self.hideRepliesInTimelines = try container.decodeIfPresent(Bool.self, forKey: .hideRepliesInTimelines) ?? false
|
||||
|
||||
self.showFavoriteAndReblogCounts = try container.decode(Bool.self, forKey: .showFavoriteAndReblogCounts)
|
||||
self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType)
|
||||
|
@ -117,8 +115,6 @@ class Preferences: Codable, ObservableObject {
|
|||
try container.encode(oppositeCollapseKeywords, forKey: .oppositeCollapseKeywords)
|
||||
try container.encode(confirmBeforeReblog, forKey: .confirmBeforeReblog)
|
||||
try container.encode(timelineStateRestoration, forKey: .timelineStateRestoration)
|
||||
try container.encode(hideReblogsInTimelines, forKey: .hideReblogsInTimelines)
|
||||
try container.encode(hideRepliesInTimelines, forKey: .hideRepliesInTimelines)
|
||||
|
||||
try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts)
|
||||
try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType)
|
||||
|
@ -173,8 +169,6 @@ class Preferences: Codable, ObservableObject {
|
|||
@Published var oppositeCollapseKeywords: [String] = []
|
||||
@Published var confirmBeforeReblog = false
|
||||
@Published var timelineStateRestoration = true
|
||||
@Published var hideReblogsInTimelines = false
|
||||
@Published var hideRepliesInTimelines = false
|
||||
|
||||
// MARK: Digital Wellness
|
||||
@Published var showFavoriteAndReblogCounts = true
|
||||
|
@ -222,8 +216,6 @@ class Preferences: Codable, ObservableObject {
|
|||
case oppositeCollapseKeywords
|
||||
case confirmBeforeReblog
|
||||
case timelineStateRestoration
|
||||
case hideReblogsInTimelines
|
||||
case hideRepliesInTimelines
|
||||
|
||||
case showFavoriteAndReblogCounts
|
||||
case defaultNotificationsType
|
||||
|
|
|
@ -74,8 +74,6 @@ protocol StatusSwipeActionContainer: UIView {
|
|||
var navigationDelegate: any TuskerNavigationDelegate { get }
|
||||
var toastableViewController: ToastableViewController? { get }
|
||||
|
||||
var canReblog: Bool { get }
|
||||
|
||||
// necessary b/c the reblog-handling logic only exists in the cells
|
||||
func performReplyAction()
|
||||
}
|
||||
|
@ -110,8 +108,7 @@ private func createFavoriteAction(status: StatusMO, container: StatusSwipeAction
|
|||
}
|
||||
|
||||
private func createReblogAction(status: StatusMO, container: StatusSwipeActionContainer) -> UIContextualAction? {
|
||||
guard container.mastodonController.loggedIn,
|
||||
container.canReblog else {
|
||||
guard container.mastodonController.loggedIn else {
|
||||
return nil
|
||||
}
|
||||
let title = status.reblogged ? "Unreblog" : "Reblog"
|
||||
|
|
|
@ -125,7 +125,7 @@ class ConversationTableViewController: EnhancedTableViewController {
|
|||
})
|
||||
|
||||
visibilityBarButtonItem = UIBarButtonItem(image: ConversationTableViewController.showPostsImage, style: .plain, target: self, action: #selector(toggleVisibilityButtonPressed))
|
||||
updateVisibilityBarButtonItem()
|
||||
visibilityBarButtonItem.isSelected = showStatusesAutomatically
|
||||
navigationItem.rightBarButtonItem = visibilityBarButtonItem
|
||||
// disable transparent background when scroll to top because it looks weird when items earlier in the thread load in
|
||||
// (it remains transparent slightly too long, resulting in a flash of the content under the transparent bar)
|
||||
|
@ -138,11 +138,6 @@ class ConversationTableViewController: EnhancedTableViewController {
|
|||
}
|
||||
}
|
||||
|
||||
private func updateVisibilityBarButtonItem() {
|
||||
visibilityBarButtonItem.isSelected = showStatusesAutomatically
|
||||
visibilityBarButtonItem.accessibilityLabel = showStatusesAutomatically ? "Collapse All" : "Expand All"
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadMainStatus() async {
|
||||
guard loadingState == .unloaded else { return }
|
||||
|
@ -396,7 +391,7 @@ class ConversationTableViewController: EnhancedTableViewController {
|
|||
tableView.beginUpdates()
|
||||
tableView.endUpdates()
|
||||
|
||||
updateVisibilityBarButtonItem()
|
||||
visibilityBarButtonItem.isSelected = showStatusesAutomatically
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class TrendingStatusesViewController: UIViewController {
|
|||
return UICollectionViewDiffableDataSource(collectionView: collectionView) { [unowned self] collectionView, indexPath, itemIdentifier in
|
||||
switch itemIdentifier {
|
||||
case .status(id: let id, let collapseState, let filterState):
|
||||
let (result, attributedString) = self.filterer.resolve(state: filterState, status: { (mastodonController.persistentContainer.status(for: id)!, false) })
|
||||
let (result, attributedString) = self.filterer.resolve(state: filterState, status: { mastodonController.persistentContainer.status(for: id)! })
|
||||
switch result {
|
||||
case .allow, .warn(_):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, collapseState, result, attributedString))
|
||||
|
|
|
@ -22,7 +22,6 @@ struct FiltersView: View {
|
|||
|
||||
struct FiltersList: View {
|
||||
@EnvironmentObject private var mastodonController: MastodonController
|
||||
@ObservedObject private var preferences = Preferences.shared
|
||||
@FetchRequest(sortDescriptors: []) private var filters: FetchedResults<FilterMO>
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var deletionError: (any Error)?
|
||||
|
@ -50,17 +49,6 @@ struct FiltersList: View {
|
|||
|
||||
private var navigationBody: some View {
|
||||
List {
|
||||
Section {
|
||||
Toggle(isOn: $preferences.hideReblogsInTimelines) {
|
||||
Text("Hide Reblogs")
|
||||
}
|
||||
Toggle(isOn: $preferences.hideRepliesInTimelines) {
|
||||
Text("Hide Replies")
|
||||
}
|
||||
} header: {
|
||||
Text("Home Timeline")
|
||||
}
|
||||
|
||||
Section {
|
||||
NavigationLink {
|
||||
EditFilterView(filter: EditedFilter(), create: true, originallyExpired: false)
|
||||
|
|
|
@ -20,7 +20,7 @@ class LargeImageInteractionController: UIPercentDrivenInteractiveTransition {
|
|||
super.init()
|
||||
self.viewController = viewController
|
||||
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handleGesture(_:)))
|
||||
panRecognizer.allowedScrollTypesMask = .continuous
|
||||
panRecognizer.allowedScrollTypesMask = .all
|
||||
viewController.view.addGestureRecognizer(panRecognizer)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
|||
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
private let allowedTypes: [Pachyderm.Notification.Kind]
|
||||
private let excludedTypes: [Pachyderm.Notification.Kind]
|
||||
private let groupTypes = [Pachyderm.Notification.Kind.favourite, .reblog, .follow]
|
||||
|
||||
private var newer: RequestRange?
|
||||
private var older: RequestRange?
|
||||
|
||||
init(allowedTypes: [Pachyderm.Notification.Kind], mastodonController: MastodonController) {
|
||||
self.allowedTypes = allowedTypes
|
||||
self.excludedTypes = Array(Set(Pachyderm.Notification.Kind.allCases).subtracting(allowedTypes))
|
||||
self.mastodonController = mastodonController
|
||||
|
||||
super.init()
|
||||
|
@ -140,7 +140,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
|||
}
|
||||
|
||||
override func loadInitialItems(completion: @escaping (LoadResult) -> Void) {
|
||||
let request = Client.getNotifications(allowedTypes: allowedTypes)
|
||||
let request = Client.getNotifications(excludeTypes: excludedTypes)
|
||||
mastodonController.run(request) { (response) in
|
||||
switch response {
|
||||
case let .failure(error):
|
||||
|
@ -171,7 +171,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
|||
return
|
||||
}
|
||||
|
||||
let request = Client.getNotifications(allowedTypes: allowedTypes, range: older)
|
||||
let request = Client.getNotifications(excludeTypes: excludedTypes, range: older)
|
||||
mastodonController.run(request) { (response) in
|
||||
switch response {
|
||||
case let .failure(error):
|
||||
|
@ -203,7 +203,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
|||
return
|
||||
}
|
||||
|
||||
let request = Client.getNotifications(allowedTypes: allowedTypes, range: newer)
|
||||
let request = Client.getNotifications(excludeTypes: excludedTypes, range: newer)
|
||||
mastodonController.run(request) { (response) in
|
||||
switch response {
|
||||
case let .failure(error):
|
||||
|
|
|
@ -35,12 +35,6 @@ struct BehaviorPrefsView: View {
|
|||
Toggle(isOn: $preferences.timelineStateRestoration) {
|
||||
Text("Maintain Position Across App Launches")
|
||||
}
|
||||
Toggle(isOn: $preferences.hideReblogsInTimelines) {
|
||||
Text("Hide Reblogs")
|
||||
}
|
||||
Toggle(isOn: $preferences.hideRepliesInTimelines) {
|
||||
Text("Hide Replies")
|
||||
}
|
||||
} header: {
|
||||
Text("Timeline")
|
||||
}
|
||||
|
|
|
@ -261,11 +261,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
let status = {
|
||||
let status = self.mastodonController.persistentContainer.status(for: statusID)!
|
||||
// if the status is a reblog of another one, filter based on that one
|
||||
if let reblogged = status.reblog {
|
||||
return (reblogged, true)
|
||||
} else {
|
||||
return (status, false)
|
||||
}
|
||||
return status.reblog ?? status
|
||||
}
|
||||
return filterer.resolve(state: state, status: status)
|
||||
}
|
||||
|
|
|
@ -354,11 +354,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
let status = {
|
||||
let status = self.mastodonController.persistentContainer.status(for: statusID)!
|
||||
// if the status is a reblog of another one, filter based on that one
|
||||
if let reblogged = status.reblog {
|
||||
return (reblogged, true)
|
||||
} else {
|
||||
return (status, false)
|
||||
}
|
||||
return status.reblog ?? status
|
||||
}
|
||||
return filterer.resolve(state: state, status: status)
|
||||
}
|
||||
|
|
|
@ -214,9 +214,7 @@ extension ContentTextView: UITextViewDelegate {
|
|||
} else {
|
||||
// otherwise, regular taps are handled by the gesture recognizer, but the accessibility interaction to select links with the rotor goes through here
|
||||
// and this seems to be the only way of overriding what it does
|
||||
if interaction == .invokeDefaultAction {
|
||||
handleLinkTapped(url: URL, text: (text as NSString).substring(with: characterRange))
|
||||
}
|
||||
handleLinkTapped(url: URL, text: (text as NSString).substring(with: characterRange))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -822,10 +822,6 @@ extension TimelineStatusCollectionViewCell: StatusSwipeActionContainer {
|
|||
var navigationDelegate: TuskerNavigationDelegate { delegate! }
|
||||
var toastableViewController: ToastableViewController? { delegate }
|
||||
|
||||
var canReblog: Bool {
|
||||
reblogButton.isEnabled
|
||||
}
|
||||
|
||||
func performReplyAction() {
|
||||
self.replyPressed()
|
||||
}
|
||||
|
|
|
@ -445,10 +445,6 @@ extension TimelineStatusTableViewCell: StatusSwipeActionContainer {
|
|||
var navigationDelegate: TuskerNavigationDelegate { delegate! }
|
||||
var toastableViewController: ToastableViewController? { delegate }
|
||||
|
||||
var canReblog: Bool {
|
||||
reblogButton.isEnabled
|
||||
}
|
||||
|
||||
func performReplyAction() {
|
||||
self.replyPressed()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue