2021-04-14 12:09:46 +00:00
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:io';
|
|
|
|
|
2022-04-29 05:26:01 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2021-04-14 12:09:46 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-10-08 07:43:31 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
|
|
|
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2024-02-22 15:28:21 +00:00
|
|
|
import 'package:flutter_shortcuts/flutter_shortcuts.dart';
|
2021-04-14 12:09:46 +00:00
|
|
|
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
2023-08-02 10:08:23 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
2024-07-14 14:49:46 +00:00
|
|
|
import 'package:matrix/matrix.dart' as sdk;
|
2021-10-26 16:50:34 +00:00
|
|
|
import 'package:matrix/matrix.dart';
|
2021-04-14 12:09:46 +00:00
|
|
|
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
2021-05-16 14:38:52 +00:00
|
|
|
import 'package:uni_links/uni_links.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
2024-07-14 14:49:46 +00:00
|
|
|
import 'package:fluffychat/pages/chat/send_file_dialog.dart';
|
2021-11-09 20:32:16 +00:00
|
|
|
import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
|
2022-07-07 16:50:13 +00:00
|
|
|
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
2023-01-20 15:59:50 +00:00
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2021-11-09 20:32:16 +00:00
|
|
|
import '../../../utils/account_bundles.dart';
|
2024-02-11 21:16:46 +00:00
|
|
|
import '../../config/setting_keys.dart';
|
2022-12-30 16:54:01 +00:00
|
|
|
import '../../utils/matrix_sdk_extensions/matrix_file_extension.dart';
|
2021-11-09 20:32:16 +00:00
|
|
|
import '../../utils/url_launcher.dart';
|
2022-09-10 10:12:52 +00:00
|
|
|
import '../../utils/voip/callkeep_manager.dart';
|
2022-08-25 16:31:30 +00:00
|
|
|
import '../../widgets/fluffy_chat_app.dart';
|
2021-11-09 20:32:16 +00:00
|
|
|
import '../../widgets/matrix.dart';
|
|
|
|
import '../bootstrap/bootstrap_dialog.dart';
|
2022-04-29 05:26:01 +00:00
|
|
|
|
|
|
|
import 'package:fluffychat/utils/tor_stub.dart'
|
|
|
|
if (dart.library.html) 'package:tor_detector_web/tor_detector_web.dart';
|
2021-06-20 11:16:51 +00:00
|
|
|
|
2022-08-30 18:24:36 +00:00
|
|
|
enum SelectMode {
|
|
|
|
normal,
|
|
|
|
share,
|
|
|
|
}
|
2022-05-12 09:25:34 +00:00
|
|
|
|
2021-08-01 06:05:40 +00:00
|
|
|
enum PopupMenuAction {
|
|
|
|
settings,
|
|
|
|
invite,
|
|
|
|
newGroup,
|
|
|
|
newSpace,
|
|
|
|
setStatus,
|
|
|
|
archive,
|
|
|
|
}
|
2021-04-14 12:09:46 +00:00
|
|
|
|
2022-08-30 18:24:36 +00:00
|
|
|
enum ActiveFilter {
|
|
|
|
allChats,
|
2024-07-14 14:49:46 +00:00
|
|
|
unread,
|
2022-08-30 18:24:36 +00:00
|
|
|
groups,
|
|
|
|
spaces,
|
|
|
|
}
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
extension LocalizedActiveFilter on ActiveFilter {
|
|
|
|
String toLocalizedString(BuildContext context) {
|
|
|
|
switch (this) {
|
|
|
|
case ActiveFilter.allChats:
|
|
|
|
return L10n.of(context)!.all;
|
|
|
|
case ActiveFilter.unread:
|
|
|
|
return L10n.of(context)!.unread;
|
|
|
|
case ActiveFilter.groups:
|
|
|
|
return L10n.of(context)!.groups;
|
|
|
|
case ActiveFilter.spaces:
|
|
|
|
return L10n.of(context)!.spaces;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 12:09:46 +00:00
|
|
|
class ChatList extends StatefulWidget {
|
2022-09-10 10:12:52 +00:00
|
|
|
static BuildContext? contextForVoip;
|
2023-08-07 16:40:02 +00:00
|
|
|
final String? activeChat;
|
2022-12-25 12:08:51 +00:00
|
|
|
|
2023-08-07 16:40:02 +00:00
|
|
|
const ChatList({
|
2023-10-28 11:03:16 +00:00
|
|
|
super.key,
|
2023-08-07 16:40:02 +00:00
|
|
|
required this.activeChat,
|
2023-10-28 11:03:16 +00:00
|
|
|
});
|
2021-04-14 12:09:46 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
ChatListController createState() => ChatListController();
|
|
|
|
}
|
|
|
|
|
2022-07-24 17:02:14 +00:00
|
|
|
class ChatListController extends State<ChatList>
|
|
|
|
with TickerProviderStateMixin, RouteAware {
|
2022-01-29 11:35:03 +00:00
|
|
|
StreamSubscription? _intentDataStreamSubscription;
|
2021-04-14 12:09:46 +00:00
|
|
|
|
2022-01-29 11:35:03 +00:00
|
|
|
StreamSubscription? _intentFileStreamSubscription;
|
2021-04-14 12:09:46 +00:00
|
|
|
|
2022-01-29 11:35:03 +00:00
|
|
|
StreamSubscription? _intentUriStreamSubscription;
|
2021-05-16 14:38:52 +00:00
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
void createNewSpace() {
|
|
|
|
context.push<String?>('/rooms/newspace');
|
|
|
|
}
|
2022-08-30 18:24:36 +00:00
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
ActiveFilter activeFilter = ActiveFilter.allChats;
|
2022-08-30 18:24:36 +00:00
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
String? _activeSpaceId;
|
|
|
|
String? get activeSpaceId => _activeSpaceId;
|
2022-08-30 18:24:36 +00:00
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
void setActiveSpace(String spaceId) => setState(() {
|
|
|
|
_activeSpaceId = spaceId;
|
|
|
|
});
|
|
|
|
void clearActiveSpace() => setState(() {
|
|
|
|
_activeSpaceId = null;
|
|
|
|
});
|
2022-08-30 18:24:36 +00:00
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
void addChatAction() async {
|
|
|
|
if (activeSpaceId == null) {
|
|
|
|
context.go('/rooms/newprivatechat');
|
|
|
|
return;
|
2023-12-23 14:07:35 +00:00
|
|
|
}
|
2024-07-14 14:49:46 +00:00
|
|
|
|
|
|
|
final roomType = await showConfirmationDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context)!.addChatOrSubSpace,
|
|
|
|
actions: [
|
|
|
|
AlertDialogAction(
|
|
|
|
key: AddRoomType.subspace,
|
|
|
|
label: L10n.of(context)!.createNewSpace,
|
|
|
|
),
|
|
|
|
AlertDialogAction(
|
|
|
|
key: AddRoomType.chat,
|
|
|
|
label: L10n.of(context)!.createGroup,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
if (roomType == null) return;
|
|
|
|
|
|
|
|
final names = await showTextInputDialog(
|
|
|
|
context: context,
|
|
|
|
title: roomType == AddRoomType.subspace
|
|
|
|
? L10n.of(context)!.createNewSpace
|
|
|
|
: L10n.of(context)!.createGroup,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
hintText: roomType == AddRoomType.subspace
|
|
|
|
? L10n.of(context)!.spaceName
|
|
|
|
: L10n.of(context)!.groupName,
|
|
|
|
minLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
maxLength: 64,
|
|
|
|
validator: (text) {
|
|
|
|
if (text == null || text.isEmpty) {
|
|
|
|
return L10n.of(context)!.pleaseChoose;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
DialogTextField(
|
|
|
|
hintText: L10n.of(context)!.chatDescription,
|
|
|
|
minLines: 4,
|
|
|
|
maxLines: 8,
|
|
|
|
maxLength: 255,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
okLabel: L10n.of(context)!.create,
|
|
|
|
cancelLabel: L10n.of(context)!.cancel,
|
|
|
|
);
|
|
|
|
if (names == null) return;
|
|
|
|
final client = Matrix.of(context).client;
|
|
|
|
final result = await showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
future: () async {
|
|
|
|
late final String roomId;
|
|
|
|
final activeSpace = client.getRoomById(activeSpaceId!)!;
|
|
|
|
await activeSpace.postLoad();
|
|
|
|
|
|
|
|
if (roomType == AddRoomType.subspace) {
|
|
|
|
roomId = await client.createSpace(
|
|
|
|
name: names.first,
|
|
|
|
topic: names.last.isEmpty ? null : names.last,
|
|
|
|
visibility: activeSpace.joinRules == JoinRules.public
|
|
|
|
? sdk.Visibility.public
|
|
|
|
: sdk.Visibility.private,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
roomId = await client.createGroupChat(
|
|
|
|
groupName: names.first,
|
|
|
|
preset: activeSpace.joinRules == JoinRules.public
|
|
|
|
? CreateRoomPreset.publicChat
|
|
|
|
: CreateRoomPreset.privateChat,
|
|
|
|
visibility: activeSpace.joinRules == JoinRules.public
|
|
|
|
? sdk.Visibility.public
|
|
|
|
: sdk.Visibility.private,
|
|
|
|
initialState: names.length > 1 && names.last.isNotEmpty
|
|
|
|
? [
|
|
|
|
sdk.StateEvent(
|
|
|
|
type: sdk.EventTypes.RoomTopic,
|
|
|
|
content: {'topic': names.last},
|
|
|
|
),
|
|
|
|
]
|
|
|
|
: null,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
await activeSpace.setSpaceChild(roomId);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
if (result.error != null) return;
|
2023-12-23 14:07:35 +00:00
|
|
|
}
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
void onChatTap(Room room, BuildContext context) async {
|
|
|
|
if (room.isSpace) {
|
|
|
|
setActiveSpace(room.id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (room.membership == Membership.invite) {
|
|
|
|
final inviterId =
|
|
|
|
room.getState(EventTypes.RoomMember, room.client.userID!)?.senderId;
|
|
|
|
final inviteAction = await showModalActionSheet<InviteActions>(
|
|
|
|
context: context,
|
|
|
|
message: room.isDirectChat
|
|
|
|
? L10n.of(context)!.invitePrivateChat
|
|
|
|
: L10n.of(context)!.inviteGroupChat,
|
|
|
|
title: room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
|
|
|
actions: [
|
|
|
|
SheetAction(
|
|
|
|
key: InviteActions.accept,
|
|
|
|
label: L10n.of(context)!.accept,
|
|
|
|
icon: Icons.check_outlined,
|
|
|
|
isDefaultAction: true,
|
|
|
|
),
|
|
|
|
SheetAction(
|
|
|
|
key: InviteActions.decline,
|
|
|
|
label: L10n.of(context)!.decline,
|
|
|
|
icon: Icons.close_outlined,
|
|
|
|
isDestructiveAction: true,
|
|
|
|
),
|
|
|
|
SheetAction(
|
|
|
|
key: InviteActions.block,
|
|
|
|
label: L10n.of(context)!.block,
|
|
|
|
icon: Icons.block_outlined,
|
|
|
|
isDestructiveAction: true,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
if (inviteAction == null) return;
|
|
|
|
if (inviteAction == InviteActions.block) {
|
|
|
|
context.go('/rooms/settings/security/ignorelist', extra: inviterId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (inviteAction == InviteActions.decline) {
|
|
|
|
await showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
future: room.leave,
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final joinResult = await showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
future: () async {
|
|
|
|
final waitForRoom = room.client.waitForRoomInSync(
|
|
|
|
room.id,
|
|
|
|
join: true,
|
|
|
|
);
|
|
|
|
await room.join();
|
|
|
|
await waitForRoom;
|
|
|
|
},
|
|
|
|
);
|
|
|
|
if (joinResult.error != null) return;
|
2022-08-30 18:24:36 +00:00
|
|
|
}
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
if (room.membership == Membership.ban) {
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
SnackBar(
|
|
|
|
content: Text(L10n.of(context)!.youHaveBeenBannedFromThisChat),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (room.membership == Membership.leave) {
|
|
|
|
context.go('/rooms/archive/${room.id}');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Share content into this room
|
|
|
|
final shareContent = Matrix.of(context).shareContent;
|
|
|
|
if (shareContent != null) {
|
|
|
|
final shareFile = shareContent.tryGet<MatrixFile>('file');
|
|
|
|
if (shareContent.tryGet<String>('msgtype') == 'chat.fluffy.shared_file' &&
|
|
|
|
shareFile != null) {
|
|
|
|
await showDialog(
|
|
|
|
context: context,
|
|
|
|
useRootNavigator: false,
|
|
|
|
builder: (c) => SendFileDialog(
|
|
|
|
files: [shareFile],
|
|
|
|
room: room,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
Matrix.of(context).shareContent = null;
|
|
|
|
} else {
|
|
|
|
final consent = await showOkCancelAlertDialog(
|
|
|
|
context: context,
|
|
|
|
title: L10n.of(context)!.forward,
|
|
|
|
message: L10n.of(context)!.forwardMessageTo(
|
|
|
|
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
|
|
|
),
|
|
|
|
okLabel: L10n.of(context)!.forward,
|
|
|
|
cancelLabel: L10n.of(context)!.cancel,
|
|
|
|
);
|
|
|
|
if (consent == OkCancelResult.cancel) {
|
|
|
|
Matrix.of(context).shareContent = null;
|
|
|
|
return;
|
2022-08-30 18:24:36 +00:00
|
|
|
}
|
2024-07-14 14:49:46 +00:00
|
|
|
if (consent == OkCancelResult.ok) {
|
|
|
|
room.sendEvent(shareContent);
|
|
|
|
Matrix.of(context).shareContent = null;
|
2022-09-11 09:07:04 +00:00
|
|
|
}
|
2024-07-14 14:49:46 +00:00
|
|
|
}
|
2022-08-30 18:24:36 +00:00
|
|
|
}
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
context.go('/rooms/${room.id}');
|
2022-09-11 09:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Function(Room) getRoomFilterByActiveFilter(ActiveFilter activeFilter) {
|
2022-08-30 18:24:36 +00:00
|
|
|
switch (activeFilter) {
|
|
|
|
case ActiveFilter.allChats:
|
2024-07-14 14:49:46 +00:00
|
|
|
return (room) => true;
|
2022-08-30 18:24:36 +00:00
|
|
|
case ActiveFilter.groups:
|
2023-12-22 16:15:14 +00:00
|
|
|
return (room) => !room.isSpace && !room.isDirectChat;
|
2024-07-14 14:49:46 +00:00
|
|
|
case ActiveFilter.unread:
|
|
|
|
return (room) => room.isUnreadOrInvited;
|
2022-08-30 18:24:36 +00:00
|
|
|
case ActiveFilter.spaces:
|
2024-07-14 14:49:46 +00:00
|
|
|
return (room) => room.isSpace;
|
2022-08-30 18:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-29 11:35:03 +00:00
|
|
|
|
2022-09-11 09:07:04 +00:00
|
|
|
List<Room> get filteredRooms => Matrix.of(context)
|
|
|
|
.client
|
|
|
|
.rooms
|
|
|
|
.where(getRoomFilterByActiveFilter(activeFilter))
|
|
|
|
.toList();
|
|
|
|
|
2022-07-07 16:50:13 +00:00
|
|
|
bool isSearchMode = false;
|
|
|
|
Future<QueryPublicRoomsResponse>? publicRoomsResponse;
|
|
|
|
String? searchServer;
|
|
|
|
Timer? _coolDown;
|
|
|
|
SearchUserDirectoryResponse? userSearchResult;
|
|
|
|
QueryPublicRoomsResponse? roomSearchResult;
|
|
|
|
|
|
|
|
bool isSearching = false;
|
|
|
|
static const String _serverStoreNamespace = 'im.fluffychat.search.server';
|
|
|
|
|
|
|
|
void setServer() async {
|
|
|
|
final newServer = await showTextInputDialog(
|
2024-01-25 08:13:08 +00:00
|
|
|
useRootNavigator: false,
|
2023-03-02 09:57:52 +00:00
|
|
|
title: L10n.of(context)!.changeTheHomeserver,
|
|
|
|
context: context,
|
|
|
|
okLabel: L10n.of(context)!.ok,
|
|
|
|
cancelLabel: L10n.of(context)!.cancel,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
prefixText: 'https://',
|
|
|
|
hintText: Matrix.of(context).client.homeserver?.host,
|
|
|
|
initialText: searchServer,
|
|
|
|
keyboardType: TextInputType.url,
|
|
|
|
autocorrect: false,
|
2023-08-13 09:15:13 +00:00
|
|
|
validator: (server) => server?.contains('.') == true
|
|
|
|
? null
|
|
|
|
: L10n.of(context)!.invalidServerName,
|
2023-08-18 05:24:31 +00:00
|
|
|
),
|
2023-03-02 09:57:52 +00:00
|
|
|
],
|
|
|
|
);
|
2022-07-07 16:50:13 +00:00
|
|
|
if (newServer == null) return;
|
2023-11-01 17:00:10 +00:00
|
|
|
Matrix.of(context).store.setString(_serverStoreNamespace, newServer.single);
|
2022-07-07 16:50:13 +00:00
|
|
|
setState(() {
|
|
|
|
searchServer = newServer.single;
|
|
|
|
});
|
2023-08-13 11:13:52 +00:00
|
|
|
_coolDown?.cancel();
|
|
|
|
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
2022-07-07 16:50:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final TextEditingController searchController = TextEditingController();
|
2023-08-13 11:13:52 +00:00
|
|
|
final FocusNode searchFocusNode = FocusNode();
|
2022-07-07 16:50:13 +00:00
|
|
|
|
|
|
|
void _search() async {
|
|
|
|
final client = Matrix.of(context).client;
|
|
|
|
if (!isSearching) {
|
|
|
|
setState(() {
|
|
|
|
isSearching = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
SearchUserDirectoryResponse? userSearchResult;
|
|
|
|
QueryPublicRoomsResponse? roomSearchResult;
|
2024-01-20 07:49:57 +00:00
|
|
|
final searchQuery = searchController.text.trim();
|
2022-07-07 16:50:13 +00:00
|
|
|
try {
|
|
|
|
roomSearchResult = await client.queryPublicRooms(
|
|
|
|
server: searchServer,
|
2024-01-20 07:49:57 +00:00
|
|
|
filter: PublicRoomQueryFilter(genericSearchTerm: searchQuery),
|
2022-07-07 16:50:13 +00:00
|
|
|
limit: 20,
|
|
|
|
);
|
2024-01-20 07:49:57 +00:00
|
|
|
|
|
|
|
if (searchQuery.isValidMatrixId &&
|
|
|
|
searchQuery.sigil == '#' &&
|
|
|
|
roomSearchResult.chunk
|
|
|
|
.any((room) => room.canonicalAlias == searchQuery) ==
|
|
|
|
false) {
|
|
|
|
final response = await client.getRoomIdByAlias(searchQuery);
|
|
|
|
final roomId = response.roomId;
|
|
|
|
if (roomId != null) {
|
|
|
|
roomSearchResult.chunk.add(
|
|
|
|
PublicRoomsChunk(
|
|
|
|
name: searchQuery,
|
|
|
|
guestCanJoin: false,
|
|
|
|
numJoinedMembers: 0,
|
|
|
|
roomId: roomId,
|
|
|
|
worldReadable: false,
|
|
|
|
canonicalAlias: searchQuery,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-07-07 16:50:13 +00:00
|
|
|
userSearchResult = await client.searchUserDirectory(
|
|
|
|
searchController.text,
|
|
|
|
limit: 20,
|
|
|
|
);
|
|
|
|
} catch (e, s) {
|
|
|
|
Logs().w('Searching has crashed', e, s);
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
SnackBar(
|
|
|
|
content: Text(
|
|
|
|
e.toLocalizedString(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-07-09 17:30:55 +00:00
|
|
|
if (!isSearchMode) return;
|
2022-07-07 16:50:13 +00:00
|
|
|
setState(() {
|
|
|
|
isSearching = false;
|
|
|
|
this.roomSearchResult = roomSearchResult;
|
|
|
|
this.userSearchResult = userSearchResult;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-10 15:26:40 +00:00
|
|
|
void onSearchEnter(String text, {bool globalSearch = true}) {
|
2022-07-07 16:50:13 +00:00
|
|
|
if (text.isEmpty) {
|
2022-12-29 09:33:13 +00:00
|
|
|
cancelSearch(unfocus: false);
|
2022-07-07 16:50:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
isSearchMode = true;
|
|
|
|
});
|
|
|
|
_coolDown?.cancel();
|
2024-03-10 15:26:40 +00:00
|
|
|
if (globalSearch) {
|
|
|
|
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
|
|
|
}
|
2022-07-07 16:50:13 +00:00
|
|
|
}
|
|
|
|
|
2023-08-13 09:15:13 +00:00
|
|
|
void startSearch() {
|
|
|
|
setState(() {
|
|
|
|
isSearchMode = true;
|
|
|
|
});
|
2023-08-13 11:13:52 +00:00
|
|
|
searchFocusNode.requestFocus();
|
|
|
|
_coolDown?.cancel();
|
|
|
|
_coolDown = Timer(const Duration(milliseconds: 500), _search);
|
2023-08-13 09:15:13 +00:00
|
|
|
}
|
|
|
|
|
2022-12-29 09:33:13 +00:00
|
|
|
void cancelSearch({bool unfocus = true}) {
|
2022-12-25 12:08:51 +00:00
|
|
|
setState(() {
|
|
|
|
searchController.clear();
|
|
|
|
isSearchMode = false;
|
|
|
|
roomSearchResult = userSearchResult = null;
|
|
|
|
isSearching = false;
|
|
|
|
});
|
2023-08-13 11:13:52 +00:00
|
|
|
if (unfocus) searchFocusNode.unfocus();
|
2022-12-25 12:08:51 +00:00
|
|
|
}
|
2022-07-07 16:50:13 +00:00
|
|
|
|
2022-04-29 05:26:01 +00:00
|
|
|
bool isTorBrowser = false;
|
|
|
|
|
2022-04-02 14:18:36 +00:00
|
|
|
BoxConstraints? snappingSheetContainerSize;
|
|
|
|
|
2021-08-29 09:29:14 +00:00
|
|
|
final ScrollController scrollController = ScrollController();
|
2023-05-10 11:01:35 +00:00
|
|
|
final ValueNotifier<bool> scrolledToTop = ValueNotifier(true);
|
2021-08-29 09:29:14 +00:00
|
|
|
|
2021-12-22 08:11:30 +00:00
|
|
|
final StreamController<Client> _clientStream = StreamController.broadcast();
|
|
|
|
|
|
|
|
Stream<Client> get clientStream => _clientStream.stream;
|
|
|
|
|
2023-08-07 16:40:02 +00:00
|
|
|
void addAccountAction() => context.go('/rooms/settings/account');
|
2022-07-07 16:50:13 +00:00
|
|
|
|
2021-08-29 09:29:14 +00:00
|
|
|
void _onScroll() {
|
|
|
|
final newScrolledToTop = scrollController.position.pixels <= 0;
|
2023-05-10 11:01:35 +00:00
|
|
|
if (newScrolledToTop != scrolledToTop.value) {
|
|
|
|
scrolledToTop.value = newScrolledToTop;
|
2021-08-29 09:29:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-01 05:45:34 +00:00
|
|
|
|
2021-08-04 07:56:05 +00:00
|
|
|
void editSpace(BuildContext context, String spaceId) async {
|
2022-01-29 11:35:03 +00:00
|
|
|
await Matrix.of(context).client.getRoomById(spaceId)!.postLoad();
|
2022-11-02 08:57:06 +00:00
|
|
|
if (mounted) {
|
2023-08-13 14:10:31 +00:00
|
|
|
context.push('/rooms/$spaceId/details');
|
2022-11-02 08:57:06 +00:00
|
|
|
}
|
2021-08-01 05:54:44 +00:00
|
|
|
}
|
|
|
|
|
2022-04-03 17:00:35 +00:00
|
|
|
// Needs to match GroupsSpacesEntry for 'separate group' checking.
|
2021-08-01 05:45:34 +00:00
|
|
|
List<Room> get spaces =>
|
|
|
|
Matrix.of(context).client.rooms.where((r) => r.isSpace).toList();
|
|
|
|
|
2023-08-07 16:40:02 +00:00
|
|
|
String? get activeChat => widget.activeChat;
|
2021-05-23 18:13:10 +00:00
|
|
|
|
2021-05-31 18:41:46 +00:00
|
|
|
SelectMode get selectMode => Matrix.of(context).shareContent != null
|
|
|
|
? SelectMode.share
|
2024-07-14 14:49:46 +00:00
|
|
|
: SelectMode.normal;
|
2021-05-31 18:41:46 +00:00
|
|
|
|
2021-04-14 12:09:46 +00:00
|
|
|
void _processIncomingSharedFiles(List<SharedMediaFile> files) {
|
2022-01-29 11:35:03 +00:00
|
|
|
if (files.isEmpty) return;
|
2022-05-29 09:34:21 +00:00
|
|
|
final file = File(files.first.path.replaceFirst('file://', ''));
|
2021-04-14 12:09:46 +00:00
|
|
|
|
|
|
|
Matrix.of(context).shareContent = {
|
|
|
|
'msgtype': 'chat.fluffy.shared_file',
|
|
|
|
'file': MatrixFile(
|
|
|
|
bytes: file.readAsBytesSync(),
|
|
|
|
name: file.path,
|
|
|
|
).detectFileType,
|
|
|
|
};
|
2023-08-07 16:40:02 +00:00
|
|
|
context.go('/rooms');
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-29 11:35:03 +00:00
|
|
|
void _processIncomingSharedText(String? text) {
|
2021-04-14 12:09:46 +00:00
|
|
|
if (text == null) return;
|
2021-11-26 13:59:35 +00:00
|
|
|
if (text.toLowerCase().startsWith(AppConfig.deepLinkPrefix) ||
|
|
|
|
text.toLowerCase().startsWith(AppConfig.inviteLinkPrefix) ||
|
2021-04-14 12:09:46 +00:00
|
|
|
(text.toLowerCase().startsWith(AppConfig.schemePrefix) &&
|
|
|
|
!RegExp(r'\s').hasMatch(text))) {
|
2021-11-26 13:59:35 +00:00
|
|
|
return _processIncomingUris(text);
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
|
|
|
Matrix.of(context).shareContent = {
|
|
|
|
'msgtype': 'm.text',
|
|
|
|
'body': text,
|
|
|
|
};
|
2023-08-07 16:40:02 +00:00
|
|
|
context.go('/rooms');
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-29 11:35:03 +00:00
|
|
|
void _processIncomingUris(String? text) async {
|
2021-08-28 08:50:12 +00:00
|
|
|
if (text == null) return;
|
2023-08-07 16:40:02 +00:00
|
|
|
context.go('/rooms');
|
2022-05-12 09:25:34 +00:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
2021-11-29 15:18:16 +00:00
|
|
|
UrlLauncher(context, text).openMatrixToUrl();
|
|
|
|
});
|
2021-05-16 14:38:52 +00:00
|
|
|
}
|
|
|
|
|
2021-04-14 12:09:46 +00:00
|
|
|
void _initReceiveSharingIntent() {
|
|
|
|
if (!PlatformInfos.isMobile) return;
|
|
|
|
|
|
|
|
// For sharing images coming from outside the app while the app is in the memory
|
|
|
|
_intentFileStreamSubscription = ReceiveSharingIntent.getMediaStream()
|
|
|
|
.listen(_processIncomingSharedFiles, onError: print);
|
|
|
|
|
|
|
|
// For sharing images coming from outside the app while the app is closed
|
|
|
|
ReceiveSharingIntent.getInitialMedia().then(_processIncomingSharedFiles);
|
|
|
|
|
|
|
|
// For sharing or opening urls/text coming from outside the app while the app is in the memory
|
|
|
|
_intentDataStreamSubscription = ReceiveSharingIntent.getTextStream()
|
|
|
|
.listen(_processIncomingSharedText, onError: print);
|
|
|
|
|
|
|
|
// For sharing or opening urls/text coming from outside the app while the app is closed
|
|
|
|
ReceiveSharingIntent.getInitialText().then(_processIncomingSharedText);
|
2021-05-16 14:38:52 +00:00
|
|
|
|
|
|
|
// For receiving shared Uris
|
2021-08-02 16:41:09 +00:00
|
|
|
_intentUriStreamSubscription = linkStream.listen(_processIncomingUris);
|
2021-05-16 14:38:52 +00:00
|
|
|
if (FluffyChatApp.gotInitialLink == false) {
|
|
|
|
FluffyChatApp.gotInitialLink = true;
|
|
|
|
getInitialLink().then(_processIncomingUris);
|
|
|
|
}
|
2024-02-22 15:28:21 +00:00
|
|
|
|
|
|
|
if (PlatformInfos.isAndroid) {
|
|
|
|
final shortcuts = FlutterShortcuts();
|
|
|
|
shortcuts.initialize().then(
|
|
|
|
(_) => shortcuts.listenAction((action) {
|
|
|
|
if (!mounted) return;
|
|
|
|
UrlLauncher(context, action).launchUrl();
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_initReceiveSharingIntent();
|
2021-11-15 09:05:15 +00:00
|
|
|
|
2021-08-29 09:29:14 +00:00
|
|
|
scrollController.addListener(_onScroll);
|
2021-11-15 09:05:15 +00:00
|
|
|
_waitForFirstSync();
|
2022-02-19 08:27:03 +00:00
|
|
|
_hackyWebRTCFixForWeb();
|
2022-09-10 10:12:52 +00:00
|
|
|
CallKeepManager().initialize();
|
2022-07-07 16:50:13 +00:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
2022-12-30 12:09:21 +00:00
|
|
|
if (mounted) {
|
2023-11-01 17:00:10 +00:00
|
|
|
searchServer =
|
|
|
|
Matrix.of(context).store.getString(_serverStoreNamespace);
|
2022-12-30 12:09:21 +00:00
|
|
|
Matrix.of(context).backgroundPush?.setupPush();
|
|
|
|
}
|
2023-10-08 07:43:31 +00:00
|
|
|
|
|
|
|
// Workaround for system UI overlay style not applied on app start
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
|
|
Theme.of(context).appBarTheme.systemOverlayStyle!,
|
|
|
|
);
|
2022-07-07 16:50:13 +00:00
|
|
|
});
|
2022-04-29 05:26:01 +00:00
|
|
|
|
|
|
|
_checkTorBrowser();
|
|
|
|
|
2021-04-14 12:09:46 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_intentDataStreamSubscription?.cancel();
|
|
|
|
_intentFileStreamSubscription?.cancel();
|
2021-05-16 14:38:52 +00:00
|
|
|
_intentUriStreamSubscription?.cancel();
|
2021-08-29 09:29:14 +00:00
|
|
|
scrollController.removeListener(_onScroll);
|
2021-04-14 12:09:46 +00:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
void chatContextAction(Room room) async {
|
|
|
|
final action = await showModalActionSheet<ChatContextAction>(
|
2021-04-14 12:09:46 +00:00
|
|
|
context: context,
|
2024-07-14 14:49:46 +00:00
|
|
|
title: room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
|
|
|
actions: [
|
|
|
|
SheetAction(
|
|
|
|
key: ChatContextAction.markUnread,
|
|
|
|
icon: room.markedUnread
|
|
|
|
? Icons.mark_as_unread
|
|
|
|
: Icons.mark_as_unread_outlined,
|
|
|
|
label: room.markedUnread
|
|
|
|
? L10n.of(context)!.markAsRead
|
|
|
|
: L10n.of(context)!.unread,
|
|
|
|
),
|
|
|
|
SheetAction(
|
|
|
|
key: ChatContextAction.favorite,
|
|
|
|
icon: room.isFavourite ? Icons.pin : Icons.pin_outlined,
|
|
|
|
label: room.isFavourite
|
|
|
|
? L10n.of(context)!.unpin
|
|
|
|
: L10n.of(context)!.pin,
|
|
|
|
),
|
|
|
|
SheetAction(
|
|
|
|
key: ChatContextAction.mute,
|
|
|
|
icon: room.pushRuleState == PushRuleState.notify
|
|
|
|
? Icons.notifications_off_outlined
|
|
|
|
: Icons.notifications,
|
|
|
|
label: room.pushRuleState == PushRuleState.notify
|
|
|
|
? L10n.of(context)!.muteChat
|
|
|
|
: L10n.of(context)!.unmuteChat,
|
|
|
|
),
|
|
|
|
SheetAction(
|
|
|
|
isDestructiveAction: true,
|
|
|
|
key: ChatContextAction.leave,
|
|
|
|
icon: Icons.delete_outlined,
|
|
|
|
label: L10n.of(context)!.leave,
|
|
|
|
),
|
|
|
|
],
|
2021-04-14 12:09:46 +00:00
|
|
|
);
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
if (action == null) return;
|
|
|
|
if (!mounted) return;
|
2021-04-14 12:09:46 +00:00
|
|
|
|
2021-11-14 19:59:25 +00:00
|
|
|
await showFutureLoadingDialog(
|
2021-04-14 12:09:46 +00:00
|
|
|
context: context,
|
2024-07-14 14:49:46 +00:00
|
|
|
future: () {
|
|
|
|
switch (action) {
|
|
|
|
case ChatContextAction.favorite:
|
|
|
|
return room.setFavourite(!room.isFavourite);
|
|
|
|
case ChatContextAction.markUnread:
|
|
|
|
return room.markUnread(!room.markedUnread);
|
|
|
|
case ChatContextAction.mute:
|
|
|
|
return room.setPushRuleState(
|
|
|
|
room.pushRuleState == PushRuleState.notify
|
|
|
|
? PushRuleState.mentionsOnly
|
|
|
|
: PushRuleState.notify,
|
|
|
|
);
|
|
|
|
case ChatContextAction.leave:
|
|
|
|
return room.leave();
|
2021-11-14 19:59:25 +00:00
|
|
|
}
|
|
|
|
},
|
2021-04-14 12:09:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-02-11 21:16:46 +00:00
|
|
|
void dismissStatusList() async {
|
|
|
|
final result = await showOkCancelAlertDialog(
|
|
|
|
title: L10n.of(context)!.hidePresences,
|
|
|
|
context: context,
|
|
|
|
);
|
|
|
|
if (result == OkCancelResult.ok) {
|
|
|
|
await Matrix.of(context).store.setBool(SettingKeys.showPresences, false);
|
|
|
|
AppConfig.showPresences = false;
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 12:09:46 +00:00
|
|
|
void setStatus() async {
|
2023-12-22 18:41:18 +00:00
|
|
|
final client = Matrix.of(context).client;
|
|
|
|
final currentPresence = await client.fetchCurrentPresence(client.userID!);
|
2021-04-14 12:09:46 +00:00
|
|
|
final input = await showTextInputDialog(
|
2024-01-25 08:13:08 +00:00
|
|
|
useRootNavigator: false,
|
2023-03-02 09:57:52 +00:00
|
|
|
context: context,
|
|
|
|
title: L10n.of(context)!.setStatus,
|
2023-12-22 16:15:14 +00:00
|
|
|
message: L10n.of(context)!.leaveEmptyToClearStatus,
|
2023-03-02 09:57:52 +00:00
|
|
|
okLabel: L10n.of(context)!.ok,
|
|
|
|
cancelLabel: L10n.of(context)!.cancel,
|
|
|
|
textFields: [
|
|
|
|
DialogTextField(
|
|
|
|
hintText: L10n.of(context)!.statusExampleMessage,
|
2023-12-22 16:15:14 +00:00
|
|
|
maxLines: 6,
|
|
|
|
minLines: 1,
|
|
|
|
maxLength: 255,
|
2023-12-22 18:41:18 +00:00
|
|
|
initialText: currentPresence.statusMsg,
|
2023-03-02 09:57:52 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
2021-04-14 12:09:46 +00:00
|
|
|
if (input == null) return;
|
2023-12-22 18:41:18 +00:00
|
|
|
if (!mounted) return;
|
2021-04-14 12:09:46 +00:00
|
|
|
await showFutureLoadingDialog(
|
|
|
|
context: context,
|
2023-12-22 18:41:18 +00:00
|
|
|
future: () => client.setPresence(
|
|
|
|
client.userID!,
|
|
|
|
PresenceType.online,
|
|
|
|
statusMsg: input.single,
|
|
|
|
),
|
2021-04-14 12:09:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-15 09:05:15 +00:00
|
|
|
bool waitForFirstSync = false;
|
2021-11-09 16:30:04 +00:00
|
|
|
|
|
|
|
Future<void> _waitForFirstSync() async {
|
2021-04-14 12:09:46 +00:00
|
|
|
final client = Matrix.of(context).client;
|
2021-11-09 12:06:41 +00:00
|
|
|
await client.roomsLoading;
|
|
|
|
await client.accountDataLoading;
|
2024-02-01 07:00:33 +00:00
|
|
|
await client.userDeviceKeysLoading;
|
2022-07-10 11:09:53 +00:00
|
|
|
if (client.prevBatch == null) {
|
2022-07-09 08:18:53 +00:00
|
|
|
await client.onSync.stream.first;
|
2022-08-28 11:34:57 +00:00
|
|
|
|
|
|
|
// Display first login bootstrap if enabled
|
|
|
|
if (client.encryption?.keyManager.enabled == true) {
|
|
|
|
if (await client.encryption?.keyManager.isCached() == false ||
|
|
|
|
await client.encryption?.crossSigning.isCached() == false ||
|
2022-11-02 08:57:06 +00:00
|
|
|
client.isUnknownSession && !mounted) {
|
2022-08-28 11:34:57 +00:00
|
|
|
await BootstrapDialog(client: client).show(context);
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
2022-10-17 15:48:38 +00:00
|
|
|
if (!mounted) return;
|
|
|
|
setState(() {
|
|
|
|
waitForFirstSync = true;
|
|
|
|
});
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cancelAction() {
|
|
|
|
if (selectMode == SelectMode.share) {
|
|
|
|
setState(() => Matrix.of(context).shareContent = null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-14 14:49:46 +00:00
|
|
|
void setActiveFilter(ActiveFilter filter) {
|
|
|
|
setState(() {
|
|
|
|
activeFilter = filter;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-09-19 11:48:23 +00:00
|
|
|
void setActiveClient(Client client) {
|
2023-08-07 16:40:02 +00:00
|
|
|
context.go('/rooms');
|
2021-09-19 11:48:23 +00:00
|
|
|
setState(() {
|
2024-07-14 14:49:46 +00:00
|
|
|
activeFilter = ActiveFilter.allChats;
|
|
|
|
_activeSpaceId = null;
|
2021-09-19 11:48:23 +00:00
|
|
|
Matrix.of(context).setActiveClient(client);
|
|
|
|
});
|
2021-12-22 08:11:30 +00:00
|
|
|
_clientStream.add(client);
|
2021-09-19 11:48:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-21 07:16:57 +00:00
|
|
|
void setActiveBundle(String bundle) {
|
2023-08-07 16:40:02 +00:00
|
|
|
context.go('/rooms');
|
2021-09-21 07:16:57 +00:00
|
|
|
setState(() {
|
2024-07-14 14:49:46 +00:00
|
|
|
_activeSpaceId = null;
|
2021-09-21 07:16:57 +00:00
|
|
|
Matrix.of(context).activeBundle = bundle;
|
|
|
|
if (!Matrix.of(context)
|
2022-01-29 11:35:03 +00:00
|
|
|
.currentBundle!
|
2021-09-21 07:16:57 +00:00
|
|
|
.any((client) => client == Matrix.of(context).client)) {
|
|
|
|
Matrix.of(context)
|
2022-01-29 11:35:03 +00:00
|
|
|
.setActiveClient(Matrix.of(context).currentBundle!.first);
|
2021-09-21 07:16:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-09-19 11:48:23 +00:00
|
|
|
|
2022-01-29 11:35:03 +00:00
|
|
|
void editBundlesForAccount(String? userId, String? activeBundle) async {
|
2022-11-02 08:57:06 +00:00
|
|
|
final l10n = L10n.of(context)!;
|
2021-09-19 11:48:23 +00:00
|
|
|
final client = Matrix.of(context)
|
|
|
|
.widget
|
2022-01-29 11:35:03 +00:00
|
|
|
.clients[Matrix.of(context).getClientIndexByMatrixId(userId!)];
|
2021-09-19 11:48:23 +00:00
|
|
|
final action = await showConfirmationDialog<EditBundleAction>(
|
|
|
|
context: context,
|
2022-01-29 11:35:03 +00:00
|
|
|
title: L10n.of(context)!.editBundlesForAccount,
|
2021-09-19 11:48:23 +00:00
|
|
|
actions: [
|
|
|
|
AlertDialogAction(
|
|
|
|
key: EditBundleAction.addToBundle,
|
2022-01-29 11:35:03 +00:00
|
|
|
label: L10n.of(context)!.addToBundle,
|
2021-09-19 11:48:23 +00:00
|
|
|
),
|
2021-11-14 17:47:18 +00:00
|
|
|
if (activeBundle != client.userID)
|
2021-09-19 11:48:23 +00:00
|
|
|
AlertDialogAction(
|
|
|
|
key: EditBundleAction.removeFromBundle,
|
2022-01-29 11:35:03 +00:00
|
|
|
label: L10n.of(context)!.removeFromBundle,
|
2021-09-19 11:48:23 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
if (action == null) return;
|
|
|
|
switch (action) {
|
|
|
|
case EditBundleAction.addToBundle:
|
|
|
|
final bundle = await showTextInputDialog(
|
2023-03-02 09:57:52 +00:00
|
|
|
context: context,
|
|
|
|
title: l10n.bundleName,
|
|
|
|
textFields: [DialogTextField(hintText: l10n.bundleName)],
|
|
|
|
);
|
2021-11-14 17:47:18 +00:00
|
|
|
if (bundle == null || bundle.isEmpty || bundle.single.isEmpty) return;
|
2021-09-19 11:48:23 +00:00
|
|
|
await showFutureLoadingDialog(
|
|
|
|
context: context,
|
|
|
|
future: () => client.setAccountBundle(bundle.single),
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case EditBundleAction.removeFromBundle:
|
|
|
|
await showFutureLoadingDialog(
|
|
|
|
context: context,
|
2022-01-29 11:35:03 +00:00
|
|
|
future: () => client.removeFromAccountBundle(activeBundle!),
|
2021-09-19 11:48:23 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool get displayBundles =>
|
|
|
|
Matrix.of(context).hasComplexBundles &&
|
|
|
|
Matrix.of(context).accountBundles.keys.length > 1;
|
|
|
|
|
2022-01-29 11:35:03 +00:00
|
|
|
String? get secureActiveBundle {
|
2021-09-19 11:48:23 +00:00
|
|
|
if (Matrix.of(context).activeBundle == null ||
|
|
|
|
!Matrix.of(context)
|
|
|
|
.accountBundles
|
|
|
|
.keys
|
|
|
|
.contains(Matrix.of(context).activeBundle)) {
|
|
|
|
return Matrix.of(context).accountBundles.keys.first;
|
|
|
|
}
|
|
|
|
return Matrix.of(context).activeBundle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetActiveBundle() {
|
2022-05-12 09:25:34 +00:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
2021-09-19 11:48:23 +00:00
|
|
|
setState(() {
|
|
|
|
Matrix.of(context).activeBundle = null;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-14 12:09:46 +00:00
|
|
|
@override
|
2023-08-13 08:56:46 +00:00
|
|
|
Widget build(BuildContext context) => ChatListView(this);
|
2022-02-19 08:27:03 +00:00
|
|
|
|
|
|
|
void _hackyWebRTCFixForWeb() {
|
2022-09-10 10:12:52 +00:00
|
|
|
ChatList.contextForVoip = context;
|
2022-02-19 08:27:03 +00:00
|
|
|
}
|
2022-04-29 05:26:01 +00:00
|
|
|
|
|
|
|
Future<void> _checkTorBrowser() async {
|
|
|
|
if (!kIsWeb) return;
|
|
|
|
final isTor = await TorBrowserDetector.isTorBrowser;
|
2022-11-13 17:09:42 +00:00
|
|
|
isTorBrowser = isTor;
|
2022-04-29 05:26:01 +00:00
|
|
|
}
|
|
|
|
|
2024-02-22 17:59:38 +00:00
|
|
|
Future<void> dehydrate() => Matrix.of(context).dehydrateAction();
|
2021-04-14 12:09:46 +00:00
|
|
|
}
|
2021-09-19 11:48:23 +00:00
|
|
|
|
|
|
|
enum EditBundleAction { addToBundle, removeFromBundle }
|
2024-07-14 14:49:46 +00:00
|
|
|
|
|
|
|
enum InviteActions {
|
|
|
|
accept,
|
|
|
|
decline,
|
|
|
|
block,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum AddRoomType { chat, subspace }
|
|
|
|
|
|
|
|
enum ChatContextAction {
|
|
|
|
favorite,
|
|
|
|
markUnread,
|
|
|
|
mute,
|
|
|
|
leave,
|
|
|
|
}
|