eBay/NMessenger

Head Prefetching Batch Fetch Content

Opened this issue · 1 comments

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.

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