attempt to mitigate line length warnings
This commit is contained in:
@ -44,7 +44,12 @@ import Views
|
||||
let fetchRequest: NSFetchRequest<Models.RecentSearchItem> = RecentSearchItem.fetchRequest()
|
||||
fetchRequest.predicate = NSPredicate(format: "term == %@", searchTerm)
|
||||
|
||||
let item = ((try? dataService.viewContext.fetch(fetchRequest))?.first) ?? RecentSearchItem(context: dataService.viewContext)
|
||||
let item: RecentSearchItem
|
||||
if let fetchedItem = (try? dataService.viewContext.fetch(fetchRequest))?.first {
|
||||
item = fetchedItem
|
||||
} else {
|
||||
item = RecentSearchItem(context: dataService.viewContext)
|
||||
}
|
||||
item.term = searchTerm
|
||||
item.savedAt = Date()
|
||||
|
||||
|
||||
@ -69,7 +69,9 @@ struct SelfHostSettingsView: View {
|
||||
Alert(
|
||||
title: Text("Changing your environment settings will close the app."),
|
||||
dismissButton: .cancel(Text(LocalText.genericOk)) {
|
||||
AppEnvironment.setCustom(serverBaseURL: apiServerAddress, webAppBaseURL: webServerAddress, ttsBaseURL: ttsServerAddress)
|
||||
AppEnvironment.setCustom(serverBaseURL: apiServerAddress,
|
||||
webAppBaseURL: webServerAddress,
|
||||
ttsBaseURL: ttsServerAddress)
|
||||
dataService.switchAppEnvironment(appEnvironment: AppEnvironment.custom)
|
||||
}
|
||||
)
|
||||
|
||||
@ -58,7 +58,10 @@ public extension AppEnvironment {
|
||||
case .test, .local:
|
||||
return URL(string: "http://localhost:4000")!
|
||||
case .custom:
|
||||
guard let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue), let url = URL(string: str) else {
|
||||
guard
|
||||
let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue),
|
||||
let url = URL(string: str)
|
||||
else {
|
||||
fatalError("custom serverBaseURL not set")
|
||||
}
|
||||
return url
|
||||
@ -74,7 +77,10 @@ public extension AppEnvironment {
|
||||
case .test, .local:
|
||||
return URL(string: "http://localhost:3000")!
|
||||
case .custom:
|
||||
guard let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue), let url = URL(string: str) else {
|
||||
guard
|
||||
let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue),
|
||||
let url = URL(string: str)
|
||||
else {
|
||||
fatalError("custom webAppBaseURL not set")
|
||||
}
|
||||
return url
|
||||
@ -90,7 +96,10 @@ public extension AppEnvironment {
|
||||
case .test, .local:
|
||||
return URL(string: "http://localhost:4000")!
|
||||
case .custom:
|
||||
guard let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue), let url = URL(string: str) else {
|
||||
guard
|
||||
let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue),
|
||||
let url = URL(string: str)
|
||||
else {
|
||||
fatalError("custom ttsBaseURL not set")
|
||||
}
|
||||
return url
|
||||
|
||||
@ -156,7 +156,9 @@ public extension LinkedItem {
|
||||
"recommendedAt": recommendedAt == nil ? nil : NSString(string: recommendedAt!)
|
||||
]
|
||||
}
|
||||
guard let JSON = (try? JSONSerialization.data(withJSONObject: recommendations, options: .prettyPrinted)) else { return "[]" }
|
||||
guard let JSON = try? JSONSerialization.data(withJSONObject: recommendations, options: .prettyPrinted) else {
|
||||
return "[]"
|
||||
}
|
||||
return String(data: JSON, encoding: .utf8) ?? "[]"
|
||||
}
|
||||
|
||||
|
||||
@ -29,9 +29,9 @@ public final class DataService: ObservableObject {
|
||||
persistentContainer.viewContext
|
||||
}
|
||||
|
||||
@AppStorage(UserDefaultKey.lastItemSyncTime.rawValue) public var lastItemSyncTime = DateFormatter.formatterISO8601.string(
|
||||
from: Date(timeIntervalSinceReferenceDate: 0)
|
||||
)
|
||||
@AppStorage(UserDefaultKey.lastItemSyncTime.rawValue) public var lastItemSyncTime: String = {
|
||||
DateFormatter.formatterISO8601.string(from: Date(timeIntervalSinceReferenceDate: 0))
|
||||
}()
|
||||
|
||||
public init(appEnvironment: AppEnvironment, networker: Networker) {
|
||||
self.appEnvironment = appEnvironment
|
||||
|
||||
@ -22,7 +22,9 @@ public extension DataService {
|
||||
case error(errorCode: Enums.OptInFeatureErrorCode)
|
||||
}
|
||||
|
||||
let featureSelection = Selection.Feature { Feature(name: try $0.name(), token: try $0.token(), granted: try $0.grantedAt() != nil) }
|
||||
let featureSelection = Selection.Feature {
|
||||
Feature(name: try $0.name(), token: try $0.token(), granted: try $0.grantedAt() != nil)
|
||||
}
|
||||
let selection = Selection<MutationResult, Unions.OptInFeatureResult> {
|
||||
try $0.on(
|
||||
optInFeatureError: .init { .error(errorCode: try $0.errorCodes().first ?? .badRequest) },
|
||||
|
||||
@ -21,7 +21,10 @@ public extension DataService {
|
||||
|
||||
let mutation = Selection.Mutation {
|
||||
try $0.recommend(
|
||||
input: .init(groupIds: groupIDs, note: OptionalArgument(note), pageId: pageID, recommendedWithHighlights: OptionalArgument(withHighlights)),
|
||||
input: .init(groupIds: groupIDs,
|
||||
note: OptionalArgument(note),
|
||||
pageId: pageID,
|
||||
recommendedWithHighlights: OptionalArgument(withHighlights)),
|
||||
selection: selection
|
||||
)
|
||||
}
|
||||
|
||||
@ -48,7 +48,10 @@ extension DataService {
|
||||
|
||||
let mutation = Selection.Mutation {
|
||||
try $0.updatePage(
|
||||
input: .init(byline: OptionalArgument(author), description: OptionalArgument(description), pageId: itemID, title: OptionalArgument(title)),
|
||||
input: .init(byline: OptionalArgument(author),
|
||||
description: OptionalArgument(description),
|
||||
pageId: itemID,
|
||||
title: OptionalArgument(title)),
|
||||
selection: selection
|
||||
)
|
||||
}
|
||||
|
||||
@ -68,7 +68,8 @@ extension DataService {
|
||||
)
|
||||
}
|
||||
|
||||
let sort = InputObjects.SortParams(by: Enums.SortBy.updatedTime, order: OptionalArgument(descending ? Enums.SortOrder.descending : Enums.SortOrder.ascending))
|
||||
let sort = InputObjects.SortParams(by: .updatedTime,
|
||||
order: OptionalArgument(descending ? .descending : .ascending))
|
||||
|
||||
let query = Selection.Query {
|
||||
try $0.updatesSince(
|
||||
|
||||
@ -353,13 +353,18 @@ public final class OmnivoreWebView: WKWebView {
|
||||
override public func buildMenu(with builder: UIMenuBuilder) {
|
||||
if #available(iOS 16.0, *) {
|
||||
let annotate = UICommand(title: "Note", action: #selector(annotateSelection))
|
||||
let highlight = UICommand(title: LocalText.genericHighlight, action: #selector(highlightSelection))
|
||||
let remove = UICommand(title: "Remove", action: #selector(removeSelection))
|
||||
let setLabels = UICommand(title: LocalText.labelsGeneric, action: #selector(setLabels))
|
||||
|
||||
let omnivore = UIMenu(title: "",
|
||||
options: .displayInline,
|
||||
children: currentMenu == .defaultMenu ? [highlight, annotate] : [annotate, setLabels, remove])
|
||||
let items: [UIMenuElement]
|
||||
if currentMenu == .defaultMenu {
|
||||
let highlight = UICommand(title: LocalText.genericHighlight, action: #selector(highlightSelection))
|
||||
items = [highlight, annotate]
|
||||
} else {
|
||||
let remove = UICommand(title: "Remove", action: #selector(removeSelection))
|
||||
let setLabels = UICommand(title: LocalText.labelsGeneric, action: #selector(setLabels))
|
||||
items = [annotate, setLabels, remove]
|
||||
}
|
||||
|
||||
let omnivore = UIMenu(title: "", options: .displayInline, children: items)
|
||||
builder.insertSibling(omnivore, beforeMenu: .lookup)
|
||||
}
|
||||
|
||||
|
||||
@ -101,8 +101,9 @@ public struct CommunityModal: View {
|
||||
VStack(spacing: 0) {
|
||||
header
|
||||
|
||||
Text((try? AttributedString(markdown: message,
|
||||
options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace))) ?? "")
|
||||
let parsedMessage = try? AttributedString(markdown: message,
|
||||
options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace))
|
||||
Text(parsedMessage ?? "")
|
||||
.multilineTextAlignment(.leading)
|
||||
.foregroundColor(Color.appGrayTextContrast)
|
||||
.accentColor(.blue)
|
||||
|
||||
@ -33,8 +33,9 @@ public struct FeaturePrimer: View {
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
Text((try? AttributedString(markdown: message,
|
||||
options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace))) ?? "")
|
||||
let parsedMessage = try? AttributedString(markdown: message,
|
||||
options: .init(interpretedSyntax: .inlineOnlyPreservingWhitespace))
|
||||
Text(parsedMessage ?? "")
|
||||
.foregroundColor(Color.appGrayText)
|
||||
.accentColor(.blue)
|
||||
.padding(.bottom, 16)
|
||||
|
||||
Reference in New Issue
Block a user