Files
fuckKomet/lib/services/local_profile_manager.dart

39 lines
1.1 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:gwid/models/profile.dart';
import 'package:gwid/services/profile_cache_service.dart';
class LocalProfileManager {
static final LocalProfileManager _instance = LocalProfileManager._internal();
factory LocalProfileManager() => _instance;
LocalProfileManager._internal();
final ProfileCacheService _profileCache = ProfileCacheService();
bool _initialized = false;
Future<void> initialize() async {
if (_initialized) return;
await _profileCache.initialize();
_initialized = true;
}
Future<Profile?> getActualProfile(Profile? serverProfile) async {
// Полностью отключаем локальные оверрайды профиля:
// всегда используем только данные с сервера.
return serverProfile;
}
Future<String?> getLocalAvatarPath() async {
await initialize();
return await _profileCache.getLocalAvatarPath();
}
Future<bool> hasLocalChanges() async {
await initialize();
return await _profileCache.hasLocalChanges();
}
Future<void> clearLocalChanges() async {
await initialize();
await _profileCache.clearProfileCache();
}
}