kopia lustrzana https://gitlab.com/mysocialportal/relatica
38 wiersze
1.1 KiB
Dart
38 wiersze
1.1 KiB
Dart
![]() |
import 'package:logging/logging.dart';
|
||
|
import 'package:result_monad/result_monad.dart';
|
||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||
|
|
||
|
import '../friendica_client/friendica_client.dart';
|
||
|
import '../models/auth/profile.dart';
|
||
|
import '../models/friendica_version.dart';
|
||
|
import '../models/instance_info.dart';
|
||
|
|
||
|
part 'instance_info_services.g.dart';
|
||
|
|
||
|
final _logger = Logger('InstanceInfoManager');
|
||
|
|
||
|
@Riverpod(keepAlive: true)
|
||
|
class InstanceInfoManager extends _$InstanceInfoManager {
|
||
|
@override
|
||
|
InstanceInfo build(Profile profile) {
|
||
|
_logger.info('Building instance info for $profile');
|
||
|
update();
|
||
|
return InstanceInfo(
|
||
|
maxStatusCharacters: 1000,
|
||
|
maxImageBytes: 800000,
|
||
|
friendicaVersion: v2024_08,
|
||
|
versionString: v2024_08.toVersionString(),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Future<void> update() async {
|
||
|
await InstanceDataClient(profile).getInstanceData().match(
|
||
|
onSuccess: (info) {
|
||
|
_logger.info('Got server info for ${profile.handle}: $info');
|
||
|
state = info;
|
||
|
}, onError: (error) {
|
||
|
_logger.severe('Error getting server info for ${profile.handle}: $error');
|
||
|
});
|
||
|
}
|
||
|
}
|