-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
Sessions table view model refactoring #703
Merged
allenhumphreys
merged 16 commits into
master
from
ah/sessions-table-view-controller-refactor
Jul 6, 2023
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e608286
Sessions table view model refactoring
allenhumphreys 467bfce
Fix search coordinator delegate issue, videos tab working well, exper…
allenhumphreys b11202c
Split filtering config for each tab, critical functionality working
allenhumphreys 47d451b
Make filters react to storage changes
allenhumphreys d81982c
Simply filter setup code by being smart
allenhumphreys 771c82e
Continuing to put things back together
allenhumphreys 3942cb2
Additional work on filtering observation
allenhumphreys 649b42f
Do schedules live filtering too
allenhumphreys 56b1031
Minor cleanup
allenhumphreys 1569f7d
Incorporate now playing into filtering to prevent UX confusion
allenhumphreys f1f8172
Clean up AppCoordinator and have a look at performance
allenhumphreys b426230
A few more optimizations
allenhumphreys 53b2ab6
Realm updates are very fast now
allenhumphreys ef353ab
Add schema migration
allenhumphreys cee9fe2
Wrap up the final fixes I think
allenhumphreys 6bcbe77
Clean up and final improvements
allenhumphreys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,14 +86,13 @@ public class SessionInstance: Object, ConditionallyDecodable { | |
return ["code"] | ||
} | ||
|
||
public static func standardSort(instanceA: SessionInstance, instanceB: SessionInstance) -> Bool { | ||
guard let sessionA = instanceA.session, let sessionB = instanceB.session else { return false } | ||
|
||
if instanceA.sessionType == instanceB.sessionType { | ||
return Session.standardSort(sessionA: sessionA, sessionB: sessionB) | ||
} else { | ||
return instanceA.sessionType < instanceB.sessionType | ||
} | ||
public static func standardSortDescriptors() -> [RealmSwift.SortDescriptor] { | ||
return [ | ||
RealmSwift.SortDescriptor(keyPath: "rawSessionType"), | ||
RealmSwift.SortDescriptor(keyPath: "session.trackOrder"), | ||
RealmSwift.SortDescriptor(keyPath: "session.eventStartDate"), | ||
RealmSwift.SortDescriptor(keyPath: "session.title") | ||
] | ||
} | ||
|
||
func merge(with other: SessionInstance, in realm: Realm) { | ||
|
@@ -113,17 +112,12 @@ public class SessionInstance: Object, ConditionallyDecodable { | |
session.merge(with: otherSession, in: realm) | ||
} | ||
|
||
let otherKeywords = other.keywords.map { newKeyword -> (Keyword) in | ||
if newKeyword.realm == nil, | ||
let existingKeyword = realm.object(ofType: Keyword.self, forPrimaryKey: newKeyword.name) { | ||
return existingKeyword | ||
} else { | ||
return newKeyword | ||
} | ||
} | ||
let currentKeywordIds = Set(keywords.map(\.name)) | ||
other.keywords.forEach { newKeyword in | ||
guard !currentKeywordIds.contains(newKeyword.name) else { return } | ||
|
||
keywords.removeAll() | ||
keywords.append(objectsIn: otherKeywords) | ||
keywords.append(realm.object(ofType: Keyword.self, forPrimaryKey: newKeyword.name) ?? newKeyword) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer equivalent since it doesn't handle removals |
||
} | ||
} | ||
|
||
// MARK: - Decodable | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing logic doesn't handle removals, should we fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(that's true for all 3 lists that get updated here)