markTaskAsDead method
Marks a task as 'dead' and records the final error. This prevents the task from being retried indefinitely.
Implementation
Future<int> markTaskAsDead(int id, String error) async {
// Get task info to update model's syncStatus
final task = await getItemById(id);
final result = await updateItem(
id: id,
status: SyncStatus.dead.name, // Set status to 'dead'
lastError: error,
// nextRetryAt could be set to null or a far future date if desired
);
// Update the model's syncStatus to 'dead'
if (task != null && result > 0) {
final modelType = task['model_type'] as String;
final modelId = task['model_id'] as String;
await updateModelSyncStatus(modelType, modelId, SyncStatus.dead.name);
}
return result;
}