|
@@ -331,7 +331,7 @@ class ChatViewController: UITableViewController {
|
|
else { return }
|
|
else { return }
|
|
|
|
|
|
if appDelegate.appIsInForeground() {
|
|
if appDelegate.appIsInForeground() {
|
|
- self.messageIds = self.getMessageIds()
|
|
|
|
|
|
+ self.messageIds = self.dcContext.getChatMsgs(chatId: self.chatId)
|
|
self.reloadData()
|
|
self.reloadData()
|
|
} else {
|
|
} else {
|
|
logger.warning("startTimer() must not be executed in background")
|
|
logger.warning("startTimer() must not be executed in background")
|
|
@@ -911,7 +911,7 @@ class ChatViewController: UITableViewController {
|
|
|
|
|
|
@objc
|
|
@objc
|
|
private func refreshMessages() {
|
|
private func refreshMessages() {
|
|
- self.messageIds = self.getMessageIds()
|
|
|
|
|
|
+ self.messageIds = dcContext.getChatMsgs(chatId: chatId)
|
|
let wasLastSectionVisible = self.isLastRowVisible()
|
|
let wasLastSectionVisible = self.isLastRowVisible()
|
|
self.reloadData()
|
|
self.reloadData()
|
|
if wasLastSectionVisible {
|
|
if wasLastSectionVisible {
|
|
@@ -933,7 +933,7 @@ class ChatViewController: UITableViewController {
|
|
private func loadMessages() {
|
|
private func loadMessages() {
|
|
|
|
|
|
// update message ids
|
|
// update message ids
|
|
- var msgIds = self.getMessageIds()
|
|
|
|
|
|
+ var msgIds = dcContext.getChatMsgs(chatId: chatId)
|
|
let freshMsgsCount = self.dcContext.getUnreadMessages(chatId: self.chatId)
|
|
let freshMsgsCount = self.dcContext.getUnreadMessages(chatId: self.chatId)
|
|
if freshMsgsCount > 0 && msgIds.count >= freshMsgsCount {
|
|
if freshMsgsCount > 0 && msgIds.count >= freshMsgsCount {
|
|
let index = msgIds.count - freshMsgsCount
|
|
let index = msgIds.count - freshMsgsCount
|
|
@@ -1038,10 +1038,6 @@ class ChatViewController: UITableViewController {
|
|
emptyStateView.isHidden = true
|
|
emptyStateView.isHidden = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- private func getMessageIds() -> [Int] {
|
|
|
|
- return dcContext.getMessageIds(chatId: chatId)
|
|
|
|
- }
|
|
|
|
|
|
|
|
@objc private func saveDraft() {
|
|
@objc private func saveDraft() {
|
|
draft.save(context: dcContext)
|
|
draft.save(context: dcContext)
|