Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge development into production
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyd committed Apr 27, 2023
2 parents 9f5e61d + 9afc333 commit 9fd8f0d
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 210 deletions.
4 changes: 0 additions & 4 deletions Emitron/Emitron.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@
495E2B1A27F4FE8C003EEE86 /* Optional+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 495E2B1927F4FE8C003EEE86 /* Optional+Extensions.swift */; };
49971FEA27B297DA00FBCCEA /* TabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49971FE927B297DA00FBCCEA /* TabView.swift */; };
8B283DEF23169A1F001F1B17 /* ProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B283DEE23169A1E001F1B17 /* ProgressBarView.swift */; };
8B7E96DD2357A65F0083DA38 /* ProTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B7E96DC2357A65F0083DA38 /* ProTag.swift */; };
8B7E96DF2357A66A0083DA38 /* CompletedTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B7E96DE2357A66A0083DA38 /* CompletedTag.swift */; };
8BFC74BC23648DF3001979F1 /* ContentPaginatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BFC74BB23648DF3001979F1 /* ContentPaginatable.swift */; };
8BFC74C32364A9BE001979F1 /* ContentScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BFC74C22364A9BE001979F1 /* ContentScreen.swift */; };
Expand Down Expand Up @@ -514,7 +513,6 @@
495E2B1927F4FE8C003EEE86 /* Optional+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Extensions.swift"; sourceTree = "<group>"; };
49971FE927B297DA00FBCCEA /* TabView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabView.swift; sourceTree = "<group>"; };
8B283DEE23169A1E001F1B17 /* ProgressBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBarView.swift; sourceTree = "<group>"; };
8B7E96DC2357A65F0083DA38 /* ProTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProTag.swift; sourceTree = "<group>"; };
8B7E96DE2357A66A0083DA38 /* CompletedTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedTag.swift; sourceTree = "<group>"; };
8BFC74BB23648DF3001979F1 /* ContentPaginatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentPaginatable.swift; sourceTree = "<group>"; };
8BFC74C22364A9BE001979F1 /* ContentScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentScreen.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1051,7 +1049,6 @@
children = (
22C6410723FA903F00CBFDE5 /* TagView.swift */,
8B7E96DE2357A66A0083DA38 /* CompletedTag.swift */,
8B7E96DC2357A65F0083DA38 /* ProTag.swift */,
);
path = Tags;
sourceTree = "<group>";
Expand Down Expand Up @@ -1941,7 +1938,6 @@
222EEF7B23CDC24500B025A4 /* VideoPlaybackViewModel.swift in Sources */,
223D77AB23B0C099005BE95D /* Download.swift in Sources */,
22C0514023A4FBCC004D1223 /* Group+Persistence.swift in Sources */,
8B7E96DD2357A65F0083DA38 /* ProTag.swift in Sources */,
2278AE4A240A565C00855221 /* Icon.swift in Sources */,
22DC505B2403EA0600A6E808 /* DownloadWarningView.swift in Sources */,
22E2268023CA2D7F00A83601 /* Group+GroupDisplayable.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions Emitron/Emitron/Assets.xcassets/Colours/Tags/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion Emitron/Emitron/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension String {
static let tutorials = "Tutorials"

// MARK: Detail View
static let detailContentLockedCosPro = "Upgrade your account to watch this and other Pro courses"
static let detailContentLockedCosPro = "Upgrade your account to watch this and other locked courses"

// MARK: Messaging
static let bookmarkCreated = "Content bookmarked successfully."
Expand Down
2 changes: 0 additions & 2 deletions Emitron/Emitron/Guardpost/Guardpost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public extension Guardpost {

// This will prevent sharing cookies with Safari, which means no auto-login
// However, it also means that you can actually log out, which is good, I guess.
#if (!DEBUG)
authSession.prefersEphemeralWebBrowserSession = true
#endif

authSession.start()
}
Expand Down
2 changes: 1 addition & 1 deletion Emitron/Emitron/Logging/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct Event {
) -> Self {
.init(
source: "\(Source.self)",
action: "Login"
action: "Refresh"
)
}

Expand Down
3 changes: 1 addition & 2 deletions Emitron/Emitron/Models/DataCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ extension DataCache {
cacheUpdate.progressions.forEach { progressions[$0.contentID] = $0 }
cacheUpdate.groups.forEach { groupIndexedGroups[$0.id] = $0 }

// swiftlint:disable generic_type_name
func mergeWithCacheUpdate<contentID: Emitron.contentID>(
func mergeWithCacheUpdate<contentID: Emitron.contentID>( // swiftlint:disable:this generic_type_name
_ dictionary: inout [Int: [contentID]],
_ getContentID: (DataCacheUpdate) -> [contentID]
) {
Expand Down
8 changes: 7 additions & 1 deletion Emitron/Emitron/Models/Permission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@

import struct Foundation.Date

struct Permission: Equatable, Codable {
struct Permission: Equatable, Codable, Hashable {
enum Tag: Int, Codable {
case streamBeginner
case streamPro
case streamTeam
case streamPersonal
case download

init?(from string: String) {
Expand All @@ -43,6 +45,10 @@ struct Permission: Equatable, Codable {
self = .streamPro
case "download-videos":
self = .download
case "stream-personal-videos":
self = .streamPersonal
case "stream-team-videos":
self = .streamTeam
default:
return nil
}
Expand Down
10 changes: 9 additions & 1 deletion Emitron/Emitron/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ private extension User {
}

func can(_ tag: Permission.Tag) -> Bool {
permissions?.lazy.map(\.tag).contains(tag) == true
// This is a hack, and relies on the fact that personal and team subs can
// pretty much stream all pro content. In future we need to add permissions
// to the contents API, and then do a comparison between content permissions
// and user permissions.
if tag == .streamPro {
let tags = Set<Permission.Tag>([.streamPersonal, .streamTeam, .streamPro])
return !tags.isDisjoint(with: permissions?.lazy.map(\.tag) ?? [])
}
return permissions?.lazy.map(\.tag).contains(tag) == true
}
}
4 changes: 4 additions & 0 deletions Emitron/Emitron/Persistence/EmitronDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import GRDB

// We use `t` as a variable name rather a lot
// swiftlint:disable identifier_name

/// A type responsible for initialising the application's database
Expand Down Expand Up @@ -170,3 +171,6 @@ enum EmitronDatabase {
return migrator
}
}

// Stop swiftlint complaining
// swiftlint:enable identifier_name
12 changes: 0 additions & 12 deletions Emitron/Emitron/Styleguide/Color+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,6 @@ extension Color {
.init("tagForeground")
}

static var proTagBackground: Color {
.init("proTagBackground")
}

static var proTagForeground: Color {
.init("proTagForeground")
}

static var proTagBorder: Color {
.init("proTagBorder")
}

static var filterTagBackground: Color {
.init("filterTagBackground")
}
Expand Down
37 changes: 20 additions & 17 deletions Emitron/Emitron/UI/App Root/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,30 @@ struct LoginView: View {

var body: some View {
GeometryReader { proxy in
VStack {

HStack {
Spacer()

Image("logo")
.resizable()
.scaledToFit()
.padding([.top], proxy.safeAreaInsets.top)
.padding(.horizontal, 92)

VStack {

Spacer()

Image("logo")
.resizable()
.scaledToFit()
.padding([.top], proxy.safeAreaInsets.top)
.padding(.horizontal, 92)

Spacer()

MainButtonView(title: "Sign In", type: .primary(withArrow: false)) {
Task(priority: .userInitiated) { try await sessionController.logIn() }
}
.padding(.horizontal, 18)
.padding([.bottom], 38)
}.frame(maxWidth: 400)
Spacer()

MainButtonView(title: "Sign In", type: .primary(withArrow: false)) {
Task(priority: .userInitiated) { try await sessionController.logIn() }
}
.padding(.horizontal, 18)
.padding([.bottom], 38)
}
.background(Color.background)
.edgesIgnoringSafeArea([.all])
}
}.background(Color.background)
}
}

Expand Down
18 changes: 17 additions & 1 deletion Emitron/Emitron/UI/App Root/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct MainView: View {
@EnvironmentObject private var dataManager: DataManager
@EnvironmentObject private var messageBus: MessageBus
@EnvironmentObject private var settingsManager: SettingsManager

// A bit of a hack variable to ensure we can refresh when we want to
@State private var refresh = false

private let tabViewModel = TabViewModel()
private let notification = NotificationCenter.default.publisher(for: .requestReview)
Expand All @@ -50,6 +53,15 @@ struct MainView: View {
makeReviewRequest()
}
}
.onReceive(sessionController.$permissionState) { state in
Task {
// This is a bit of a hack. It forces reloading this view, even though
// it shouldn't be necessary. However, it appears to maybe work?
try await Task.sleep(nanoseconds: 2_000_000_000)
print(":::STATE:::: \(state)")
refresh.toggle()
}
}
}
}
}
Expand All @@ -59,7 +71,11 @@ private extension MainView {
@ViewBuilder var contentView: some View {
if !sessionController.isLoggedIn {
LoginView()
} else {
// This conditional is a mess. But it forces this view to be reliant on
// the refresh state var, which is triggered whenever the permission state
// changes. This is necesary because, sometimes, this view doesn't update
// when permission state changes. And I don't know why.
} else if refresh || !refresh {
switch sessionController.permissionState {
case .loaded:
tabBarView
Expand Down
18 changes: 5 additions & 13 deletions Emitron/Emitron/UI/Shared/Content Detail/ContentSummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,11 @@ extension ContentSummaryView: View {
dynamicContentViewModel.initialiseIfRequired()

return VStack(alignment: .leading) {
HStack {
Text(content.technologyTripleString.uppercased())
.font(.uiUppercase)
.foregroundColor(.contentText)
.kerning(0.5)

Spacer()

if content.professional {
ProTag()
}
}
.padding([.top], 20)
Text(content.technologyTripleString.uppercased())
.font(.uiUppercase)
.foregroundColor(.contentText)
.kerning(0.5)
.padding([.top], 20)

Text(content.name)
.font(.uiTitle1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct ProContentLockedOverlayView: View {
HStack {
Image.padlock

Text("Pro Course")
Text("Locked Course")
.font(.uiTitle1)
.foregroundColor(.titleText)
}
Expand Down
6 changes: 1 addition & 5 deletions Emitron/Emitron/UI/Shared/Content List/CardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ struct CardView: View {
.lineSpacing(3)
.foregroundColor(.contentText)

HStack(spacing: 8) {
if model.professional {
ProTag()
}

HStack(spacing: 8) {
completedTagOrReleasedAt

Spacer()
Expand Down
Loading

0 comments on commit 9fd8f0d

Please sign in to comment.