Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions NextcloudTalk/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2066,22 +2066,23 @@ import SwiftUI
return
}

guard let taskId, status != .failed else {
let noRunningAiSummaryTasks = AiSummaryController.shared.getSummaryTaskIds(forRoomInternalId: self.room.internalId).isEmpty

// This summary task failed, no previous tasks running and no more messages -> Nothing we can do, stop here
if status == .failed, noRunningAiSummaryTasks, nextOffset == nil {
NotificationPresenter.shared().present(text: NSLocalizedString("Generating summary of unread messages failed", comment: ""), dismissAfterDelay: 7.0, includedStyle: .error)
return
}

let hasRunningAiSummaryTasks = !AiSummaryController.shared.getSummaryTaskIds(forRoomInternalId: self.room.internalId).isEmpty

// No messages to summarize found, no previous tasks running and no more messages -> Nothing we can do, stop here
if status == .noMessagesFound, !hasRunningAiSummaryTasks, nextOffset == nil {
if status == .noMessagesFound, noRunningAiSummaryTasks, nextOffset == nil {
NotificationPresenter.shared().present(text: NSLocalizedString("No messages found to summarize", comment: ""), dismissAfterDelay: 7.0, includedStyle: .error)
return
}

// We might end up here with a status of "noMessagesFound". That can happen if we have previous running tasks, or got a nextOffset.
// Therefore we explictly check for "success" to only track tasks that were successfully submitted with messages
if status == .success {
if status == .success, let taskId {
AiSummaryController.shared.addSummaryTaskId(forRoomInternalId: self.room.internalId, withTaskId: taskId)
print("Scheduled summary task with taskId \(taskId) and nextOffset \(String(describing: nextOffset))")
}
Expand Down
Loading