Skip to content

Commit

Permalink
Merge pull request #236 from pangeachat/prevent-empty-chats
Browse files Browse the repository at this point in the history
Prevent Empty Chats
  • Loading branch information
ggurdin authored May 22, 2024
2 parents d8d9f75 + 46aca69 commit 629b5e4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 247 deletions.
5 changes: 5 additions & 0 deletions lib/pages/chat_list/chat_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ class ChatListController extends State<ChatList>
while (selectedRoomIds.isNotEmpty) {
final roomId = selectedRoomIds.first;
try {
// #Pangea
if (client.getRoomById(roomId)!.isUnread) {
await client.getRoomById(roomId)!.markUnread(false);
}
// Pangea#
await client.getRoomById(roomId)!.leave();
} finally {
toggleSelection(roomId);
Expand Down
5 changes: 5 additions & 0 deletions lib/pages/chat_list/chat_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class ChatListItem extends StatelessWidget {
message: L10n.of(context)!.archiveRoomDescription,
);
if (confirmed == OkCancelResult.cancel) return;
// #Pangea
if (room.isUnread) {
await room.markUnread(false);
}
// Pangea#
await showFutureLoadingDialog(
context: context,
future: () => room.leave(),
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/chat_list/space_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ class _SpaceViewState extends State<SpaceView> {
// #Pangea
// future: room!.leave,
future: () async {
await room!.leave();
if (room!.isUnread) {
await room.markUnread(false);
}
await room.leave();
if (Matrix.of(context).activeRoomId == room.id) {
context.go('/rooms');
}
Expand Down
15 changes: 9 additions & 6 deletions lib/pages/chat_list/utils/on_chat_tap.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import 'package:flutter/material.dart';

import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:fluffychat/pages/chat/send_file_dialog.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart';

import 'package:fluffychat/pages/chat/send_file_dialog.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/matrix.dart';

void onChatTap(Room room, BuildContext context) async {
if (room.membership == Membership.invite) {
final inviterId =
Expand Down Expand Up @@ -47,6 +45,11 @@ void onChatTap(Room room, BuildContext context) async {
return;
}
if (inviteAction == InviteActions.decline) {
// #Pangea
if (room.isUnread) {
await room.markUnread(false);
}
// Pangea#
await showFutureLoadingDialog(
context: context,
future: room.leave,
Expand Down
149 changes: 0 additions & 149 deletions lib/pangea/pages/class_settings/p_class_widgets/delete_class_tile.dart

This file was deleted.

6 changes: 4 additions & 2 deletions lib/pangea/utils/archive_space.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:matrix/matrix.dart';

import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:matrix/matrix.dart';

Future<void> archiveSpace(Room? space, Client client) async {
if (space == null) {
Expand All @@ -14,6 +13,9 @@ Future<void> archiveSpace(Room? space, Client client) async {

final List<Room> children = await space.getChildRooms();
for (final Room child in children) {
if (child.isUnread) {
await child.markUnread(false);
}
await child.leave();
}
await space.leave();
Expand Down
89 changes: 0 additions & 89 deletions lib/pangea/utils/delete_room.dart

This file was deleted.

0 comments on commit 629b5e4

Please sign in to comment.