docs: 更新协议文档,删除废弃计划文档
- 更新 http-error-codes, user-points-chat-data-protocol - 更新 divination-run-protocol, profile-protocol - 删除废弃的后端和前端设计计划文档
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
@@ -181,6 +183,56 @@ class _EryaoAppState extends State<EryaoApp> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleHistorySessionDeleted(String threadId) async {
|
||||
final user = _authBloc.state.user;
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final rollback = List<DivinationResultData>.from(_historyRecords);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_historyRecords = _historyRecords
|
||||
.where((item) => item.threadId != threadId)
|
||||
.toList(growable: false);
|
||||
_loadedHistoryUserEmail = user.email;
|
||||
});
|
||||
|
||||
unawaited(
|
||||
_deleteHistorySessionRemote(
|
||||
threadId: threadId,
|
||||
userEmail: user.email,
|
||||
rollback: rollback,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _deleteHistorySessionRemote({
|
||||
required String threadId,
|
||||
required String userEmail,
|
||||
required List<DivinationResultData> rollback,
|
||||
}) async {
|
||||
try {
|
||||
await _divinationApi.deleteSession(threadId: threadId);
|
||||
} catch (error, stackTrace) {
|
||||
_logger.error(
|
||||
message: 'Failed to delete history session',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
extra: <String, dynamic>{'threadId': threadId},
|
||||
);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_historyRecords = rollback;
|
||||
_loadedHistoryUserEmail = userEmail;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
List<DivinationResultData> _mergeAndSortHistory(
|
||||
List<DivinationResultData> input,
|
||||
) {
|
||||
@@ -355,11 +407,13 @@ class _EryaoAppState extends State<EryaoApp> {
|
||||
profileSettings: _profileSettings,
|
||||
historyRecords: _historyRecords,
|
||||
coinBalance: _creditsBalance,
|
||||
divinationApi: _divinationApi,
|
||||
onLocaleChanged: _handleInterfaceLanguageChanged,
|
||||
onProfileSettingsChanged: _saveProfileSettings,
|
||||
onSaveProfile: _saveProfile,
|
||||
onUploadAvatar: _uploadAvatar,
|
||||
onDivinationCompleted: _handleDivinationCompleted,
|
||||
onDeleteHistorySession: _handleHistorySessionDeleted,
|
||||
onLogout: _authBloc.logout,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user