feat(chats): added refresh timer for chat room, feat(diary): fixed plan duration in plan widget and added date to app bar)

This commit is contained in:
Username1548
2025-06-05 04:28:43 +07:00
parent da8d21bb08
commit ff40e74491
7 changed files with 66 additions and 15 deletions

View File

@@ -28,8 +28,22 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
int currentPage = 1;
late int lastPage;
bool isLoading = false;
Timer? _timer;
ChatRoomCubit({required this.chatRepository, required this.wsManager, required this.cardsRepository}) : super(const ChatRoomState.loading());
ChatRoomCubit({
required this.chatRepository,
required this.wsManager,
required this.cardsRepository,
}) : super(const ChatRoomState.loading());
void setTimer() {
_timer?.cancel();
_timer = Timer.periodic(const Duration(seconds: 5), (_) => updateChosenPlanState());
}
void cancelTimer() {
_timer?.cancel();
}
loadNextPage(String chatId) async {
if (currentPage < lastPage && !isLoading) {
@@ -97,7 +111,6 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
if (chosenPlan?.consultantId == chatRoom.users.sender.id) {
await checkCards();
}
} catch (e) {
log(e.toString());
typingSubscription?.cancel();
@@ -234,6 +247,7 @@ class ChatRoomCubit extends Cubit<ChatRoomState> {
@override
Future<void> close() async {
wsManager.unsubscribeDirectChatChannel();
_timer?.cancel();
messagesSubscription?.cancel();
typingSubscription?.cancel();
super.close();