Skip to content

Commit

Permalink
fix: #197-아무 대화가 시작되지 않은 채팅방은 표시 하지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-hunc committed May 15, 2024
1 parent cb8d767 commit af31f9f
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class _HelperChattingListScreenState extends State<HelperChattingListScreen> {
Future<void> startPolling(Map<String, dynamic> roomInfo) async {
try {
while (isActive) {
// loadChatRooms();
try {
var currentNewChatsInfos =
await ChatService.pollingChatList(roomInfo);
Expand All @@ -65,15 +64,17 @@ class _HelperChattingListScreenState extends State<HelperChattingListScreen> {

if (flag) {
// 새로운 채팅방일 때
chatRoomList.add(ChatRoomModel(
chatRoomId: newChatInfo.chatRoomId,
userId: newChatInfo.userId,
userName: newChatInfo.userId,
lastMessageId: 0,
lastMessagePreviewId: newChatInfo.id,
chatRoomMessage: newChatInfo.content,
chatRoomDate: newChatInfo.timestamp,
));
if (newChatInfo.id != 0) {
chatRoomList.add(ChatRoomModel(
chatRoomId: newChatInfo.chatRoomId,
userId: newChatInfo.userId,
userName: newChatInfo.userId,
lastMessageId: 0,
lastMessagePreviewId: newChatInfo.id,
chatRoomMessage: newChatInfo.content,
chatRoomDate: newChatInfo.timestamp,
));
}
}
}

Expand Down Expand Up @@ -115,13 +116,17 @@ class _HelperChattingListScreenState extends State<HelperChattingListScreen> {
body: ListView.builder(
itemCount: chatRoomList.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: HelperChattingCard(
chatRoomModel: chatRoomList[index],
chatRoomListUpdate: loadChatRooms,
),
);
if (chatRoomList[index].lastMessageId != 0) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: HelperChattingCard(
chatRoomModel: chatRoomList[index],
chatRoomListUpdate: loadChatRooms,
),
);
} else {
return const SizedBox.shrink();
}
},
),
);
Expand Down

0 comments on commit af31f9f

Please sign in to comment.