👽 Update API to microservices
♻️ Refactor router pushes
This commit is contained in:
@@ -28,14 +28,14 @@ part 'settings.g.dart';
|
||||
@riverpod
|
||||
Future<List<SnAuthFactor>> authFactors(Ref ref) async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final res = await client.get('/accounts/me/factors');
|
||||
final res = await client.get('/id/accounts/me/factors');
|
||||
return res.data.map<SnAuthFactor>((e) => SnAuthFactor.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<List<SnContactMethod>> contactMethods(Ref ref) async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final resp = await client.get('/accounts/me/contacts');
|
||||
final resp = await client.get('/id/accounts/me/contacts');
|
||||
return resp.data
|
||||
.map<SnContactMethod>((e) => SnContactMethod.fromJson(e))
|
||||
.toList();
|
||||
@@ -44,7 +44,7 @@ Future<List<SnContactMethod>> contactMethods(Ref ref) async {
|
||||
@riverpod
|
||||
Future<List<SnAccountConnection>> accountConnections(Ref ref) async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final resp = await client.get('/accounts/me/connections');
|
||||
final resp = await client.get('/id/accounts/me/connections');
|
||||
return resp.data
|
||||
.map<SnAccountConnection>((e) => SnAccountConnection.fromJson(e))
|
||||
.toList();
|
||||
@@ -68,7 +68,7 @@ class AccountSettingsScreen extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.delete('/accounts/me');
|
||||
await client.delete('/id/accounts/me');
|
||||
if (context.mounted) {
|
||||
showSnackBar('accountDeletionSent'.tr());
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ part of 'settings.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$authFactorsHash() => r'4bb65bc0c065c4091c209ee81e57ddef41051ae2';
|
||||
String _$authFactorsHash() => r'24fe2f7b375b019d87fc3b85cbedbe857f399c0f';
|
||||
|
||||
/// See also [authFactors].
|
||||
@ProviderFor(authFactors)
|
||||
@@ -25,7 +25,7 @@ final authFactorsProvider =
|
||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||
// ignore: unused_element
|
||||
typedef AuthFactorsRef = AutoDisposeFutureProviderRef<List<SnAuthFactor>>;
|
||||
String _$contactMethodsHash() => r'4d7952fc196dce4dc646314565a49c115fd1d292';
|
||||
String _$contactMethodsHash() => r'76a1a93f61c51c44b32b4821f5112d58406155f0';
|
||||
|
||||
/// See also [contactMethods].
|
||||
@ProviderFor(contactMethods)
|
||||
@@ -45,7 +45,7 @@ final contactMethodsProvider =
|
||||
// ignore: unused_element
|
||||
typedef ContactMethodsRef = AutoDisposeFutureProviderRef<List<SnContactMethod>>;
|
||||
String _$accountConnectionsHash() =>
|
||||
r'38a309d596e0ea2539cd92ea86984e1e4fb346e4';
|
||||
r'9f69e7f23e3e53c528d38b93d76f0c9efc9a83db';
|
||||
|
||||
/// See also [accountConnections].
|
||||
@ProviderFor(accountConnections)
|
||||
|
@@ -31,7 +31,7 @@ class AuthFactorSheet extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.delete('/accounts/me/factors/${factor.id}');
|
||||
await client.delete('/id/accounts/me/factors/${factor.id}');
|
||||
if (context.mounted) Navigator.pop(context, true);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
@@ -49,7 +49,7 @@ class AuthFactorSheet extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.post('/accounts/me/factors/${factor.id}/disable');
|
||||
await client.post('/id/accounts/me/factors/${factor.id}/disable');
|
||||
if (context.mounted) Navigator.pop(context, true);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
|
@@ -74,7 +74,7 @@ class AccountConnectionSheet extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.delete('/accounts/me/connections/${connection.id}');
|
||||
await client.delete('/id/accounts/me/connections/${connection.id}');
|
||||
if (context.mounted) Navigator.pop(context, true);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
|
@@ -25,7 +25,7 @@ class ContactMethodSheet extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.delete('/accounts/me/contacts/${contact.id}');
|
||||
await client.delete('/id/accounts/me/contacts/${contact.id}');
|
||||
if (context.mounted) Navigator.pop(context, true);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
@@ -38,7 +38,7 @@ class ContactMethodSheet extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.post('/accounts/me/contacts/${contact.id}/verify');
|
||||
await client.post('/id/accounts/me/contacts/${contact.id}/verify');
|
||||
if (context.mounted) {
|
||||
showSnackBar('contactMethodVerificationSent'.tr());
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class ContactMethodSheet extends HookConsumerWidget {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.post('/accounts/me/contacts/${contact.id}/primary');
|
||||
await client.post('/id/accounts/me/contacts/${contact.id}/primary');
|
||||
if (context.mounted) Navigator.pop(context, true);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
|
@@ -135,7 +135,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
showLoadingModal(context);
|
||||
try {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
await client.post('/relationships/${account.value!.id}/friends');
|
||||
await client.post('/id/relationships/${account.value!.id}/friends');
|
||||
ref.invalidate(accountRelationshipProvider(name));
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
@@ -149,9 +149,9 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
try {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
if (accountRelationship.value == null) {
|
||||
await client.post('/relationships/${account.value!.id}/block');
|
||||
await client.post('/id/relationships/${account.value!.id}/block');
|
||||
} else {
|
||||
await client.delete('/relationships/${account.value!.id}/block');
|
||||
await client.delete('/id/relationships/${account.value!.id}/block');
|
||||
}
|
||||
ref.invalidate(accountRelationshipProvider(name));
|
||||
} catch (err) {
|
||||
@@ -164,7 +164,10 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
Future<void> directMessageAction() async {
|
||||
if (!account.hasValue) return;
|
||||
if (accountChat.value != null) {
|
||||
context.push('/chat/${accountChat.value!.id}');
|
||||
context.pushNamed(
|
||||
'chatRoom',
|
||||
pathParameters: {'id': accountChat.value!.id},
|
||||
);
|
||||
return;
|
||||
}
|
||||
showLoadingModal(context);
|
||||
@@ -175,7 +178,9 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
data: {'related_user_id': account.value!.id},
|
||||
);
|
||||
final chat = SnChatRoom.fromJson(resp.data);
|
||||
if (context.mounted) context.push('/chat/${chat.id}');
|
||||
if (context.mounted) {
|
||||
context.pushNamed('chatRoom', pathParameters: {'id': chat.id});
|
||||
}
|
||||
ref.invalidate(accountDirectChatProvider(name));
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
|
@@ -20,7 +20,7 @@ part 'relationship.g.dart';
|
||||
@riverpod
|
||||
Future<List<SnRelationship>> sentFriendRequest(Ref ref) async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final resp = await client.get('/relationships/requests');
|
||||
final resp = await client.get('/id/relationships/requests');
|
||||
return resp.data
|
||||
.map((e) => SnRelationship.fromJson(e))
|
||||
.cast<SnRelationship>()
|
||||
@@ -221,7 +221,7 @@ class RelationshipScreen extends HookConsumerWidget {
|
||||
if (result == null) return;
|
||||
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.post('/relationships/${result.id}/friends');
|
||||
await client.post('/id/relationships/${result.id}/friends');
|
||||
ref.invalidate(sentFriendRequestProvider);
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ class _SentFriendRequestsSheet extends HookConsumerWidget {
|
||||
Future<void> cancelRequest(SnRelationship request) async {
|
||||
try {
|
||||
final client = ref.read(apiClientProvider);
|
||||
await client.delete('/relationships/${request.relatedId}/friends');
|
||||
await client.delete('/id/relationships/${request.relatedId}/friends');
|
||||
ref.invalidate(sentFriendRequestProvider);
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
|
@@ -6,7 +6,7 @@ part of 'relationship.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$sentFriendRequestHash() => r'2efa72835b1740e0fe96bd347bce0f98b6ae80d6';
|
||||
String _$sentFriendRequestHash() => r'dc02ace6cb755a01ab862c9fcff3b26de7f946cb';
|
||||
|
||||
/// See also [sentFriendRequest].
|
||||
@ProviderFor(sentFriendRequest)
|
||||
|
Reference in New Issue
Block a user