Files
GroundedHelper/frontend/lib/Grounded/see/group/ViewGroupChat.dart
alvocool d3431ca5de Switch to Inter, round the corners softly and make the nav switch tabs
Inter replaces General Sans (Inter Display for titles and big numbers).
Corners come back from before the squaring commit, scaled to a soft set
(16 cards, 14 buttons, 12 rows, 8 chips) and applied to the screens built
since. The nav is now a cluster of round frosted buttons that switches
Today, Routines, Goals, Groups and Progress in place inside Home: no
pushed pages, no back arrows, and Android back returns to Today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
2026-11-09 07:08:46 +03:00

55 lines
1.6 KiB
Dart

import '../../about/external/data/GroupMessage.dart';
import '../../about/external/initial/GroupMessageRequest.dart';
import '../../about/external/initial/IdRequest.dart';
import '../../utils/ObjectConvertors.dart';
import '../parent/ParentViewModel.dart';
import 'ConnectGroupChat.dart';
class ViewGroupChat extends ParentViewModel {
ConnectGroupChat connection;
ViewGroupChat(super.context, this.connection);
void loadMessages(String groupId) async {
if (!await hasNetwork(() => loadMessages(groupId))) return;
showLoading("Opening the chat");
try {
final response =
await getDataManager().getGroupMessages(IdRequest(id: groupId));
closeLoading();
connection.onMessagesLoaded(getGroupMessageList(response.data));
} catch (e) {
handleError(
e, () => loadMessages(groupId), () => dismissError(), "Retry");
}
}
/// The background refresh while the chat is open. Silent either way — a
/// missed poll is picked up by the next one.
void refresh(String groupId) async {
try {
final response =
await getDataManager().getGroupMessages(IdRequest(id: groupId));
connection.onMessagesLoaded(getGroupMessageList(response.data));
} catch (e) {
// Next tick tries again.
}
}
void send(GroupMessageRequest request) async {
try {
final response = await getDataManager().sendGroupMessage(request);
connection.onMessageSent(GroupMessage.fromJson(response.data));
} catch (e) {
connection.onSendFailed(request.body);
handleError(e, () => send(request), () => dismissError(), "Retry");
}
}
}