Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into fix/discussion-f…
Browse files Browse the repository at this point in the history
…ilter
  • Loading branch information
forgotvas committed Mar 25, 2024
2 parents f9615d6 + 2bc8c4f commit d009bab
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 25 deletions.
8 changes: 8 additions & 0 deletions Core/Core.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
02F6EF4A28D9F0A700835477 /* DateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F6EF4928D9F0A700835477 /* DateExtension.swift */; };
02F98A7F28F81EE900DE94C0 /* Container+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F98A7E28F81EE900DE94C0 /* Container+App.swift */; };
0604C9AA2B22FACF00AD5DBF /* UIComponentsConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0604C9A92B22FACF00AD5DBF /* UIComponentsConfig.swift */; };
06078B702BA49C3100576798 /* Dictionary+JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06078B6E2BA49C3100576798 /* Dictionary+JSON.swift */; };
06078B712BA49C3100576798 /* String+JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06078B6F2BA49C3100576798 /* String+JSON.swift */; };
064987932B4D69FF0071642A /* DragAndDropCssInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0649878A2B4D69FE0071642A /* DragAndDropCssInjection.swift */; };
064987942B4D69FF0071642A /* WebviewInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0649878B2B4D69FE0071642A /* WebviewInjection.swift */; };
064987952B4D69FF0071642A /* SurveyCssInjection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0649878C2B4D69FE0071642A /* SurveyCssInjection.swift */; };
Expand Down Expand Up @@ -259,6 +261,8 @@
02F6EF4928D9F0A700835477 /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = "<group>"; };
02F98A7E28F81EE900DE94C0 /* Container+App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Container+App.swift"; sourceTree = "<group>"; };
0604C9A92B22FACF00AD5DBF /* UIComponentsConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIComponentsConfig.swift; sourceTree = "<group>"; };
06078B6E2BA49C3100576798 /* Dictionary+JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dictionary+JSON.swift"; sourceTree = "<group>"; };
06078B6F2BA49C3100576798 /* String+JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+JSON.swift"; sourceTree = "<group>"; };
0649878A2B4D69FE0071642A /* DragAndDropCssInjection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragAndDropCssInjection.swift; sourceTree = "<group>"; };
0649878B2B4D69FE0071642A /* WebviewInjection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebviewInjection.swift; sourceTree = "<group>"; };
0649878C2B4D69FE0071642A /* SurveyCssInjection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SurveyCssInjection.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -450,6 +454,8 @@
0283347E28D4DCC100C828FC /* Extensions */ = {
isa = PBXGroup;
children = (
06078B6E2BA49C3100576798 /* Dictionary+JSON.swift */,
06078B6F2BA49C3100576798 /* String+JSON.swift */,
02F164362902A9EB0090DDEF /* StringExtension.swift */,
024BE3DE29B2615500BCDEE2 /* CGColorExtension.swift */,
0283347F28D4DCD200C828FC /* ViewExtension.swift */,
Expand Down Expand Up @@ -1079,10 +1085,12 @@
0283348028D4DCD200C828FC /* ViewExtension.swift in Sources */,
BA8FA66A2AD59B5500EA029A /* GoogleAuthProvider.swift in Sources */,
02A4833529B8A73400D33F33 /* CorePersistenceProtocol.swift in Sources */,
06078B712BA49C3100576798 /* String+JSON.swift in Sources */,
0233D5732AF13EEE00BAC8BD /* AppReviewButton.swift in Sources */,
02512FF0299533DF0024D438 /* CoreDataHandlerProtocol.swift in Sources */,
0260E58028FD792800BBBE18 /* WebUnitViewModel.swift in Sources */,
02A4833A29B8A9AB00D33F33 /* DownloadManager.swift in Sources */,
06078B702BA49C3100576798 /* Dictionary+JSON.swift in Sources */,
027BD3AE2909475000392132 /* KeyboardScrollerOptions.swift in Sources */,
BAFB99922B14E23D007D09F9 /* AppleSignInConfig.swift in Sources */,
141F1D302B7328D4009E81EB /* WebviewCookiesUpdateProtocol.swift in Sources */,
Expand Down
16 changes: 0 additions & 16 deletions Core/Core/Data/Model/Data_Dashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public extension DataLayer {
public let number: String
public let org: String
public let start: String?
public let startDisplay: String
public let startType: StartType
public let end: String?
public let dynamicUpgradeDeadline: String?
Expand All @@ -112,9 +111,6 @@ public extension DataLayer {
public let courseImage: String
public let courseAbout: String
public let courseSharingUtmParameters: CourseSharingUtmParameters
public let courseUpdates: String
public let courseHandouts: String
public let discussionURL: String
public let videoOutline: String?
public let isSelfPaced: Bool

Expand All @@ -124,7 +120,6 @@ public extension DataLayer {
case number
case org
case start
case startDisplay = "start_display"
case startType = "start_type"
case end
case dynamicUpgradeDeadline = "dynamic_upgrade_deadline"
Expand All @@ -134,9 +129,6 @@ public extension DataLayer {
case courseImage = "course_image"
case courseAbout = "course_about"
case courseSharingUtmParameters = "course_sharing_utm_parameters"
case courseUpdates = "course_updates"
case courseHandouts = "course_handouts"
case discussionURL = "discussion_url"
case videoOutline = "video_outline"
case isSelfPaced = "is_self_paced"
}
Expand All @@ -147,7 +139,6 @@ public extension DataLayer {
number: String,
org: String,
start: String?,
startDisplay: String,
startType: StartType,
end: String?,
dynamicUpgradeDeadline: String?,
Expand All @@ -157,9 +148,6 @@ public extension DataLayer {
courseImage: String,
courseAbout: String,
courseSharingUtmParameters: CourseSharingUtmParameters,
courseUpdates: String,
courseHandouts: String,
discussionURL: String,
videoOutline: String?,
isSelfPaced: Bool
) {
Expand All @@ -168,7 +156,6 @@ public extension DataLayer {
self.number = number
self.org = org
self.start = start
self.startDisplay = startDisplay
self.startType = startType
self.end = end
self.dynamicUpgradeDeadline = dynamicUpgradeDeadline
Expand All @@ -178,9 +165,6 @@ public extension DataLayer {
self.courseImage = courseImage
self.courseAbout = courseAbout
self.courseSharingUtmParameters = courseSharingUtmParameters
self.courseUpdates = courseUpdates
self.courseHandouts = courseHandouts
self.discussionURL = discussionURL
self.videoOutline = videoOutline
self.isSelfPaced = isSelfPaced
}
Expand Down
18 changes: 18 additions & 0 deletions Core/Core/Extensions/Dictionary+JSON.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Dictionary+JSON.swift
// Core
//
// Created by Vadim Kuznetsov on 13.03.24.
//

import Foundation

public extension Dictionary where Key == String, Value == String {
public func toJson() -> String? {
guard let jsonData = try? JSONSerialization.data(withJSONObject: self, options: []) else {
return nil
}

return String(data: jsonData, encoding: .utf8)
}
}
23 changes: 23 additions & 0 deletions Core/Core/Extensions/String+JSON.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// String+JSON.swift
// Core
//
// Created by Vadim Kuznetsov on 13.03.24.
//

import Foundation

public extension String {
public func jsonStringToDictionary() -> [String: Any]? {
guard let jsonData = self.data(using: .utf8) else {
return nil
}

guard let jsonObject = try? JSONSerialization.jsonObject(with: jsonData, options: []),
let dictionary = jsonObject as? [String: Any] else {
return nil
}

return dictionary
}
}
10 changes: 9 additions & 1 deletion Core/Core/Extensions/UIApplicationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ extension UINavigationController {
.font: Theme.UIFonts.titleMedium()
]

UISegmentedControl.appearance().setTitleTextAttributes(
[
.foregroundColor: Theme.Colors.textPrimary.uiColor(),
.font: Theme.UIFonts.labelLarge()
],
for: .normal
)
UISegmentedControl.appearance().setTitleTextAttributes(
[
.foregroundColor: Theme.Colors.primaryButtonTextColor.uiColor(),
.font: Theme.UIFonts.labelLarge()
],
for: .normal)
for: .selected
)
UISegmentedControl.appearance().selectedSegmentTintColor = UIColor(Theme.Colors.accentXColor)

UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = Theme.UIColors.accentXColor
Expand Down
4 changes: 1 addition & 3 deletions Core/Core/View/Base/ProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ public struct ProgressBar: View {
.animation(animation, value: isAnimating)
}
.onAppear {
withAnimation {
isAnimating = true
}
isAnimating = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22522" systemVersion="23D56" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22757" systemVersion="23D56" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="CDCourseBlock" representedClassName="CDCourseBlock" syncable="YES" codeGenerationType="class">
<attribute name="allSources" optional="YES" attributeType="Transformable" valueTransformerName="NSSecureUnarchiveFromData" customClassName="[String]"/>
<attribute name="blockId" optional="YES" attributeType="String"/>
Expand All @@ -11,6 +11,7 @@
<attribute name="id" optional="YES" attributeType="String"/>
<attribute name="multiDevice" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="studentUrl" optional="YES" attributeType="String"/>
<attribute name="transcripts" optional="YES" attributeType="String"/>
<attribute name="type" optional="YES" attributeType="String"/>
<relationship name="desktopMP4" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="CDCourseBlockVideo"/>
<relationship name="fallback" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="CDCourseBlockVideo"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public struct CreateNewThreadView: View {
self.onPostCreated = onPostCreated
self.courseID = courseID
viewModel.selectedTopic = selectedTopic
Task {
await viewModel.getTopics(courseID: courseID)
}
}

public var body: some View {
Expand Down Expand Up @@ -198,6 +195,9 @@ public struct CreateNewThreadView: View {
Theme.Colors.background
.ignoresSafeArea()
)
.task {
await viewModel.getTopics(courseID: courseID)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CreateNewThreadViewModel: ObservableObject {

@MainActor
public func getTopics(courseID: String) async {
guard allTopics.isEmpty else { return }
isShowProgress = true
do {
topics = try await interactor.getTopics(courseID: courseID)
Expand Down
6 changes: 5 additions & 1 deletion OpenEdX/Data/CoursePersistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class CoursePersistence: CoursePersistenceProtocol {

let blocks = try? context.fetch(requestBlocks).map {
let userViewData = DataLayer.CourseDetailUserViewData(
transcripts: nil,
transcripts: $0.transcripts?.jsonStringToDictionary() as? [String: String],
encodedVideo: DataLayer.CourseDetailEncodedVideoData(
youTube: DataLayer.EncodedVideoData(
url: $0.youTube?.url,
Expand Down Expand Up @@ -213,6 +213,10 @@ public class CoursePersistence: CoursePersistenceProtocol {
courseDetail.hls = hls
}

if let transcripts = block.userViewData?.transcripts {
courseDetail.transcripts = transcripts.toJson()
}

do {
try context.save()
} catch {
Expand Down

0 comments on commit d009bab

Please sign in to comment.