feat: 重构 Reminder Notification 系统并更新应用包名
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -110,11 +111,13 @@ class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
|
||||
AgUiService? service,
|
||||
required ChatApi chatApi,
|
||||
ChatHistoryRepository? historyRepository,
|
||||
Future<void> Function()? onCalendarMutated,
|
||||
Duration recoveryPollInterval = const Duration(milliseconds: 700),
|
||||
Duration recoveryTimeout = const Duration(seconds: 20),
|
||||
}) : _service =
|
||||
service ??
|
||||
AgUiService(chatApi: chatApi, historyRepository: historyRepository),
|
||||
_onCalendarMutated = onCalendarMutated,
|
||||
_recoveryPollInterval = recoveryPollInterval,
|
||||
_recoveryTimeout = recoveryTimeout,
|
||||
super(const ChatState()) {
|
||||
@@ -122,6 +125,7 @@ class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
|
||||
}
|
||||
|
||||
final AgUiService _service;
|
||||
final Future<void> Function()? _onCalendarMutated;
|
||||
final Duration _recoveryPollInterval;
|
||||
final Duration _recoveryTimeout;
|
||||
String? _activeUserId;
|
||||
@@ -214,5 +218,33 @@ class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
|
||||
_attachmentPreviewCache.clear();
|
||||
_attachmentPreviewInflight.clear();
|
||||
emit(const ChatState());
|
||||
if (normalizedUserId != null && epoch == _sessionEpoch) {
|
||||
try {
|
||||
await _loadHistory();
|
||||
} catch (error) {
|
||||
emit(state.copyWith(error: error.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _shouldRefreshCalendarForTool(ToolCallResultEvent event) {
|
||||
final name = event.toolName.trim().toLowerCase();
|
||||
final status = event.status.trim().toLowerCase();
|
||||
if (name != 'calendar_write') {
|
||||
return false;
|
||||
}
|
||||
return status == 'success' || status == 'partial';
|
||||
}
|
||||
|
||||
Future<void> _refreshCalendarAfterToolMutation() async {
|
||||
final callback = _onCalendarMutated;
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await callback();
|
||||
} catch (error) {
|
||||
emit(state.copyWith(error: error.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user