refactor: Update to Dart 3.10 with . shorthands
This commit is contained in:
parent
75a37f3f7c
commit
1ea649f01e
167 changed files with 3351 additions and 3912 deletions
|
|
@ -27,15 +27,15 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
bool guestAccessLoading = false;
|
||||
Room get room => Matrix.of(context).client.getRoomById(widget.roomId)!;
|
||||
Set<Room> get knownSpaceParents => {
|
||||
...room.client.rooms.where(
|
||||
(space) =>
|
||||
space.isSpace &&
|
||||
space.spaceChildren.any((child) => child.roomId == room.id),
|
||||
),
|
||||
...room.spaceParents
|
||||
.map((parent) => room.client.getRoomById(parent.roomId ?? ''))
|
||||
.whereType<Room>(),
|
||||
};
|
||||
...room.client.rooms.where(
|
||||
(space) =>
|
||||
space.isSpace &&
|
||||
space.spaceChildren.any((child) => child.roomId == room.id),
|
||||
),
|
||||
...room.spaceParents
|
||||
.map((parent) => room.client.getRoomById(parent.roomId ?? ''))
|
||||
.whereType<Room>(),
|
||||
};
|
||||
|
||||
String get roomVersion =>
|
||||
room
|
||||
|
|
@ -87,21 +87,20 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
try {
|
||||
await room.setJoinRules(
|
||||
newJoinRules,
|
||||
allowConditionRoomIds: {JoinRules.restricted, JoinRules.knockRestricted}
|
||||
.contains(newJoinRules)
|
||||
allowConditionRoomIds:
|
||||
{
|
||||
JoinRules.restricted,
|
||||
JoinRules.knockRestricted,
|
||||
}.contains(newJoinRules)
|
||||
? knownSpaceParents.map((parent) => parent.id).toList()
|
||||
: null,
|
||||
);
|
||||
} catch (e, s) {
|
||||
Logs().w('Unable to change join rules', e, s);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
e.toLocalizedString(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
|
@ -123,13 +122,9 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
} catch (e, s) {
|
||||
Logs().w('Unable to change history visibility', e, s);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
e.toLocalizedString(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
|
@ -151,13 +146,9 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
} catch (e, s) {
|
||||
Logs().w('Unable to change guest access', e, s);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
e.toLocalizedString(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
|
@ -216,8 +207,11 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
newRoom = room.client.getRoomById(newRoomId);
|
||||
}
|
||||
|
||||
if ({JoinRules.invite, JoinRules.knock, JoinRules.knockRestricted}
|
||||
.contains(room.joinRules)) {
|
||||
if ({
|
||||
JoinRules.invite,
|
||||
JoinRules.knock,
|
||||
JoinRules.knockRestricted,
|
||||
}.contains(room.joinRules)) {
|
||||
final users = await room.requestParticipants([
|
||||
Membership.join,
|
||||
Membership.invite,
|
||||
|
|
@ -282,7 +276,8 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
cancelLabel: L10n.of(context).no,
|
||||
);
|
||||
|
||||
final altAliases = room
|
||||
final altAliases =
|
||||
room
|
||||
.getState(EventTypes.RoomCanonicalAlias)
|
||||
?.content
|
||||
.tryGetList<String>('alt_aliases')
|
||||
|
|
@ -298,17 +293,13 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client.setRoomStateWithKey(
|
||||
room.id,
|
||||
EventTypes.RoomCanonicalAlias,
|
||||
'',
|
||||
{
|
||||
'alias': canonicalAliasConsent == OkCancelResult.ok
|
||||
? alias
|
||||
: room.canonicalAlias,
|
||||
if (altAliases.isNotEmpty) 'alt_aliases': altAliases.toList(),
|
||||
},
|
||||
),
|
||||
future: () => room.client
|
||||
.setRoomStateWithKey(room.id, EventTypes.RoomCanonicalAlias, '', {
|
||||
'alias': canonicalAliasConsent == OkCancelResult.ok
|
||||
? alias
|
||||
: room.canonicalAlias,
|
||||
if (altAliases.isNotEmpty) 'alt_aliases': altAliases.toList(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -335,13 +326,9 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
} catch (e, s) {
|
||||
Logs().w('Unable to change visibility', e, s);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
e.toLocalizedString(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
|
|
|||
|
|
@ -24,17 +24,19 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
),
|
||||
body: MaxWidthBody(
|
||||
child: StreamBuilder<Object>(
|
||||
stream: room.client.onRoomState.stream
|
||||
.where((update) => update.roomId == controller.room.id),
|
||||
stream: room.client.onRoomState.stream.where(
|
||||
(update) => update.roomId == controller.room.id,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
final canonicalAlias = room.canonicalAlias;
|
||||
final altAliases = room
|
||||
final altAliases =
|
||||
room
|
||||
.getState(EventTypes.RoomCanonicalAlias)
|
||||
?.content
|
||||
.tryGetList<String>('alt_aliases') ??
|
||||
[];
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
|
|
@ -47,12 +49,13 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
),
|
||||
RadioGroup<HistoryVisibility>(
|
||||
groupValue: room.historyVisibility,
|
||||
onChanged: controller.historyVisibilityLoading ||
|
||||
onChanged:
|
||||
controller.historyVisibilityLoading ||
|
||||
!room.canChangeHistoryVisibility
|
||||
? (_) {}
|
||||
: controller.setHistoryVisibility,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
for (final historyVisibility in HistoryVisibility.values)
|
||||
RadioListTile<HistoryVisibility>.adaptive(
|
||||
|
|
@ -80,12 +83,13 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
groupValue: room.joinRules,
|
||||
onChanged: controller.setJoinRule,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
for (final joinRule in controller.availableJoinRules)
|
||||
if (joinRule != JoinRules.private)
|
||||
RadioListTile<JoinRules>.adaptive(
|
||||
enabled: !controller.joinRulesLoading &&
|
||||
enabled:
|
||||
!controller.joinRulesLoading &&
|
||||
room.canChangeJoinRules,
|
||||
title: Text(
|
||||
joinRule.localizedString(
|
||||
|
|
@ -99,8 +103,10 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
Divider(color: theme.dividerColor),
|
||||
if ({JoinRules.public, JoinRules.knock}
|
||||
.contains(room.joinRules)) ...[
|
||||
if ({
|
||||
JoinRules.public,
|
||||
JoinRules.knock,
|
||||
}.contains(room.joinRules)) ...[
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context).areGuestsAllowedToJoin,
|
||||
|
|
@ -114,11 +120,12 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
groupValue: room.guestAccess,
|
||||
onChanged: controller.setGuestAccess,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
for (final guestAccess in GuestAccess.values)
|
||||
RadioListTile<GuestAccess>.adaptive(
|
||||
enabled: !controller.guestAccessLoading &&
|
||||
enabled:
|
||||
!controller.guestAccessLoading &&
|
||||
room.canChangeGuestAccess,
|
||||
title: Text(
|
||||
guestAccess.getLocalizedString(
|
||||
|
|
@ -148,9 +155,10 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
if (canonicalAlias.isNotEmpty)
|
||||
_AliasListTile(
|
||||
alias: canonicalAlias,
|
||||
onDelete: room.canChangeStateEvent(
|
||||
EventTypes.RoomCanonicalAlias,
|
||||
)
|
||||
onDelete:
|
||||
room.canChangeStateEvent(
|
||||
EventTypes.RoomCanonicalAlias,
|
||||
)
|
||||
? () => controller.deleteAlias(canonicalAlias)
|
||||
: null,
|
||||
isCanonicalAlias: true,
|
||||
|
|
@ -158,9 +166,10 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
for (final alias in altAliases)
|
||||
_AliasListTile(
|
||||
alias: alias,
|
||||
onDelete: room.canChangeStateEvent(
|
||||
EventTypes.RoomCanonicalAlias,
|
||||
)
|
||||
onDelete:
|
||||
room.canChangeStateEvent(
|
||||
EventTypes.RoomCanonicalAlias,
|
||||
)
|
||||
? () => controller.deleteAlias(alias)
|
||||
: null,
|
||||
),
|
||||
|
|
@ -172,10 +181,11 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
return const SizedBox.shrink();
|
||||
}
|
||||
localAddresses.remove(room.canonicalAlias);
|
||||
localAddresses
|
||||
.removeWhere((alias) => altAliases.contains(alias));
|
||||
localAddresses.removeWhere(
|
||||
(alias) => altAliases.contains(alias),
|
||||
);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: localAddresses
|
||||
.map(
|
||||
(alias) => _AliasListTile(
|
||||
|
|
@ -257,10 +267,7 @@ class _AliasListTile extends StatelessWidget {
|
|||
? const Icon(Icons.star)
|
||||
: const Icon(Icons.link_outlined),
|
||||
title: InkWell(
|
||||
onTap: () => FluffyShare.share(
|
||||
'https://matrix.to/#/$alias',
|
||||
context,
|
||||
),
|
||||
onTap: () => FluffyShare.share('https://matrix.to/#/$alias', context),
|
||||
child: SelectableText(
|
||||
alias,
|
||||
style: TextStyle(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue