Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web production deployment #3961

Merged
merged 47 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7ef643f
Make digest refresh less
jacksonh May 13, 2024
9563332
Allow hiding the digest icon for users that have opted out
jacksonh May 14, 2024
2b9851c
Make digestconfig a proper type so Swift can interact with it
jacksonh May 14, 2024
c3c6083
Use DigestConfig type when setting user personalization
jacksonh May 14, 2024
bc1c48d
fix failed to get thumbnail from rss feed
sywhb Apr 19, 2024
9286174
upload and download original content from GCS
sywhb Apr 19, 2024
7a0b2f3
upload file only not exists
sywhb Apr 19, 2024
5bd157c
hash url as the key
sywhb Apr 19, 2024
3e925e0
update comment
sywhb Apr 19, 2024
e093c9e
fix comment
sywhb Apr 21, 2024
04ba629
fix rebase conflicts
sywhb Apr 22, 2024
6cfb06c
normalize file url
sywhb Apr 22, 2024
eddf920
do not store original content in db
sywhb Apr 22, 2024
8096847
fix bug
sywhb Apr 22, 2024
cce5f24
still use redis for cache
sywhb May 8, 2024
d796503
resolve rebase conflicts
sywhb May 14, 2024
dbd7b79
cont
sywhb May 14, 2024
3c24dc2
GQL requires this be an input object
jacksonh May 14, 2024
d52e40e
Linting
jacksonh May 14, 2024
a034771
Allog config of digest
jacksonh May 14, 2024
9a3474b
Revert file that shouldnt have been removed
jacksonh May 14, 2024
9dee510
fix rss
sywhb May 14, 2024
b7886b8
fix tests
sywhb May 14, 2024
bbf3de1
Transform digest config to a JSON string before setting
jacksonh May 14, 2024
2cb1b8e
Add an extra test for clearing the user personalization data
jacksonh May 15, 2024
cca7a21
fix tests
sywhb May 15, 2024
89fb625
Merge pull request #3952 from omnivore-app/fix/ios-digest-new-users
jacksonh May 15, 2024
c6bf64a
Upgrade to gpt-4o
jacksonh May 15, 2024
f217c6f
Cast digestConfig to any to serialize properly
jacksonh May 15, 2024
74bf05c
Linting
jacksonh May 15, 2024
a602cf3
add gcs bucket name to the env var
sywhb May 15, 2024
3d4242e
Merge pull request #3957 from omnivore-app/fix/api-digest-config-type
jacksonh May 15, 2024
9579660
Merge pull request #3956 from omnivore-app/fix/update-openai
jacksonh May 15, 2024
950b428
fix mock cloud storage
sywhb May 15, 2024
eff9e6c
add global hooks
sywhb May 15, 2024
58fa766
remove debugging logs
sywhb May 15, 2024
6d0edbd
Merge pull request #3839 from omnivore-app/feature/upload-original-co…
sywhb May 15, 2024
505e366
fix: add author to the chapter in digest
sywhb May 15, 2024
9f1babf
select used columns
sywhb May 15, 2024
396ada2
pre-cache thumbnail
sywhb May 15, 2024
1a973fa
make author optional
sywhb May 15, 2024
854ca08
Merge pull request #3958 from omnivore-app/fix/authro-in-chapter
sywhb May 15, 2024
8cfa24a
allow downloading/uploading readable content
sywhb May 15, 2024
9769eab
fix youtube transcript
sywhb May 16, 2024
f92c6ef
lint test file
sywhb May 16, 2024
293ed87
remove redundant response from return value
sywhb May 16, 2024
b6dba11
Merge pull request #3960 from omnivore-app/feature/readable-content-d…
sywhb May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/Omnivore/app/src/main/assets/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public struct ShareExtensionView: View {
.frame(maxWidth: .infinity)
.font(Font.system(size: 14))
.accentColor(.blue)
#if os(macos)
#if os(macOS)
.introspectTextView { textView in
textView.textContainerInset = NSSize(width: 10, height: 10)
}
Expand Down
77 changes: 58 additions & 19 deletions apple/OmnivoreKit/Sources/App/Views/AI/DigestConfigView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,41 @@ import Transmission
@MainActor
public class DigestConfigViewModel: ObservableObject {
@Published var isLoading = false
@Published var digestEnabled = false

@Published var isIneligible = false
@Published var hasOptInError = false
@Published var digest: DigestResult?
@Published var chapterInfo: [(DigestChapter, DigestChapterData)]?
@Published var presentedLibraryItem: String?
@Published var presentWebContainer = false

@AppStorage(UserDefaultKey.lastVisitedDigestId.rawValue) var lastVisitedDigestId = ""

func load(dataService: DataService) async {
func checkAlreadyOptedIn(dataService: DataService) async {
isLoading = true
if let user = try? await dataService.fetchViewer() {
digestEnabled = user.hasFeatureGranted("ai-digest")
}
isLoading = false
}

func enableDigest(dataService: DataService) async {
isLoading = true
if !dataService.digestNeedsRefresh() {
if let digest = dataService.loadStoredDigest() {
self.digest = digest
do {
if try await dataService.optInFeature(name: "ai-digest") == nil {
throw BasicError.message(messageText: "Could not opt into feature")
}
} else {
do {
if let digest = try await dataService.getLatestDigest(timeoutInterval: 10) {
self.digest = digest
}
} catch {
print("ERROR WITH DIGEST: ", error)
self.digest = nil
try await dataService.setupUserDigestConfig()
try await dataService.refreshDigest()
digestEnabled = true
} catch {
if error is IneligibleError {
isIneligible = true
} else {
hasOptInError = true
}
}

isLoading = false
}
}
Expand All @@ -41,12 +52,14 @@ public class DigestConfigViewModel: ObservableObject {
@MainActor
struct DigestConfigView: View {
@StateObject var viewModel = DigestConfigViewModel()
let homeViewModel: HomeFeedViewModel
let dataService: DataService

@Environment(\.dismiss) private var dismiss

public init(dataService: DataService) {
public init(dataService: DataService, homeViewModel: HomeFeedViewModel) {
self.dataService = dataService
self.homeViewModel = homeViewModel
}

var titleBlock: some View {
Expand All @@ -65,12 +78,31 @@ struct DigestConfigView: View {
VStack {
titleBlock
.padding(.top, 10)
itemBody
.padding(15)

if viewModel.isLoading {
HStack {
Spacer()
ProgressView()
Spacer()
}
.padding(.top, 50)
} else if viewModel.digestEnabled {
Text("You've been added to the AI Digest demo. You first issue should be ready soon.")
.padding(15)
} else if viewModel.isIneligible {
Text("To enable digest you need to have saved at least ten library items and have two active subscriptions.")
.padding(15)
} else if viewModel.hasOptInError {
Text("There was an error setting up digest for your account.")
.padding(15)
} else {
itemBody
.padding(15)
}

Spacer()
}.task {
await viewModel.load(dataService: dataService)
await viewModel.checkAlreadyOptedIn(dataService: dataService)
}
}

Expand Down Expand Up @@ -123,10 +155,17 @@ struct DigestConfigView: View {
HStack {
Spacer()

Button(action: {}, label: { Text("Hide digest") })
Button(action: {
homeViewModel.hideDigestIcon = true
dismiss()
}, label: { Text("Hide digest") })
.buttonStyle(RoundedRectButtonStyle())

Button(action: {}, label: { Text("Enable digest") })
Button(action: {
Task {
await viewModel.enableDigest(dataService: dataService)
}
}, label: { Text("Enable digest") })
.buttonStyle(RoundedRectButtonStyle(color: Color.blue, textColor: Color.white))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func formatTimeInterval(_ time: TimeInterval) -> String? {
@MainActor
public class FullScreenDigestViewModel: ObservableObject {
@Published var isLoading = false
@Published var hasError = false
@Published var digest: DigestResult?
@Published var chapterInfo: [(DigestChapter, DigestChapterData)]?
@Published var presentedLibraryItem: String?
Expand All @@ -46,6 +47,9 @@ public class FullScreenDigestViewModel: ObservableObject {
@AppStorage(UserDefaultKey.lastVisitedDigestId.rawValue) var lastVisitedDigestId = ""

func load(dataService: DataService, audioController: AudioController) async {
hasError = false
isLoading = true

if !dataService.digestNeedsRefresh() {
if let digest = dataService.loadStoredDigest() {
self.digest = digest
Expand All @@ -72,6 +76,8 @@ public class FullScreenDigestViewModel: ObservableObject {
let chapterData = self.chapterInfo?.map { $0.1 }
audioController.play(itemAudioProperties: DigestAudioItem(digest: digest, chapters: chapterData ?? []))
}
} else {
hasError = true
}

isLoading = false
Expand Down Expand Up @@ -164,6 +170,19 @@ struct FullScreenDigestView: View {
ProgressView()
Spacer()
}
} else if viewModel.hasError {
VStack {
Spacer()
Text("There was an error loading your digest.")
Button(action: {
Task {
await viewModel.load(dataService: dataService, audioController: audioController)
}
}, label: { Text("Try again") })
.buttonStyle(RoundedRectButtonStyle(color: Color.blue, textColor: Color.white))

Spacer()
}
} else {
itemBody
}
Expand Down
15 changes: 3 additions & 12 deletions apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// swiftlint:disable file_length type_body_length
import CoreData
import Models
import Services
Expand Down Expand Up @@ -334,7 +335,7 @@ struct AnimatingCellHeight: AnimatableModifier {
.sheet(isPresented: $showDigestConfig) {
if #available(iOS 17.0, *) {
NavigationView {
DigestConfigView(dataService: dataService)
DigestConfigView(dataService: dataService, homeViewModel: viewModel)
}
} else {
Text("Sorry digest is only available on iOS 17 and above")
Expand Down Expand Up @@ -415,17 +416,7 @@ struct AnimatingCellHeight: AnimatableModifier {
)
.buttonStyle(.plain)
.padding(.trailing, 4)
}
// if #available(iOS 17.0, *), !dataService.featureFlags.digestEnabled, !viewModel.digestHidden {
// Button(
// action: { showDigestConfig = true },
// label: { Image.tabDigestSelected }
// )
// .buttonStyle(.plain)
// .padding(.trailing, 4)
// }
if #available(iOS 17.0, *), !dataService.featureFlags.digestEnabled, !viewModel.digestHidden {
// Give the user an opportunity to enable digest
} else if #available(iOS 17.0, *), !dataService.featureFlags.digestEnabled, !viewModel.hideDigestIcon {
Button(
action: { showDigestConfig = true },
label: { Image.tabDigestSelected }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum LoadingBarStyle {
@AppStorage(UserDefaultKey.hideFeatureSection.rawValue) var hideFeatureSection = false
@AppStorage(UserDefaultKey.stopUsingFollowingPrimer.rawValue) var stopUsingFollowingPrimer = false
@AppStorage("LibraryTabView::hideFollowingTab") var hideFollowingTab = false
@AppStorage("LibraryTabView::digestHidden") var digestHidden = false
@AppStorage("LibraryTabView::hideDigestIcon") var hideDigestIcon = false
@AppStorage(UserDefaultKey.lastVisitedDigestId.rawValue) var lastVisitedDigestId = ""

@AppStorage(UserDefaultKey.lastSelectedFeaturedItemFilter.rawValue) var featureFilter =
Expand Down Expand Up @@ -403,7 +403,8 @@ enum LoadingBarStyle {

func checkForDigestUpdate(dataService: DataService) async {
do {
if dataService.featureFlags.digestEnabled, let result = try? await dataService.getLatestDigest(timeoutInterval: 2) {
if dataService.featureFlags.digestEnabled,
let result = try? await dataService.getLatestDigest(timeoutInterval: 2) {
if result.id != lastVisitedDigestId {
digestIsUnread = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import Views
}

@AppStorage("LibraryTabView::hideFollowingTab") var hideFollowingTab = false
@AppStorage("LibraryTabView::hideDigestIcon") var hideDigestIcon = false

@AppStorage(UserDefaultKey.hideFeatureSection.rawValue) var hideFeatureSection = false

func loadFilters(dataService: DataService) async {
Expand Down Expand Up @@ -95,6 +97,7 @@ struct FiltersView: View {
List {
Section(header: Text("User Interface")) {
Toggle("Hide following tab", isOn: $viewModel.hideFollowingTab)
Toggle("Hide digest icon", isOn: $viewModel.hideDigestIcon)
Toggle("Hide feature section", isOn: $viewModel.hideFeatureSection)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ public struct ExplainResult: Codable {
public let text: String
}

extension DataService {

extension DataService {
public func digestNeedsRefresh() -> Bool {
let fileManager = FileManager.default
let localURL = URL.om_cachesDirectory.appendingPathComponent("digest.json")
Expand Down
Loading
Loading