forked from Nexus/nexus
treewide sweepfixes
This commit is contained in:
parent
8fda43ccf8
commit
012ecd9249
41 changed files with 270 additions and 386 deletions
|
|
@ -23,7 +23,7 @@ class AttachmentController(final String roomId)
|
||||||
);
|
);
|
||||||
|
|
||||||
final content = await ref
|
final content = await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.uploadMedia(.new(path: file.path, encrypt: isEncrypted));
|
.uploadMedia(.new(path: file.path, encrypt: isEncrypted));
|
||||||
|
|
||||||
state = (filename, content);
|
state = (filename, content);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class AuthUrlController(final Uri homeserver)
|
||||||
extends AsyncNotifier<OAuthAuthCodeResponse> {
|
extends AsyncNotifier<OAuthAuthCodeResponse> {
|
||||||
@override
|
@override
|
||||||
Future<OAuthAuthCodeResponse> build() async => ref
|
Future<OAuthAuthCodeResponse> build() async => ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.getAuthUrl(
|
.getAuthUrl(
|
||||||
.new(
|
.new(
|
||||||
homeserverUrl: homeserver,
|
homeserverUrl: homeserver,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import "package:nexus/controllers/client.dart";
|
||||||
class ClientIdController(final Uri homeserver) extends AsyncNotifier<String> {
|
class ClientIdController(final Uri homeserver) extends AsyncNotifier<String> {
|
||||||
@override
|
@override
|
||||||
Future<String> build() => ref
|
Future<String> build() => ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.registerClient(
|
.registerClient(
|
||||||
.new(
|
.new(
|
||||||
clientName: "Nexus",
|
clientName: "Nexus",
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ class EventController(final GetEventRequest request)
|
||||||
if (event != null) return event;
|
if (event != null) return event;
|
||||||
|
|
||||||
final fetchedEvent = await ref
|
final fetchedEvent = await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.getEvent(request)
|
.getEvent(request)
|
||||||
.onError((_, _) => null);
|
.onError((_, _) => null);
|
||||||
|
|
||||||
if (fetchedEvent != null) {
|
if (fetchedEvent != null) {
|
||||||
ref
|
ref
|
||||||
.watch(RoomsController.provider.notifier)
|
.read(RoomsController.provider.notifier)
|
||||||
.update(
|
.update(
|
||||||
.new({
|
.new({
|
||||||
request.roomId: .new(
|
request.roomId: .new(
|
||||||
|
|
|
||||||
|
|
@ -40,28 +40,23 @@ class GomuksListenerController extends AsyncNotifier<void> {
|
||||||
switch (muksEventType) {
|
switch (muksEventType) {
|
||||||
case "client_state":
|
case "client_state":
|
||||||
ref
|
ref
|
||||||
.watch(ClientStateController.provider.notifier)
|
.read(ClientStateController.provider.notifier)
|
||||||
.set(.fromJson(decodedMuksEvent));
|
.set(.fromJson(decodedMuksEvent));
|
||||||
break;
|
|
||||||
case "sync_status":
|
case "sync_status":
|
||||||
ref
|
ref
|
||||||
.watch(SyncStatusController.provider.notifier)
|
.read(SyncStatusController.provider.notifier)
|
||||||
.set(.fromJson(decodedMuksEvent));
|
.set(.fromJson(decodedMuksEvent));
|
||||||
break;
|
|
||||||
case "init_complete":
|
case "init_complete":
|
||||||
ref.watch(InitCompleteController.provider.notifier).complete();
|
ref.read(InitCompleteController.provider.notifier).complete();
|
||||||
break;
|
|
||||||
case "send_complete":
|
case "send_complete":
|
||||||
final event = Event.fromJson(decodedMuksEvent["event"]);
|
final event = Event.fromJson(decodedMuksEvent["event"]);
|
||||||
ref
|
ref
|
||||||
.watch(RoomsController.provider.notifier)
|
.read(RoomsController.provider.notifier)
|
||||||
.update(
|
.update(
|
||||||
.new({
|
.new({
|
||||||
event.roomId: .new(events: .new({event.rowId: event})),
|
event.roomId: .new(events: .new({event.rowId: event})),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
|
||||||
case "sync_complete":
|
case "sync_complete":
|
||||||
final syncData = SyncData.fromJson(decodedMuksEvent);
|
final syncData = SyncData.fromJson(decodedMuksEvent);
|
||||||
final roomProvider = RoomsController.provider;
|
final roomProvider = RoomsController.provider;
|
||||||
|
|
@ -73,28 +68,27 @@ class GomuksListenerController extends AsyncNotifier<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ref
|
ref
|
||||||
.watch(roomProvider.notifier)
|
.read(roomProvider.notifier)
|
||||||
.update(syncData.rooms, syncData.leftRooms);
|
.update(syncData.rooms, syncData.leftRooms);
|
||||||
ref
|
ref
|
||||||
.watch(accountDataProvider.notifier)
|
.read(accountDataProvider.notifier)
|
||||||
.update(syncData.accountData);
|
.update(syncData.accountData);
|
||||||
|
|
||||||
if (syncData.topLevelSpaces != null) {
|
if (syncData.topLevelSpaces case final topLevelSpaces?) {
|
||||||
ref
|
ref
|
||||||
.watch(TopLevelSpacesController.provider.notifier)
|
.read(TopLevelSpacesController.provider.notifier)
|
||||||
.set(syncData.topLevelSpaces!);
|
.set(topLevelSpaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (syncData.spaceEdges != null) {
|
if (syncData.spaceEdges case final spaceEdges?) {
|
||||||
ref
|
ref
|
||||||
.watch(SpaceEdgesController.provider.notifier)
|
.read(SpaceEdgesController.provider.notifier)
|
||||||
.set(syncData.spaceEdges!);
|
.set(spaceEdges);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ref
|
// ref
|
||||||
// .watch(SyncStatusController.provider.notifier)
|
// .read(SyncStatusController.provider.notifier)
|
||||||
// .set(SyncStatus.fromJson(decodedMuksEvent));
|
// .set(SyncStatus.fromJson(decodedMuksEvent));
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
debugPrint("Unhandled event: $muksEventType");
|
debugPrint("Unhandled event: $muksEventType");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class KeyController(final String key) extends AsyncNotifier<String?> {
|
||||||
ref.watch(SharedPrefsController.provider).getString(key);
|
ref.watch(SharedPrefsController.provider).getString(key);
|
||||||
|
|
||||||
Future<void> set(String? value) async {
|
Future<void> set(String? value) async {
|
||||||
final prefs = ref.watch(SharedPrefsController.provider);
|
final prefs = ref.read(SharedPrefsController.provider);
|
||||||
state = .data(value);
|
state = .data(value);
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class MemberListOpenedController extends AsyncNotifier<bool> {
|
||||||
|
|
||||||
Future<void> set(bool value) async {
|
Future<void> set(bool value) async {
|
||||||
state = .data(value);
|
state = .data(value);
|
||||||
await ref.watch(SharedPrefsController.provider).setBool(key, value);
|
await ref.read(SharedPrefsController.provider).setBool(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final provider =
|
static final provider =
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class MembersController(final String roomId)
|
||||||
|
|
||||||
if (!room.hasFetchedMembers) {
|
if (!room.hasFetchedMembers) {
|
||||||
final fetchedState = await ref
|
final fetchedState = await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.getRoomState(
|
.getRoomState(
|
||||||
GetRoomStateRequest(
|
GetRoomStateRequest(
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class NotificationsController(final NotificationsRequest request)
|
||||||
final lastNotification = currentNotifications.lastOrNull;
|
final lastNotification = currentNotifications.lastOrNull;
|
||||||
final lastTs = lastNotification == null
|
final lastTs = lastNotification == null
|
||||||
? null
|
? null
|
||||||
: ref.watch(
|
: ref.read(
|
||||||
RoomsController.provider.select(
|
RoomsController.provider.select(
|
||||||
(rooms) => rooms[lastNotification.$2]
|
(rooms) => rooms[lastNotification.$2]
|
||||||
?.events[lastNotification.$1]
|
?.events[lastNotification.$1]
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ class PushKeyController(final String instance) extends AsyncNotifier<String?> {
|
||||||
|
|
||||||
Future<void> set(String? value) async {
|
Future<void> set(String? value) async {
|
||||||
final provider = KeyController.provider(KeyController.pushKeyKey);
|
final provider = KeyController.provider(KeyController.pushKeyKey);
|
||||||
final notifier = ref.watch(provider.notifier);
|
final notifier = ref.read(provider.notifier);
|
||||||
final prefs = IMap(json.decode(await ref.watch(provider.future) ?? "{}"));
|
final prefs = IMap(json.decode(await ref.read(provider.future) ?? "{}"));
|
||||||
|
|
||||||
state = .data(value);
|
state = .data(value);
|
||||||
notifier.set(
|
notifier.set(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class ReactionsController(final ReactionsConfig config)
|
||||||
|
|
||||||
final reactionEvents = eventInfo?.$2.isNotEmpty == true
|
final reactionEvents = eventInfo?.$2.isNotEmpty == true
|
||||||
? await ref
|
? await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.getRelatedEvents(
|
.getRelatedEvents(
|
||||||
.new(
|
.new(
|
||||||
roomId: config.roomId,
|
roomId: config.roomId,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class RecentEmojiController extends Notifier<IList<RecentEmoji>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> add(String emoji) => ref
|
Future<void> add(String emoji) => ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.setAccountData(
|
.setAccountData(
|
||||||
.new(
|
.new(
|
||||||
type: AccountData.recentEmojiKey,
|
type: AccountData.recentEmojiKey,
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class RoomChatController(final ChatParams info)
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteMessage(Event event, {String? reason}) => ref
|
Future<void> deleteMessage(Event event, {String? reason}) => ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.redactEvent(
|
.redactEvent(
|
||||||
RedactEventRequest(
|
RedactEventRequest(
|
||||||
eventId: event.eventId,
|
eventId: event.eventId,
|
||||||
|
|
@ -146,7 +146,7 @@ class RoomChatController(final ChatParams info)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.events.isEmpty) {
|
if (response.events.isEmpty) {
|
||||||
state = .data(state.value);
|
state = .data(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
ref
|
ref
|
||||||
|
|
@ -234,7 +234,7 @@ class RoomChatController(final ChatParams info)
|
||||||
Content? baseContent;
|
Content? baseContent;
|
||||||
final relatedEvent = relatedEventRowId == null
|
final relatedEvent = relatedEventRowId == null
|
||||||
? null
|
? null
|
||||||
: ref.watch(
|
: ref.read(
|
||||||
RoomsController.provider.select(
|
RoomsController.provider.select(
|
||||||
(rooms) => rooms[info.roomId]?.events[relatedEventRowId],
|
(rooms) => rooms[info.roomId]?.events[relatedEventRowId],
|
||||||
),
|
),
|
||||||
|
|
@ -267,9 +267,7 @@ class RoomChatController(final ChatParams info)
|
||||||
baseContent: baseContent,
|
baseContent: baseContent,
|
||||||
mentions: Mentions(
|
mentions: Mentions(
|
||||||
userIds: [
|
userIds: [
|
||||||
if (shouldMention == true &&
|
if (shouldMention && relatedEvent != null && relationType == .reply)
|
||||||
relatedEvent != null &&
|
|
||||||
relationType == RelationType.reply)
|
|
||||||
relatedEvent.sender,
|
relatedEvent.sender,
|
||||||
].toIList(),
|
].toIList(),
|
||||||
room: taggedMessage.contains("@room"),
|
room: taggedMessage.contains("@room"),
|
||||||
|
|
@ -307,12 +305,10 @@ class RoomChatController(final ChatParams info)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final reactionEvents = allReactionEvents
|
final reactionEvent = allReactionEvents?.firstWhereOrNull(
|
||||||
?.where((event) => event.redactedBy == null)
|
(event) =>
|
||||||
.toIList();
|
event.redactedBy == null &&
|
||||||
|
switch (event.content) {
|
||||||
final reactionEvent = reactionEvents?.firstWhereOrNull(
|
|
||||||
(event) => switch (event.content) {
|
|
||||||
ReactionContent(:final key) =>
|
ReactionContent(:final key) =>
|
||||||
key == reaction && event.sender == userId,
|
key == reaction && event.sender == userId,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
@ -320,9 +316,7 @@ class RoomChatController(final ChatParams info)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (reactionEvent != null) {
|
if (reactionEvent != null) {
|
||||||
await ref
|
await client.redactEvent(
|
||||||
.watch(ClientController.provider.notifier)
|
|
||||||
.redactEvent(
|
|
||||||
.new(eventId: reactionEvent.eventId, roomId: info.roomId),
|
.new(eventId: reactionEvent.eventId, roomId: info.roomId),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class RoomsController extends Notifier<IMap<String, Room>> {
|
||||||
hasMore: incoming.hasMore,
|
hasMore: incoming.hasMore,
|
||||||
clientSticky: incoming.resetClientSticky
|
clientSticky: incoming.resetClientSticky
|
||||||
? incoming.clientSticky
|
? incoming.clientSticky
|
||||||
: (incoming.clientSticky.isEmpty == true
|
: (incoming.clientSticky.isEmpty
|
||||||
? existing.clientSticky
|
? existing.clientSticky
|
||||||
: existing.clientSticky.addAll(
|
: existing.clientSticky.addAll(
|
||||||
incoming.clientSticky,
|
incoming.clientSticky,
|
||||||
|
|
@ -73,9 +73,9 @@ class RoomsController extends Notifier<IMap<String, Room>> {
|
||||||
incoming.hasFetchedMembers || existing.hasFetchedMembers,
|
incoming.hasFetchedMembers || existing.hasFetchedMembers,
|
||||||
hasFetchedState:
|
hasFetchedState:
|
||||||
incoming.hasFetchedState || existing.hasFetchedState,
|
incoming.hasFetchedState || existing.hasFetchedState,
|
||||||
timeline: (incoming.reset
|
timeline: incoming.reset
|
||||||
? incoming.timeline
|
? incoming.timeline
|
||||||
: existing.timeline.addAll(incoming.timeline)),
|
: existing.timeline.addAll(incoming.timeline),
|
||||||
receipts: incoming.receipts.entries.fold(
|
receipts: incoming.receipts.entries.fold(
|
||||||
existing.receipts,
|
existing.receipts,
|
||||||
(receiptAcc, event) => receiptAcc.add(
|
(receiptAcc, event) => receiptAcc.add(
|
||||||
|
|
@ -88,12 +88,7 @@ class RoomsController extends Notifier<IMap<String, Room>> {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
final prunedList = leftRooms.fold(
|
state = leftRooms.fold(merged, (acc, roomId) => acc.remove(roomId));
|
||||||
merged,
|
|
||||||
(acc, roomId) => acc.remove(roomId),
|
|
||||||
);
|
|
||||||
|
|
||||||
state = prunedList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static final provider = NotifierProvider<RoomsController, IMap<String, Room>>(
|
static final provider = NotifierProvider<RoomsController, IMap<String, Room>>(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import "dart:convert";
|
import "dart:convert";
|
||||||
|
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/settings_file.dart";
|
import "package:nexus/controllers/settings_file.dart";
|
||||||
import "package:nexus/models/settings.dart";
|
import "package:nexus/models/settings.dart";
|
||||||
|
|
@ -17,7 +18,7 @@ class SettingsController extends AsyncNotifier<Settings> {
|
||||||
|
|
||||||
Future<void> set(Settings settings) async {
|
Future<void> set(Settings settings) async {
|
||||||
state = .data(settings);
|
state = .data(settings);
|
||||||
final file = await ref.watch(SettingsFileController.provider.future);
|
final file = await ref.read(SettingsFileController.provider.future);
|
||||||
await file.writeAsString(json.encode(settings.toJson()));
|
await file.writeAsString(json.encode(settings.toJson()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
|
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:path/path.dart";
|
import "package:path/path.dart";
|
||||||
import "package:path_provider/path_provider.dart";
|
import "package:path_provider/path_provider.dart";
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class SettingsSectionsController
|
||||||
options: ThemeMode.values,
|
options: ThemeMode.values,
|
||||||
getName: (option) => toBeginningOfSentenceCase(option.name),
|
getName: (option) => toBeginningOfSentenceCase(option.name),
|
||||||
onChanged: (value) => ref
|
onChanged: (value) => ref
|
||||||
.watch(SettingsController.provider.notifier)
|
.read(SettingsController.provider.notifier)
|
||||||
.set(settings.copyWith(theme: value))
|
.set(settings.copyWith(theme: value))
|
||||||
.onError(showError),
|
.onError(showError),
|
||||||
),
|
),
|
||||||
|
|
@ -67,7 +67,7 @@ class SettingsSectionsController
|
||||||
Platform.isMacOS ||
|
Platform.isMacOS ||
|
||||||
Platform.isWindows)
|
Platform.isWindows)
|
||||||
? (value) => ref
|
? (value) => ref
|
||||||
.watch(SettingsController.provider.notifier)
|
.read(SettingsController.provider.notifier)
|
||||||
.set(settings.copyWith(useDynamicTheming: value))
|
.set(settings.copyWith(useDynamicTheming: value))
|
||||||
.onError(showError)
|
.onError(showError)
|
||||||
: null,
|
: null,
|
||||||
|
|
@ -89,7 +89,7 @@ class SettingsSectionsController
|
||||||
secondary: Icon(icon),
|
secondary: Icon(icon),
|
||||||
value: settings.showAllInHome,
|
value: settings.showAllInHome,
|
||||||
onChanged: (value) => ref
|
onChanged: (value) => ref
|
||||||
.watch(SettingsController.provider.notifier)
|
.read(SettingsController.provider.notifier)
|
||||||
.set(settings.copyWith(showAllInHome: value))
|
.set(settings.copyWith(showAllInHome: value))
|
||||||
.onError(showError),
|
.onError(showError),
|
||||||
),
|
),
|
||||||
|
|
@ -106,7 +106,7 @@ class SettingsSectionsController
|
||||||
secondary: Icon(icon),
|
secondary: Icon(icon),
|
||||||
value: settings.showMinimizeButton,
|
value: settings.showMinimizeButton,
|
||||||
onChanged: (value) => ref
|
onChanged: (value) => ref
|
||||||
.watch(SettingsController.provider.notifier)
|
.read(SettingsController.provider.notifier)
|
||||||
.set(settings.copyWith(showMinimizeButton: value))
|
.set(settings.copyWith(showMinimizeButton: value))
|
||||||
.onError(showError),
|
.onError(showError),
|
||||||
),
|
),
|
||||||
|
|
@ -122,7 +122,7 @@ class SettingsSectionsController
|
||||||
value: settings.linuxMobileMode,
|
value: settings.linuxMobileMode,
|
||||||
onChanged: Platform.isLinux
|
onChanged: Platform.isLinux
|
||||||
? (value) => ref
|
? (value) => ref
|
||||||
.watch(SettingsController.provider.notifier)
|
.read(SettingsController.provider.notifier)
|
||||||
.set(settings.copyWith(linuxMobileMode: value))
|
.set(settings.copyWith(linuxMobileMode: value))
|
||||||
.onError(showError)
|
.onError(showError)
|
||||||
: null,
|
: null,
|
||||||
|
|
@ -190,14 +190,14 @@ class SettingsSectionsController
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (await ref
|
if (await ref
|
||||||
.watch(
|
.read(
|
||||||
NotificationController
|
NotificationController
|
||||||
.provider
|
.provider
|
||||||
.notifier,
|
.notifier,
|
||||||
)
|
)
|
||||||
.requestPermissions()) {
|
.requestPermissions()) {
|
||||||
await ref
|
await ref
|
||||||
.watch(
|
.read(
|
||||||
UnifiedPushController
|
UnifiedPushController
|
||||||
.provider
|
.provider
|
||||||
.notifier,
|
.notifier,
|
||||||
|
|
@ -208,7 +208,7 @@ class SettingsSectionsController
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await ref
|
await ref
|
||||||
.watch(
|
.read(
|
||||||
UnifiedPushController
|
UnifiedPushController
|
||||||
.provider
|
.provider
|
||||||
.notifier,
|
.notifier,
|
||||||
|
|
@ -268,7 +268,7 @@ class SettingsSectionsController
|
||||||
onChanged: specVersionsResponse.maybeWhen(
|
onChanged: specVersionsResponse.maybeWhen(
|
||||||
data: (_) =>
|
data: (_) =>
|
||||||
(value) => ref
|
(value) => ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.setAccountData(
|
.setAccountData(
|
||||||
.new(
|
.new(
|
||||||
type: AccountData.invitePermissionConfigKey,
|
type: AccountData.invitePermissionConfigKey,
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ class SpacesController extends AsyncNotifier<IList<Space>> {
|
||||||
final spaceEdges = ref.watch(SpaceEdgesController.provider);
|
final spaceEdges = ref.watch(SpaceEdgesController.provider);
|
||||||
final accountData = ref.watch(AccountDataController.provider);
|
final accountData = ref.watch(AccountDataController.provider);
|
||||||
|
|
||||||
final childrenById = {
|
final childrenById = spaceEdges.map(
|
||||||
for (final entry in spaceEdges.entries)
|
(spaceId, edges) =>
|
||||||
entry.key: entry.value.map((e) => e.childId).toList(),
|
MapEntry(spaceId, edges.map((edge) => edge.childId).toList()),
|
||||||
};
|
);
|
||||||
|
|
||||||
Set<String> collectDescendants(String startId) {
|
Set<String> collectDescendants(String startId) {
|
||||||
final visited = <String>{};
|
final visited = <String>{};
|
||||||
|
|
@ -78,21 +78,22 @@ class SpacesController extends AsyncNotifier<IList<Space>> {
|
||||||
|
|
||||||
final spaces = topLevelSpaceIds.map(buildSpace).toIList();
|
final spaces = topLevelSpaceIds.map(buildSpace).toIList();
|
||||||
|
|
||||||
final usedRooms = {
|
final usedRooms = spaces
|
||||||
for (final space in spaces) ...[
|
.expand(
|
||||||
|
(space) => [
|
||||||
...space.children,
|
...space.children,
|
||||||
...space.subSpaces.expand((s) => s.children),
|
...space.subSpaces.expand((s) => s.children),
|
||||||
],
|
],
|
||||||
}.nonNulls.toISet();
|
)
|
||||||
|
.toISet();
|
||||||
|
final usedRoomIds = usedRooms.map((room) => room.metadata?.id).toSet();
|
||||||
|
|
||||||
final directMessages = accountData.directMessages.values.flattened;
|
final directMessages = accountData.directMessages.values.flattened.toSet();
|
||||||
|
|
||||||
final otherRooms = rooms.entries
|
final otherRooms = rooms.entries
|
||||||
.where(
|
.where(
|
||||||
(e) =>
|
(e) =>
|
||||||
!usedRooms
|
!usedRoomIds.contains(e.key) &&
|
||||||
.map((element) => element.metadata?.id)
|
|
||||||
.contains(e.key) &&
|
|
||||||
!topLevelSpaceIds.contains(e.key) &&
|
!topLevelSpaceIds.contains(e.key) &&
|
||||||
!childrenById.containsKey(e.key),
|
!childrenById.containsKey(e.key),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class UnifiedPushAllowedController extends AsyncNotifier<String?> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final capabilities = await ref
|
final capabilities = await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.getCapabilities();
|
.getCapabilities();
|
||||||
|
|
||||||
if (capabilities.webpush?.vapid == null) {
|
if (capabilities.webpush?.vapid == null) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class UrlPreviewController(final Uri url)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await ref
|
return await ref
|
||||||
.watch(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.getUrlPreview(url);
|
.getUrlPreview(url);
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
debugPrintStack(label: error.toString(), stackTrace: stackTrace);
|
debugPrintStack(label: error.toString(), stackTrace: stackTrace);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue