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

@@ -44,12 +44,24 @@ class _ChatScreenState extends State<ChatScreen> {
final List<({int id, int index})> unreadMessagesIds = [];
final List<({int id, int index})> unreadMessagesIdsCopy = [];
final showableChatBadgeStates = ChosenPlanStateEnum.getShowableChatBadgeStates();
late AppLifecycleListener _listener;
void _onHide() {
chatRoomCubit.cancelTimer();
}
void _onResume() {
chatRoomCubit.updateChosenPlanState();
chatRoomCubit.setTimer();
}
@override
void initState() {
super.initState();
scrollController.addListener(_onScroll);
chatRoomCubit.initChat(widget.chatId, sendInitialMessage: widget.sendInitialMessage ?? false);
chatRoomCubit.setTimer();
_listener = AppLifecycleListener(onHide: _onHide, onResume: _onResume);
}
_onScroll() {
@@ -61,6 +73,7 @@ class _ChatScreenState extends State<ChatScreen> {
@override
void dispose() {
scrollController.dispose();
_listener.dispose();
chatRoomCubit.close();
super.dispose();
}
@@ -96,7 +109,7 @@ class _ChatScreenState extends State<ChatScreen> {
final showAboutOrderButton =
state.chatRoom.chosenPlan != null && state.chatRoom.chosenPlan!.chosenPlanState != ChosenPlanStateEnum.stateCanceledByTheInitiator;
BannerType? bannerType;
if (chosenPlan == null) {
if (chosenPlan == null || chosenPlan.chosenPlanState == ChosenPlanStateEnum.stateCanceledByTheInitiator) {
bannerType = null;
} else if (amIConsultant && !state.hasCard) {
bannerType = BannerType.card;