forked from openedx/openedx-app-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openedx#377 from edx/fix/discussion_blacked_out
chore: Make inactive posting buttons/fields for "posting disabled" courses
- Loading branch information
Showing
28 changed files
with
500 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Discussion/Discussion/Data/Model/Data_DiscussionInfo.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Data_DiscussionInfo.swift | ||
// Discussion | ||
// | ||
// Created by Eugene Yatsenko on 19.03.2024. | ||
// | ||
|
||
import Foundation | ||
import Core | ||
|
||
public struct DiscussionBlackout { | ||
var start: String | ||
var end: String | ||
} | ||
|
||
public extension DataLayer { | ||
struct DiscussionInfo: Codable { | ||
var discussionID: String? | ||
var blackouts: [DiscussionBlackout]? | ||
} | ||
|
||
struct DiscussionBlackout: Codable { | ||
var start: String | ||
var end: String | ||
} | ||
} | ||
|
||
public extension DataLayer.DiscussionInfo { | ||
var domain: DiscussionInfo { | ||
.init( | ||
discussionID: discussionID, | ||
blackouts: blackouts?.compactMap { .init(start: $0.start, end: $0.end) } | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// DiscussionInfo.swift | ||
// Discussion | ||
// | ||
// Created by Eugene Yatsenko on 19.03.2024. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct DiscussionInfo { | ||
public var discussionID: String? | ||
public var blackouts: [DiscussionBlackout]? | ||
|
||
public func isBlackedOut() -> Bool { | ||
guard let blackouts = blackouts else { | ||
return false | ||
} | ||
var isBlackedOut = false | ||
for blackout in blackouts { | ||
let start = Date(iso8601: blackout.start) | ||
let end = Date(iso8601: blackout.end) | ||
|
||
if Date().isEarlierThanOrEqualTo(date: end) && | ||
Date().isLaterThanOrEqualTo(date: start) { | ||
isBlackedOut = true | ||
} | ||
} | ||
|
||
return isBlackedOut | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.