Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Head Prefetching Batch Fetch Content #199

Open
munsifhayat opened this issue Apr 16, 2018 · 1 comment
Open

Head Prefetching Batch Fetch Content #199

munsifhayat opened this issue Apr 16, 2018 · 1 comment

Comments

@munsifhayat
Copy link

Issue# 1 :

Why does the batch fetch content is not called by itself?

Here is my code for that :

func batchFetchContent() {

    DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
        
        DispatchQueue.main.async {
            self.pageIndex += 1
            self.performCallToGetConsumerMessagesHistory(limit: "20", offsetValue: "\(self.pageIndex)", isAdd: false, completionBlock: { (cells) in
                DispatchQueue.main.async {
                    let messageCells = self.createNextBatch()
                    self.endBatchFetchDirectly(messageCells: messageCells)
                }
            })
        }
    }
}


private func endBatchFetchDirectly(messageCells: [GeneralMessengerCell]) {
    self.chatWindow?.messengerView.endBatchFetchWithMessages(messageCells)
}



private func endBatchFetchAdjusted(messageCells: [GeneralMessengerCell]) {
    let currentHeight = self.chatWindow?.messengerView.messengerNode.view.contentSize.height ?? 24
    self.chatWindow?.messengerView.endBatchFetchWithMessages(messageCells)
    self.chatWindow?.messengerView.addMessagesWithBlock([], scrollsToMessage: false, withAnimation: .none) {
        DispatchQueue.main.async {
            if let contentHeight = self.chatWindow?.messengerView.messengerNode.view.contentSize.height {
                let addedHeight = contentHeight - currentHeight
                self.chatWindow?.messengerView.messengerNode.view.contentOffset.y = addedHeight
                
            }
          }
    }
}

issue 2 : What are the prerequisite for that ?
Batch fetch content call.

@munsifhayat
Copy link
Author

munsifhayat commented Apr 16, 2018

self.chatWindow?.messengerView.doesBatchFetch = true
Still it is not working.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant