-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Performing Nested Adapter Updates on Section Controllers/Binding Section Controllers #1264
Comments
@jboo1212 yup! That looks like you're on the right track. We do almost the same thing in Instagram. |
Hey @rnystrom, thanks for the confirmation. I just had one issue though. I receive the below call stack error...
I trigger an update of the data source to diff the Story Model > Stories that have been read but not sure why it triggers that error. Below is the code... private func modelGenerators() -> [Story] {
// Users
let user1 = User(id: UUID().uuidString, profilePic: Bundle.main.url(forResource: "jeromeythehomie", withExtension: "jpg")!, handle: "jeromeythehomie")
let user2 = User(id: UUID().uuidString, profilePic: Bundle.main.url(forResource: "mattlee077", withExtension: "jpg")!, handle: "mattlee077")
let user3 = User(id: UUID().uuidString, profilePic: Bundle.main.url(forResource: "asethics", withExtension: "jpg")!, handle: "asethics")
let user4 = User(id: UUID().uuidString, profilePic: Bundle.main.url(forResource: "nat.pat33", withExtension: "jpg")!, handle: "nat.pat33")
// Story Items
let storyItem1 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_0021", withExtension: "mov")!)
let storyItem2 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_0460", withExtension: "mov")!)
let storyItem3 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1539", withExtension: "mov")!)
let storyItem4 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1636", withExtension: "mov")!)
let storyItem5 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1691", withExtension: "mov")!)
let storyItem6 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1704", withExtension: "mov")!)
let storyItem7 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1705", withExtension: "mov")!)
let storyItem8 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1706", withExtension: "mov")!)
let storyItem9 = StoryItem(id: UUID().uuidString, url: Bundle.main.url(forResource: "IMG_1707", withExtension: "mov")!)
// Stories
let story1 = Story(user: user1, isRead: false, storyItems: [storyItem1, storyItem2, storyItem3])
let story2 = Story(user: user2, isRead: true, storyItems: [storyItem4, storyItem5, storyItem6, storyItem7])
let story3 = Story(user: user3, isRead: false, storyItems: [storyItem8])
let story4 = Story(user: user4, isRead: false, storyItems: [storyItem9])
let stories = [story1, story2, story3, story4]
let story5 = Story(user: user1, isRead: false, storyItems: [storyItem1, storyItem2, storyItem3])
let story6 = Story(user: user2, isRead: true, storyItems: [storyItem4, storyItem5, storyItem6, storyItem7])
let story7 = Story(user: user3, isRead: true, storyItems: [storyItem8])
let story8 = Story(user: user4, isRead: true, storyItems: [storyItem9])
otherStories = [story5, story6, story7, story8]
return stories
}
@objc private func onRefresh() {
refreshControl.beginRefreshing()
let model = StoryModel(stories: otherStories)
storyModel = [model]
adapter.performUpdates(animated: true, completion: nil)
refreshControl.endRefreshing()
} My understanding is that the Story Model contains Stories that have changed which will then tell the Stories data source (IGListBindingSectionController) to update. I'll edit my previous post to show you how the models look now. |
New issue checklist
README
and documentationGeneral information
IGListKit
version: 3.0In https://github.com/jboo1212/IGStoriesClone I'm making a stories clone but in my finals steps of completing the clone, I'm having difficulties wrapping my brain around nested adapter updates. Whenever the collection view is dragged by its refresh control, it should trigger an adapter update from Story Model to the nested adapter data source containing the stories.
I.e. when a story is "read" by the user and the collection view is dragged, the system will move read stories towards the end of the collection and not read stories towards the front.
Am I on the right track? Should I make
Story Model
have a betterisEqual(toDiffableObject object: ListDiffable?) -> Bool
?Below are the models for IGStories.
The text was updated successfully, but these errors were encountered: