Make AuthService.currentClient a non-Result type

codemagic-setup
Hank Grabowski 2023-02-24 15:56:39 -05:00
rodzic dc0b7e7bfc
commit a0dc28234b
11 zmienionych plików z 100 dodań i 235 usunięć

Wyświetl plik

@ -53,7 +53,6 @@ Future<void> dependencyInjectionInitialization() async {
() => MediaUploadAttachmentHelper());
getIt.registerLazySingleton<NotificationsManager>(
() => NotificationsManager());
galleryService.getGalleries();
getIt.registerLazySingleton<DirectMessageService>(
() => DirectMessageService());
getIt.registerLazySingleton<NetworkStatusService>(

Wyświetl plik

@ -44,10 +44,8 @@ class _ImageViewerScreenState extends State<ImageViewerScreen> {
buildSnackbar(context, 'Downloading full image to save locally');
final appsDir = await getApplicationDocumentsDirectory();
final filename = p.basename(attachment.fullFileUri.path);
final bytesResult = await getIt<AuthService>()
.currentClient
.value
.getFileBytes(attachment.uri);
final bytesResult =
await getIt<AuthService>().currentClient.getFileBytes(attachment.uri);
if (bytesResult.isFailure && mounted) {
buildSnackbar(context,
'Error getting full size version of file: ${bytesResult.error}');

Wyświetl plik

@ -21,8 +21,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Profile: ${authService.currentClient.fold(onSuccess: (client) => client.credentials.handle, onError: (error) => 'Error Getting Profile')}'),
Text('Profile: ${authService.currentClient.credentials.handle}'),
],
),
),

Wyświetl plik

