fluffychat merge
This commit is contained in:
commit
df802362ac
4 changed files with 85 additions and 87 deletions
|
|
@ -3369,6 +3369,8 @@
|
|||
"@moreEvents": {},
|
||||
"declineInvitation": "Noraidīt uzaicinājumu",
|
||||
"@declineInvitation": {},
|
||||
"noMessagesYet": "Vēl nav ziņu",
|
||||
"@noMessagesYet": {},
|
||||
"ignore": "Bloķēt",
|
||||
"ignoredUsers": "Bloķētie lietotāji",
|
||||
"writeAMessageLangCodes": "Rakstiet {l1} vai {l2}...",
|
||||
|
|
|
|||
|
|
@ -43,10 +43,27 @@ class SettingsIgnoreListController extends State<SettingsIgnoreList> {
|
|||
errorText = null;
|
||||
});
|
||||
|
||||
final client = Matrix.of(context).client;
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.ignoreUser(userId),
|
||||
future: () async {
|
||||
for (final room in client.rooms) {
|
||||
final isInviteFromUser = room.membership == Membership.invite &&
|
||||
room.getState(EventTypes.RoomMember, client.userID!)?.senderId ==
|
||||
userId;
|
||||
|
||||
if (room.directChatMatrixID == userId || isInviteFromUser) {
|
||||
try {
|
||||
await room.leave();
|
||||
} catch (e, s) {
|
||||
Logs().w('Unable to leave room with blocked user $userId', e, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
await client.ignoreUser(userId);
|
||||
},
|
||||
);
|
||||
setState(() {});
|
||||
controller.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
|
|
@ -26,87 +23,74 @@ class SettingsIgnoreListView extends StatelessWidget {
|
|||
),
|
||||
body: MaxWidthBody(
|
||||
withScrolling: false,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: controller.controller,
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => controller.ignoreUser(context),
|
||||
decoration: InputDecoration(
|
||||
errorText: controller.errorText,
|
||||
hintText: '@bad_guy:domain.abc',
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
labelText: L10n.of(context).blockUsername,
|
||||
suffixIcon: IconButton(
|
||||
tooltip: L10n.of(context).block,
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => controller.ignoreUser(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
L10n.of(context).blockListDescription,
|
||||
style: const TextStyle(color: Colors.orange),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: theme.dividerColor,
|
||||
),
|
||||
Expanded(
|
||||
child: StreamBuilder<Object>(
|
||||
stream: client.onSync.stream.where(
|
||||
(syncUpdate) =>
|
||||
syncUpdate.accountData?.any(
|
||||
(accountData) =>
|
||||
accountData.type == 'm.ignored_user_list',
|
||||
) ??
|
||||
false,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
return ListView.builder(
|
||||
itemCount: client.ignoredUsers.length,
|
||||
itemBuilder: (c, i) => FutureBuilder<Profile>(
|
||||
future:
|
||||
client.getProfileFromUserId(client.ignoredUsers[i]),
|
||||
builder: (c, s) => ListTile(
|
||||
leading: Avatar(
|
||||
mxContent: s.data?.avatarUrl ?? Uri.parse(''),
|
||||
name: s.data?.displayName ?? client.ignoredUsers[i],
|
||||
// #Pangea
|
||||
userId: s.data?.userId,
|
||||
// Pangea#
|
||||
),
|
||||
title: Text(
|
||||
s.data?.displayName ?? client.ignoredUsers[i],
|
||||
),
|
||||
subtitle:
|
||||
Text(s.data?.userId ?? client.ignoredUsers[i]),
|
||||
trailing: IconButton(
|
||||
tooltip: L10n.of(context).delete,
|
||||
icon: const Icon(Icons.delete_outlined),
|
||||
onPressed: () => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
client.unignoreUser(client.ignoredUsers[i]),
|
||||
child: StreamBuilder(
|
||||
stream: client.onSync.stream.where(
|
||||
(syncUpdate) =>
|
||||
syncUpdate.accountData?.any(
|
||||
(accountData) => accountData.type == 'm.ignored_user_list',
|
||||
) ??
|
||||
false,
|
||||
),
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (client.prevBatch == null) {
|
||||
return const Center(child: CircularProgressIndicator.adaptive());
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: controller.controller,
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => controller.ignoreUser(context),
|
||||
decoration: InputDecoration(
|
||||
errorText: controller.errorText,
|
||||
hintText: '@bad_guy:domain.abc',
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
labelText: L10n.of(context).blockUsername,
|
||||
suffixIcon: IconButton(
|
||||
tooltip: L10n.of(context).block,
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () => controller.ignoreUser(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
L10n.of(context).blockListDescription,
|
||||
style: const TextStyle(color: Colors.orange),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: theme.dividerColor,
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: client.ignoredUsers.length,
|
||||
itemBuilder: (c, i) => ListTile(
|
||||
title: Text(client.ignoredUsers[i]),
|
||||
trailing: IconButton(
|
||||
tooltip: L10n.of(context).delete,
|
||||
icon: const Icon(Icons.delete_outlined),
|
||||
onPressed: () => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () =>
|
||||
client.unignoreUser(client.ignoredUsers[i]),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -88,12 +88,7 @@ Future<MatrixSdkDatabase> _constructDatabase(String clientName) async {
|
|||
|
||||
Directory? fileStorageLocation;
|
||||
try {
|
||||
final tmpDir = await getTemporaryDirectory();
|
||||
final appTmpDir = Directory(join(tmpDir.path, clientName));
|
||||
if (!await appTmpDir.exists()) {
|
||||
await appTmpDir.create(recursive: true);
|
||||
}
|
||||
fileStorageLocation = appTmpDir;
|
||||
fileStorageLocation = await getTemporaryDirectory();
|
||||
} on MissingPlatformDirectoryException catch (_) {
|
||||
Logs().w(
|
||||
'No temporary directory for file cache available on this platform.',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue