kopia lustrzana https://gitlab.com/mysocialportal/relatica
Limit new DM thread creation to people the user follows or mutual (back end errors out if not connected)
rodzic
00cd377ae2
commit
adcb40baf4
|
@ -13,10 +13,12 @@ class MentionAutocompleteOptions extends ConsumerWidget {
|
|||
required this.id,
|
||||
required this.query,
|
||||
required this.onMentionUserTap,
|
||||
this.matchingStatus,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String query;
|
||||
final Set<ConnectionStatus>? matchingStatus;
|
||||
final ValueSetter<Connection> onMentionUserTap;
|
||||
|
||||
@override
|
||||
|
@ -25,13 +27,17 @@ class MentionAutocompleteOptions extends ConsumerWidget {
|
|||
final postTreeUsers = ref
|
||||
.watch(postTreeConnectionIdsProvider(profile, id))
|
||||
.getValueOrElse(() => [])
|
||||
.map((id) => ref.watch(connectionByIdProvider(profile, id)))
|
||||
.map((id) => ref.read(connectionByIdProvider(profile, id)))
|
||||
.where((result) => result.isSuccess)
|
||||
.map((result) => result.value)
|
||||
.toList()
|
||||
..sort((u1, u2) => u1.name.compareTo(u2.name));
|
||||
|
||||
final knownUsers = ref.watch(knownUsersByNameProvider(profile, query));
|
||||
final knownUsers = ref.watch(knownUsersByNameProvider(
|
||||
profile,
|
||||
query,
|
||||
matchingStatus: matchingStatus,
|
||||
));
|
||||
|
||||
final users = [...postTreeUsers, ...knownUsers];
|
||||
|
||||
|
|
|
@ -41,7 +41,10 @@ Result<List<String>, ExecError> postTreeConnectionIds(
|
|||
_ptcLogger.info('Building for $id for $profile');
|
||||
ref.cacheFor(_cacheDuration);
|
||||
return ref
|
||||
.watch(postTreeEntryByIdProvider(profile, id))
|
||||
.watch(postTreeEntryByIdProvider(
|
||||
profile,
|
||||
id,
|
||||
))
|
||||
.transform(
|
||||
(entryTreeItem) => entryTreeItem
|
||||
.flatten(ref: ref, profile: profile)
|
||||
|
|
|
@ -71,9 +71,19 @@ Future<bool> connectionRepoInit(Ref ref, Profile profile) async {
|
|||
}
|
||||
|
||||
@riverpod
|
||||
List<Connection> knownUsersByName(Ref ref, Profile profile, String userName) {
|
||||
List<Connection> knownUsersByName(Ref ref, Profile profile, String userName,
|
||||
{Set<ConnectionStatus>? matchingStatus}) {
|
||||
return ref.watch(_connectionsRepoSyncProvider(profile)).fold(
|
||||
onSuccess: (repo) => repo.getKnownUsersByName(userName),
|
||||
onSuccess: (repo) {
|
||||
final knownUsers = repo.getKnownUsersByName(userName);
|
||||
if (matchingStatus == null) {
|
||||
return knownUsers;
|
||||
}
|
||||
|
||||
return knownUsers
|
||||
.where((u) => matchingStatus.contains(u.status))
|
||||
.toList();
|
||||
},
|
||||
onError: (_) => []);
|
||||
}
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ class _ConnectionRepoInitProviderElement
|
|||
Profile get profile => (origin as ConnectionRepoInitProvider).profile;
|
||||
}
|
||||
|
||||
String _$knownUsersByNameHash() => r'564fbbf69fcc62f0c18c8ec98e8a0382df95f8a3';
|
||||
String _$knownUsersByNameHash() => r'89ebe37e2257f9124b614b3aeddc81213ec41475';
|
||||
|
||||
/// See also [knownUsersByName].
|
||||
@ProviderFor(knownUsersByName)
|
||||
|
@ -302,11 +302,13 @@ class KnownUsersByNameFamily extends Family<List<Connection>> {
|
|||
/// See also [knownUsersByName].
|
||||
KnownUsersByNameProvider call(
|
||||
Profile profile,
|
||||
String userName,
|
||||
) {
|
||||
String userName, {
|
||||
Set<ConnectionStatus>? matchingStatus,
|
||||
}) {
|
||||
return KnownUsersByNameProvider(
|
||||
profile,
|
||||
userName,
|
||||
matchingStatus: matchingStatus,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -317,6 +319,7 @@ class KnownUsersByNameFamily extends Family<List<Connection>> {
|
|||
return call(
|
||||
provider.profile,
|
||||
provider.userName,
|
||||
matchingStatus: provider.matchingStatus,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -340,12 +343,14 @@ class KnownUsersByNameProvider extends AutoDisposeProvider<List<Connection>> {
|
|||
/// See also [knownUsersByName].
|
||||
KnownUsersByNameProvider(
|
||||
Profile profile,
|
||||
String userName,
|
||||
) : this._internal(
|
||||
String userName, {
|
||||
Set<ConnectionStatus>? matchingStatus,
|
||||
}) : this._internal(
|
||||
(ref) => knownUsersByName(
|
||||
ref as KnownUsersByNameRef,
|
||||
profile,
|
||||
userName,
|
||||
matchingStatus: matchingStatus,
|
||||
),
|
||||
from: knownUsersByNameProvider,
|
||||
name: r'knownUsersByNameProvider',
|
||||
|
@ -358,6 +363,7 @@ class KnownUsersByNameProvider extends AutoDisposeProvider<List<Connection>> {
|
|||
KnownUsersByNameFamily._allTransitiveDependencies,
|
||||
profile: profile,
|
||||
userName: userName,
|
||||
matchingStatus: matchingStatus,
|
||||
);
|
||||
|
||||
KnownUsersByNameProvider._internal(
|
||||
|
@ -369,10 +375,12 @@ class KnownUsersByNameProvider extends AutoDisposeProvider<List<Connection>> {
|
|||
required super.from,
|
||||
required this.profile,
|
||||
required this.userName,
|
||||
required this.matchingStatus,
|
||||
}) : super.internal();
|
||||
|
||||
final Profile profile;
|
||||
final String userName;
|
||||
final Set<ConnectionStatus>? matchingStatus;
|
||||
|
||||
@override
|
||||
Override overrideWith(
|
||||
|
@ -389,6 +397,7 @@ class KnownUsersByNameProvider extends AutoDisposeProvider<List<Connection>> {
|
|||
debugGetCreateSourceHash: null,
|
||||
profile: profile,
|
||||
userName: userName,
|
||||
matchingStatus: matchingStatus,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -402,7 +411,8 @@ class KnownUsersByNameProvider extends AutoDisposeProvider<List<Connection>> {
|
|||
bool operator ==(Object other) {
|
||||
return other is KnownUsersByNameProvider &&
|
||||
other.profile == profile &&
|
||||
other.userName == userName;
|
||||
other.userName == userName &&
|
||||
other.matchingStatus == matchingStatus;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -410,6 +420,7 @@ class KnownUsersByNameProvider extends AutoDisposeProvider<List<Connection>> {
|
|||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, profile.hashCode);
|
||||
hash = _SystemHash.combine(hash, userName.hashCode);
|
||||
hash = _SystemHash.combine(hash, matchingStatus.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
|
@ -423,6 +434,9 @@ mixin KnownUsersByNameRef on AutoDisposeProviderRef<List<Connection>> {
|
|||
|
||||
/// The parameter `userName` of this provider.
|
||||
String get userName;
|
||||
|
||||
/// The parameter `matchingStatus` of this provider.
|
||||
Set<ConnectionStatus>? get matchingStatus;
|
||||
}
|
||||
|
||||
class _KnownUsersByNameProviderElement
|
||||
|
@ -434,6 +448,9 @@ class _KnownUsersByNameProviderElement
|
|||
Profile get profile => (origin as KnownUsersByNameProvider).profile;
|
||||
@override
|
||||
String get userName => (origin as KnownUsersByNameProvider).userName;
|
||||
@override
|
||||
Set<ConnectionStatus>? get matchingStatus =>
|
||||
(origin as KnownUsersByNameProvider).matchingStatus;
|
||||
}
|
||||
|
||||
String _$myContactsHash() => r'd627cbc98c66e636fdf057ef7d946b5b0248d2a9';
|
||||
|
|
|
@ -495,7 +495,7 @@ class _CreateCircleProviderElement extends AutoDisposeFutureProviderElement<
|
|||
String get title => (origin as CreateCircleProvider).title;
|
||||
}
|
||||
|
||||
String _$renameCircleHash() => r'4bb3b90fc0dc47b59a1154e55857ec21b98fa622';
|
||||
String _$renameCircleHash() => r'aee93f520a0021c8eb2e17d1ec0d7142b204abcd';
|
||||
|
||||
/// See also [renameCircle].
|
||||
@ProviderFor(renameCircle)
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:multi_trigger_autocomplete/multi_trigger_autocomplete.dart';
|
|||
import '../controls/autocomplete/mention_autocomplete_options.dart';
|
||||
import '../controls/padding.dart';
|
||||
import '../controls/standard_appbar.dart';
|
||||
import '../models/connection.dart';
|
||||
import '../riverpod_controllers/account_services.dart';
|
||||
import '../riverpod_controllers/connection_manager_services.dart';
|
||||
import '../riverpod_controllers/direct_message_services.dart';
|
||||
|
@ -52,6 +53,10 @@ class MessagesNewThread extends ConsumerWidget {
|
|||
return MentionAutocompleteOptions(
|
||||
id: '',
|
||||
query: autocompleteQuery.query,
|
||||
matchingStatus: const {
|
||||
ConnectionStatus.mutual,
|
||||
ConnectionStatus.youFollowThem
|
||||
},
|
||||
onMentionUserTap: (user) {
|
||||
final autocomplete =
|
||||
MultiTriggerAutocomplete.of(context);
|
||||
|
|
Ładowanie…
Reference in New Issue