@ -13,19 +13,10 @@ class AuthService extends ChangeNotifier {
FriendicaClient? _friendicaClient;
bool _loggedIn = false;
Result<FriendicaClient, ExecError> get currentClient {
if (_friendicaClient == null) {
return Result.error(ExecError(
type: ErrorType.authentication,
message: 'Not logged in',
));
}
return Result.ok(_friendicaClient!);
}
bool get loggedIn => _loggedIn && _friendicaClient != null;
FriendicaClient get currentClient => _friendicaClient!;
String get currentId => _friendicaClient?.credentials.userId ?? '';
String get currentHandle => _friendicaClient?.credentials.handle ?? '';

Wyświetl plik

@ -43,10 +43,7 @@ class ConnectionsManager extends ChangeNotifier {
Future<void> acceptFollowRequest(Connection connection) async {
_logger.finest(
'Attempting to accept follow request ${connection.name}: ${connection.status}');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.acceptFollow(connection))
.match(
await getIt<AuthService>().currentClient.acceptFollow(connection).match(
onSuccess: (update) {
_logger
.finest('Successfully followed ${update.name}: ${update.status}');
@ -62,10 +59,7 @@ class ConnectionsManager extends ChangeNotifier {
Future<void> rejectFollowRequest(Connection connection) async {
_logger.finest(
'Attempting to accept follow request ${connection.name}: ${connection.status}');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.rejectFollow(connection))
.match(
await getIt<AuthService>().currentClient.rejectFollow(connection).match(
onSuccess: (update) {
_logger
.finest('Successfully followed ${update.name}: ${update.status}');
@ -81,10 +75,7 @@ class ConnectionsManager extends ChangeNotifier {
Future<void> ignoreFollowRequest(Connection connection) async {
_logger.finest(
'Attempting to accept follow request ${connection.name}: ${connection.status}');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.ignoreFollow(connection))
.match(
await getIt<AuthService>().currentClient.ignoreFollow(connection).match(
onSuccess: (update) {
_logger
.finest('Successfully followed ${update.name}: ${update.status}');
@ -100,10 +91,7 @@ class ConnectionsManager extends ChangeNotifier {
Future<void> follow(Connection connection) async {
_logger.finest(
'Attempting to follow ${connection.name}: ${connection.status}');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.followConnection(connection))
.match(
await getIt<AuthService>().currentClient.followConnection(connection).match(
onSuccess: (update) {
_logger
.finest('Successfully followed ${update.name}: ${update.status}');
@ -121,7 +109,7 @@ class ConnectionsManager extends ChangeNotifier {
'Attempting to unfollow ${connection.name}: ${connection.status}');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.unFollowConnection(connection))
.unFollowConnection(connection)
.match(
onSuccess: (update) {
_logger
@ -141,13 +129,7 @@ class ConnectionsManager extends ChangeNotifier {
Future<void> updateAllContacts() async {
_logger.fine('Updating all contacts');
final clientResult = getIt<AuthService>().currentClient;
if (clientResult.isFailure) {
_logger.severe(
'Unable to update contacts due to client error: ${clientResult.error}');
return;
}
final client = clientResult.value;
final client = getIt<AuthService>().currentClient;
final results = <String, Connection>{};
var moreResults = true;
var maxId = -1;
@ -224,8 +206,9 @@ class ConnectionsManager extends ChangeNotifier {
FutureResult<bool, ExecError> addUserToGroup(
GroupData group, Connection connection) async {
_logger.finest('Adding ${connection.name} to group: ${group.name}');
final result = await getIt<AuthService>().currentClient.andThenAsync(
(client) => client.addConnectionToGroup(group, connection));
final result = await getIt<AuthService>()
.currentClient
.addConnectionToGroup(group, connection);
result.match(
onSuccess: (_) => _refreshGroupListData(connection.id, true),
onError: (error) {
@ -240,8 +223,9 @@ class ConnectionsManager extends ChangeNotifier {
FutureResult<bool, ExecError> removeUserFromGroup(
GroupData group, Connection connection) async {
_logger.finest('Removing ${connection.name} from group: ${group.name}');
final result = await getIt<AuthService>().currentClient.andThenAsync(
(client) => client.removeConnectionFromGroup(group, connection));
final result = await getIt<AuthService>()
.currentClient
.removeConnectionFromGroup(group, connection);
result.match(
onSuccess: (_) => _refreshGroupListData(connection.id, true),
onError: (error) {
@ -291,7 +275,7 @@ class ConnectionsManager extends ChangeNotifier {
_logger.finest('Refreshing member list data for Connection $id');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.getMemberGroupsForConnection(id))
.getMemberGroupsForConnection(id)
.match(
onSuccess: (groups) {
groupsRepo.updateConnectionGroupData(id, groups);
@ -310,7 +294,7 @@ class ConnectionsManager extends ChangeNotifier {
_logger.finest('Refreshing connection data for ${connection.name}');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.getConnectionWithStatus(connection))
.getConnectionWithStatus(connection)
.match(
onSuccess: (update) {
updateConnection(update);
@ -326,10 +310,7 @@ class ConnectionsManager extends ChangeNotifier {
Future<void> _updateMyGroups(bool withNotification) async {
_logger.finest('Refreshing my groups list');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.getGroups())
.match(
await getIt<AuthService>().currentClient.getGroups().match(
onSuccess: (groups) {
_logger.finest('Got updated groups:${groups.map((e) => e.name)}');
groupsRepo.clearGroups();

Wyświetl plik

@ -38,7 +38,7 @@ class DirectMessageService extends ChangeNotifier {
Future<void> updateThreads() async {
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.getDirectMessages(PagingData()))
.getDirectMessages(PagingData())
.match(
onSuccess: (update) {
final newThreads = DirectMessageThread.createThreads(update);
@ -61,13 +61,11 @@ class DirectMessageService extends ChangeNotifier {
FutureResult<DirectMessage, ExecError> newThread(
Connection receiver, String text) async {
final result = await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.postDirectMessage(
null,
receiver.id,
text,
));
final result = await getIt<AuthService>().currentClient.postDirectMessage(
null,
receiver.id,
text,
);
result.match(onSuccess: (newMessage) {
DirectMessageThread.createThreads([newMessage]).forEach((thread) {
_threads[thread.parentUri] = thread;
@ -101,13 +99,11 @@ class DirectMessageService extends ChangeNotifier {
);
}
final result = await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.postDirectMessage(
original.id,
original.senderId,
text,
));
final result = await getIt<AuthService>().currentClient.postDirectMessage(
original.id,
original.senderId,
text,
);
result.match(onSuccess: (newMessage) {
thread.messages.add(newMessage);
notifyListeners();
@ -130,10 +126,7 @@ class DirectMessageService extends ChangeNotifier {
return;
}
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.markDirectMessageRead(m))
.match(
await getIt<AuthService>().currentClient.markDirectMessageRead(m).match(
onSuccess: (update) {
thread.messages.removeAt(oldIndex);
thread.messages.insert(oldIndex, update);

Wyświetl plik

@ -68,15 +68,7 @@ class EntryManagerService extends ChangeNotifier {
FutureResult<bool, ExecError> deleteEntryById(String id) async {
_logger.finest('Delete entry: $id');
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result = await client.deleteEntryById(id);
final result = await getIt<AuthService>().currentClient.deleteEntryById(id);
if (result.isFailure) {
return result.errorCast();
}
@ -86,23 +78,14 @@ class EntryManagerService extends ChangeNotifier {
return Result.ok(true);
}
FutureResult<bool, ExecError> createNewStatus(
String text, {
FutureResult<bool, ExecError> createNewStatus(String text, {
String spoilerText = '',
String inReplyToId = '',
required NewEntryMediaItems mediaItems,
required List<ImageEntry> existingMediaItems,
}) async {
_logger.finest('Creating new post: $text');
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final client = getIt<AuthService>().currentClient;
final mediaIds = existingMediaItems.map((m) => m.scales.first.id).toList();
for (final item in mediaItems.attachments) {
if (item.isExistingServerItem) {
@ -124,10 +107,11 @@ class EntryManagerService extends ChangeNotifier {
}
final uploadResult =
await MediaUploadAttachmentHelper.getUploadableImageBytes(
await MediaUploadAttachmentHelper.getUploadableImageBytes(
item.localFilePath,
).andThenAsync(
(imageBytes) async => await client.uploadFileAsAttachment(
(imageBytes) async =>
await client.uploadFileAsAttachment(
bytes: imageBytes,
album: mediaItems.albumName,
description: item.description,
@ -145,10 +129,10 @@ class EntryManagerService extends ChangeNotifier {
final result = await client
.createNewStatus(
text: text,
spoilerText: spoilerText,
inReplyToId: inReplyToId,
mediaIds: mediaIds)
text: text,
spoilerText: spoilerText,
inReplyToId: inReplyToId,
mediaIds: mediaIds)
.andThenSuccessAsync((item) async {
await processNewItems([item], client.credentials.username, null);
return item;
@ -169,7 +153,7 @@ class EntryManagerService extends ChangeNotifier {
_logger.finest('${status.id} status created');
return true;
}).mapError(
(error) {
(error) {
_logger.finest('Error creating post: $error');
return ExecError(
type: ErrorType.localError,
@ -182,14 +166,7 @@ class EntryManagerService extends ChangeNotifier {
FutureResult<List<EntryTreeItem>, ExecError> updateTimeline(
TimelineIdentifiers type, int maxId, int sinceId) async {
_logger.fine(() => 'Updating timeline');
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final client = getIt<AuthService>().currentClient;
final itemsResult = await client.getTimeline(
type: type,
page: PagingData(
@ -203,10 +180,12 @@ class EntryManagerService extends ChangeNotifier {
}
itemsResult.value.sort((t1, t2) => t1.id.compareTo(t2.id));
final updatedPosts =
await processNewItems(itemsResult.value, auth.currentId, client);
final updatedPosts = await processNewItems(
itemsResult.value, client.credentials.userId, client);
_logger.finest(() {
final postCount = _entries.values.where((e) => e.parentId.isEmpty).length;
final postCount = _entries.values
.where((e) => e.parentId.isEmpty)
.length;
final commentCount = _entries.length - postCount;
final orphanCount = _entries.values
.where(
@ -217,11 +196,9 @@ class EntryManagerService extends ChangeNotifier {
return Result.ok(updatedPosts);
}
Future<List<EntryTreeItem>> processNewItems(
List<TimelineEntry> items,
String currentId,
FriendicaClient? client,
) async {
Future<List<EntryTreeItem>> processNewItems(List<TimelineEntry> items,
String currentId,
FriendicaClient? client,) async {
items.sort((i1, i2) => int.parse(i1.id).compareTo(int.parse(i2.id)));
final allSeenItems = [...items];
for (final item in items) {
@ -248,7 +225,9 @@ class EntryManagerService extends ChangeNotifier {
await client
?.getPostOrComment(o.id, fullContext: true)
.andThenSuccessAsync((items) async {
final parentPostId = items.firstWhere((e) => e.parentId.isEmpty).id;
final parentPostId = items
.firstWhere((e) => e.parentId.isEmpty)
.id;
_parentPostIds[o.id] = parentPostId;
allSeenItems.addAll(items);
for (final item in items) {
@ -276,7 +255,7 @@ class EntryManagerService extends ChangeNotifier {
for (final item in seenItemsCopy) {
if (item.parentId.isEmpty) {
final postNode =
_postNodes.putIfAbsent(item.id, () => _Node(item.id));
_postNodes.putIfAbsent(item.id, () => _Node(item.id));
postNodesToReturn.add(postNode);
allSeenItems.remove(item);
} else {
@ -318,35 +297,31 @@ class EntryManagerService extends ChangeNotifier {
.toList();
_logger.finest(
'Completed processing new items ${client == null ? 'sub level' : 'top level'}');
'Completed processing new items ${client == null
? 'sub level'
: 'top level'}');
return updatedPosts;
}
FutureResult<EntryTreeItem, ExecError> refreshStatusChain(String id) async {
_logger.finest('Refreshing post: $id');
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final client = getIt<AuthService>().currentClient;
final result = await client
.getPostOrComment(id, fullContext: false)
.andThenAsync((rootItems) async => await client
.getPostOrComment(id, fullContext: true)
.andThenSuccessAsync(
(contextItems) async => [...rootItems, ...contextItems]))
.andThenAsync((rootItems) async =>
await client
.getPostOrComment(id, fullContext: true)
.andThenSuccessAsync(
(contextItems) async => [...rootItems, ...contextItems]))
.andThenSuccessAsync((items) async {
await processNewItems(items, client.credentials.username, null);
});
return result.mapValue((_) {
_logger.finest('$id post updated');
return _nodeToTreeItem(_getPostRootNode(id)!, auth.currentId);
return _nodeToTreeItem(_getPostRootNode(id)!, client.credentials.userId);
}).mapError(
(error) {
(error) {
_logger.finest('$id error updating: $error');
return ExecError(
type: ErrorType.localError,
@ -358,24 +333,17 @@ class EntryManagerService extends ChangeNotifier {
FutureResult<EntryTreeItem, ExecError> resharePost(String id) async {
_logger.finest('Resharing post: $id');
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final client = getIt<AuthService>().currentClient;
final result =
await client.resharePost(id).andThenSuccessAsync((item) async {
await client.resharePost(id).andThenSuccessAsync((item) async {
await processNewItems([item], client.credentials.username, null);
});
return result.mapValue((_) {
_logger.finest('$id post updated after reshare');
return _nodeToTreeItem(_postNodes[id]!, auth.currentId);
return _nodeToTreeItem(_postNodes[id]!, client.credentials.userId);
}).mapError(
(error) {
(error) {
_logger.finest('$id error updating: $error');
return ExecError(
type: ErrorType.localError,
@ -387,16 +355,11 @@ class EntryManagerService extends ChangeNotifier {
FutureResult<bool, ExecError> unResharePost(String id) async {
_logger.finest('Unresharing post: $id');
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result =
await client.unResharePost(id).andThenSuccessAsync((item) async {
final client = getIt<AuthService>()
.currentClient;
final result = await client
.unResharePost(id)
.andThenSuccessAsync((item) async {
await processNewItems([item], client.credentials.username, null);
});
@ -410,16 +373,12 @@ class EntryManagerService extends ChangeNotifier {
return Result.ok(true);
}
FutureResult<EntryTreeItem, ExecError> toggleFavorited(
String id, bool newStatus) async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result = await client.changeFavoriteStatus(id, newStatus);
FutureResult<EntryTreeItem, ExecError> toggleFavorited(String id,
bool newStatus) async {
final client = getIt<AuthService>()
.currentClient;
final result = await client
.changeFavoriteStatus(id, newStatus);
if (result.isFailure) {
return result.errorCast();
}
@ -431,7 +390,7 @@ class EntryManagerService extends ChangeNotifier {
: _postNodes[update.parentId]!.getChildById(update.id)!;
notifyListeners();
return Result.ok(_nodeToTreeItem(node, auth.currentId));
return Result.ok(_nodeToTreeItem(node, client.credentials.userId));
}
EntryTreeItem _nodeToTreeItem(_Node node, String currentId) {
@ -508,7 +467,7 @@ class _Node {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is _Node && runtimeType == other.runtimeType && id == other.id;
other is _Node && runtimeType == other.runtimeType && id == other.id;
@override
int get hashCode => id.hashCode;

Wyświetl plik

@ -1,5 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:result_monad/result_monad.dart';
import '../friendica_client/paging_data.dart';
@ -11,7 +10,6 @@ import 'auth_service.dart';
class GalleryService extends ChangeNotifier {
static const IMAGES_PER_PAGE = 50;
static final _logger = Logger('$GalleryService');
final _galleries = <String, GalleryData>{};
final _galleryPages = <String, List<PagingData>>{};
final _images = <String, Set<ImageEntry>>{};
@ -41,15 +39,7 @@ class GalleryService extends ChangeNotifier {
}
FutureResult<List<GalleryData>, ExecError> updateGalleries() async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result = await client.getGalleryData();
final result = await getIt<AuthService>().currentClient.getGalleryData();
if (result.isFailure) {
return result.errorCast();
}
@ -86,13 +76,6 @@ class GalleryService extends ChangeNotifier {
{required String galleryName,
required bool withNextPage,
bool nextPageOnly = true}) async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final pages = _galleryPages.putIfAbsent(galleryName, () => []);
if (pages.isEmpty) {
pages.add(PagingData(offset: 0, limit: IMAGES_PER_PAGE));
@ -101,12 +84,13 @@ class GalleryService extends ChangeNotifier {
pages.add(PagingData(offset: offset, limit: IMAGES_PER_PAGE));
}
final client = clientResult.value;
final imageSet = _images.putIfAbsent(galleryName, () => {});
final pagesToUse = nextPageOnly ? [pages.last] : pages;
for (final page in pagesToUse) {
final result = await client.getGalleryImages(galleryName, page);
final result = await getIt<AuthService>()
.currentClient
.getGalleryImages(galleryName, page);
if (result.isFailure) {
return result.errorCast();
}

Wyświetl plik

@ -1,5 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:result_monad/result_monad.dart';
import '../globals.dart';
@ -8,7 +7,6 @@ import '../models/exec_error.dart';
import 'auth_service.dart';
class InteractionsManager extends ChangeNotifier {
static final _logger = Logger('$InteractionsManager');
final _likesByStatusId = <String, List<Connection>>{};
final _resharesByStatusId = <String, List<Connection>>{};
@ -32,15 +30,8 @@ class InteractionsManager extends ChangeNotifier {
FutureResult<List<Connection>, ExecError> updateLikesForStatus(
String statusId) async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final likesResult = await client.getLikes(statusId);
final likesResult =
await getIt<AuthService>().currentClient.getLikes(statusId);
if (likesResult.isSuccess) {
_likesByStatusId[statusId] = likesResult.value;
notifyListeners();
@ -50,15 +41,8 @@ class InteractionsManager extends ChangeNotifier {
FutureResult<List<Connection>, ExecError> updateResharesForStatus(
String statusId) async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final resharesResult = await client.getReshares(statusId);
final resharesResult =
await getIt<AuthService>().currentClient.getReshares(statusId);
if (resharesResult.isSuccess) {
_resharesByStatusId[statusId] = resharesResult.value;
notifyListeners();

Wyświetl plik

@ -127,15 +127,9 @@ class NotificationsManager extends ChangeNotifier {
}
FutureResult<bool, ExecError> markSeen(UserNotification notification) async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result = await client.clearNotification(notification);
final result = await getIt<AuthService>()
.currentClient
.clearNotification(notification);
if (result.isSuccess) {
notifyListeners();
}
@ -145,15 +139,8 @@ class NotificationsManager extends ChangeNotifier {
}
FutureResult<List<UserNotification>, ExecError> markAllAsRead() async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result = await client.clearNotifications();
final result =
await getIt<AuthService>().currentClient.clearNotifications();
if (result.isFailure) {
return result.errorCast();
}
@ -188,15 +175,8 @@ class NotificationsManager extends ChangeNotifier {
static FutureResult<PagedResponse<List<UserNotification>>, ExecError>
_clientGetNotificationsRequest(PagingData page) async {
final auth = getIt<AuthService>();
final clientResult = auth.currentClient;
if (clientResult.isFailure) {
_logger.severe('Error getting Friendica client: ${clientResult.error}');
return clientResult.errorCast();
}
final client = clientResult.value;
final result = await client.getNotifications(page);
final result =
await getIt<AuthService>().currentClient.getNotifications(page);
return result;
}
}

Wyświetl plik

@ -45,10 +45,7 @@ class TimelineManager extends ChangeNotifier {
Future<void> _refreshGroupData() async {
_logger.finest('Refreshing member group data ');
await getIt<AuthService>()
.currentClient
.andThenAsync((client) => client.getGroups())
.match(
await getIt<AuthService>().currentClient.getGroups().match(
onSuccess: (groups) {
_groups.clear();
for (final group in groups) {