mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge branch 'mac-release' into main
This commit is contained in:
@@ -102,6 +102,10 @@ private extension IconView {
|
||||
}
|
||||
|
||||
func rectForImageView() -> NSRect {
|
||||
guard !(iconImage?.isSymbol ?? false) else {
|
||||
return NSMakeRect(0.0, 0.0, bounds.size.width, bounds.size.height)
|
||||
}
|
||||
|
||||
guard let image = iconImage?.image else {
|
||||
return NSRect.zero
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
}
|
||||
|
||||
if item.action == #selector(nextUnread(_:)) {
|
||||
return canGoToNextUnread()
|
||||
return canGoToNextUnread(wrappingToTop: true)
|
||||
}
|
||||
|
||||
if item.action == #selector(markAllAsRead(_:)) {
|
||||
|
||||
@@ -106,7 +106,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
// When the array is the same — same articles, same order —
|
||||
// but some data in some of the articles may have changed.
|
||||
// Just reload visible cells in this case: don’t call reloadData.
|
||||
articleRowMap = [String: Int]()
|
||||
articleRowMap = [String: [Int]]()
|
||||
reloadVisibleCells()
|
||||
return
|
||||
}
|
||||
@@ -124,7 +124,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
showFeedNames = .feed
|
||||
}
|
||||
|
||||
articleRowMap = [String: Int]()
|
||||
articleRowMap = [String: [Int]]()
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
private var fetchSerialNumber = 0
|
||||
private let fetchRequestQueue = FetchRequestQueue()
|
||||
private var exceptionArticleFetcher: ArticleFetcher?
|
||||
private var articleRowMap = [String: Int]() // articleID: rowIndex
|
||||
private var articleRowMap = [String: [Int]]() // articleID: rowIndex
|
||||
private var cellAppearance: TimelineCellAppearance!
|
||||
private var cellAppearanceWithIcon: TimelineCellAppearance!
|
||||
private var showFeedNames: TimelineShowFeedName = .none {
|
||||
@@ -1057,20 +1057,25 @@ private extension TimelineViewController {
|
||||
restoreSelection(savedSelection)
|
||||
}
|
||||
|
||||
func row(for articleID: String) -> Int? {
|
||||
func rows(for articleID: String) -> [Int]? {
|
||||
updateArticleRowMapIfNeeded()
|
||||
return articleRowMap[articleID]
|
||||
}
|
||||
|
||||
func row(for article: Article) -> Int? {
|
||||
return row(for: article.articleID)
|
||||
func rows(for article: Article) -> [Int]? {
|
||||
return rows(for: article.articleID)
|
||||
}
|
||||
|
||||
func updateArticleRowMap() {
|
||||
var rowMap = [String: Int]()
|
||||
var rowMap = [String: [Int]]()
|
||||
var index = 0
|
||||
articles.forEach { (article) in
|
||||
rowMap[article.articleID] = index
|
||||
if var indexes = rowMap[article.articleID] {
|
||||
indexes.append(index)
|
||||
rowMap[article.articleID] = indexes
|
||||
} else {
|
||||
rowMap[article.articleID] = [index]
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
articleRowMap = rowMap
|
||||
@@ -1086,11 +1091,11 @@ private extension TimelineViewController {
|
||||
var indexes = IndexSet()
|
||||
|
||||
articleIDs.forEach { (articleID) in
|
||||
guard let oneIndex = row(for: articleID) else {
|
||||
guard let rowsIndex = rows(for: articleID) else {
|
||||
return
|
||||
}
|
||||
if oneIndex != NSNotFound {
|
||||
indexes.insert(oneIndex)
|
||||
for rowIndex in rowsIndex {
|
||||
indexes.insert(rowIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import SwiftUI
|
||||
import Account
|
||||
import RSCore
|
||||
|
||||
enum AddAccountSections: Int, CaseIterable {
|
||||
case local = 0
|
||||
@@ -53,11 +54,11 @@ enum AddAccountSections: Int, CaseIterable {
|
||||
case .icloud:
|
||||
return [.cloudKit]
|
||||
case .web:
|
||||
#if DEBUG
|
||||
return [.bazQux, .feedbin, .feedly, .feedWrangler, .inoreader, .newsBlur, .theOldReader]
|
||||
#else
|
||||
return [.bazQux, .feedbin, .feedly, .inoreader, .newsBlur, .theOldReader]
|
||||
#endif
|
||||
if AppDefaults.shared.isDeveloperBuild {
|
||||
return [.bazQux, .feedbin, .feedly, .inoreader, .newsBlur, .theOldReader].filter({ $0.isDeveloperRestricted == false })
|
||||
} else {
|
||||
return [.bazQux, .feedbin, .feedly, .inoreader, .newsBlur, .theOldReader]
|
||||
}
|
||||
case .selfhosted:
|
||||
return [.freshRSS]
|
||||
case .allOrdered:
|
||||
@@ -67,12 +68,17 @@ enum AddAccountSections: Int, CaseIterable {
|
||||
AddAccountSections.selfhosted.sectionContent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct AddAccountsView: View {
|
||||
|
||||
weak var parent: NSHostingController<AddAccountsView>? // required because presentationMode.dismiss() doesn't work
|
||||
var addAccountDelegate: AccountsPreferencesAddAccountDelegate?
|
||||
private let chunkLimit = 4 // use this to control number of accounts in each web account column
|
||||
@State private var selectedAccount: AccountType = .onMyMac
|
||||
|
||||
init(delegate: AccountsPreferencesAddAccountDelegate?) {
|
||||
@@ -157,7 +163,7 @@ struct AddAccountsView: View {
|
||||
account.image()
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 25, height: 25, alignment: .center)
|
||||
.frame(width: 20, height: 20, alignment: .center)
|
||||
.padding(.leading, 4)
|
||||
Text(account.localizedAccountName())
|
||||
}
|
||||
@@ -189,7 +195,7 @@ struct AddAccountsView: View {
|
||||
account.image()
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 25, height: 25, alignment: .center)
|
||||
.frame(width: 20, height: 20, alignment: .center)
|
||||
.padding(.leading, 4)
|
||||
|
||||
Text(account.localizedAccountName())
|
||||
@@ -207,6 +213,7 @@ struct AddAccountsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var webAccounts: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Web")
|
||||
@@ -214,22 +221,28 @@ struct AddAccountsView: View {
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 8)
|
||||
|
||||
Picker(selection: $selectedAccount, label: Text(""), content: {
|
||||
ForEach(AddAccountSections.web.sectionContent.filter({ isRestricted($0) != true }), id: \.self, content: { account in
|
||||
|
||||
HStack(alignment: .center) {
|
||||
account.image()
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 25, height: 25, alignment: .center)
|
||||
.padding(.leading, 4)
|
||||
|
||||
Text(account.localizedAccountName())
|
||||
HStack {
|
||||
ForEach(0..<chunkedWebAccounts().count, content: { chunk in
|
||||
VStack {
|
||||
Picker(selection: $selectedAccount, label: Text(""), content: {
|
||||
ForEach(chunkedWebAccounts()[chunk], id: \.self, content: { account in
|
||||
|
||||
HStack(alignment: .center) {
|
||||
account.image()
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 20, height: 20, alignment: .center)
|
||||
.padding(.leading, 4)
|
||||
Text(account.localizedAccountName())
|
||||
}
|
||||
.tag(account)
|
||||
|
||||
})
|
||||
})
|
||||
Spacer()
|
||||
}
|
||||
.tag(account)
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
.offset(x: 7.5, y: 0)
|
||||
|
||||
Text(AddAccountSections.web.sectionFooter).foregroundColor(.gray)
|
||||
@@ -252,7 +265,7 @@ struct AddAccountsView: View {
|
||||
account.image()
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 25, height: 25, alignment: .center)
|
||||
.frame(width: 20, height: 20, alignment: .center)
|
||||
.padding(.leading, 4)
|
||||
|
||||
Text(account.localizedAccountName())
|
||||
@@ -272,12 +285,10 @@ struct AddAccountsView: View {
|
||||
AccountManager.shared.accounts.contains(where: { $0.type == .cloudKit })
|
||||
}
|
||||
|
||||
private func isRestricted(_ accountType: AccountType) -> Bool {
|
||||
if AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
private func chunkedWebAccounts() -> [[AccountType]] {
|
||||
AddAccountSections.web.sectionContent.chunked(into: chunkLimit)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user