-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-1193: Store/get/delete active account in persistent storage
- Loading branch information
Showing
37 changed files
with
618 additions
and
723 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
lib/data/datasource/multiple_account/multiple_account_datasource.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
abstract class MultipleAccountDatasource { | ||
Future<void> storePersistActiveAccount(String userId); | ||
|
||
Future<String?> getPersistActiveAccount(); | ||
|
||
Future<void> deletePersistActiveAccount(); | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/data/datasource_impl/multiple_account/multiple_account_datasource_impl.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:fluffychat/data/datasource/multiple_account/multiple_account_datasource.dart'; | ||
import 'package:fluffychat/data/local/multiple_account/multiple_account_cache_manager.dart'; | ||
import 'package:fluffychat/di/global/get_it_initializer.dart'; | ||
|
||
class MultipleAccountDatasourceImpl implements MultipleAccountDatasource { | ||
final MultipleAccountCacheManager _multipleAccountCacheManager = | ||
getIt.get<MultipleAccountCacheManager>(); | ||
|
||
@override | ||
Future<String?> getPersistActiveAccount() { | ||
return _multipleAccountCacheManager.getPersistActiveAccount(); | ||
} | ||
|
||
@override | ||
Future<void> storePersistActiveAccount(String userId) { | ||
return _multipleAccountCacheManager.storePersistActiveAccount(userId); | ||
} | ||
|
||
@override | ||
Future<void> deletePersistActiveAccount() { | ||
return _multipleAccountCacheManager.deletePersistActiveAccount(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
lib/data/local/multiple_account/multiple_account_cache_manager.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:fluffychat/di/global/get_it_initializer.dart'; | ||
import 'package:fluffychat/utils/famedlysdk_store.dart'; | ||
|
||
class MultipleAccountCacheManager { | ||
final pres = getIt.get<Store>(); | ||
|
||
static const String persistActiveAccountKey = 'persist_active_account_key'; | ||
|
||
Future<void> storePersistActiveAccount(String userId) async { | ||
await pres.setItem(persistActiveAccountKey, userId); | ||
} | ||
|
||
Future<String?> getPersistActiveAccount() async { | ||
return await pres.getItem(persistActiveAccountKey); | ||
} | ||
|
||
Future<void> deletePersistActiveAccount() async { | ||
await pres.deleteItem(persistActiveAccountKey); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/data/repository/multiple_account/multiple_account_repository_impl.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:fluffychat/data/datasource/multiple_account/multiple_account_datasource.dart'; | ||
import 'package:fluffychat/di/global/get_it_initializer.dart'; | ||
import 'package:fluffychat/domain/repository/multiple_account/multiple_account_repository.dart'; | ||
|
||
class MultipleAccountRepositoryImpl extends MultipleAccountRepository { | ||
final MultipleAccountDatasource _multipleAccountDatasource = | ||
getIt.get<MultipleAccountDatasource>(); | ||
|
||
@override | ||
Future<String?> getPersistActiveAccount() { | ||
return _multipleAccountDatasource.getPersistActiveAccount(); | ||
} | ||
|
||
@override | ||
Future<void> storePersistActiveAccount(String userId) { | ||
return _multipleAccountDatasource.storePersistActiveAccount(userId); | ||
} | ||
|
||
@override | ||
Future<void> deletePersistActiveAccount() { | ||
return _multipleAccountDatasource.deletePersistActiveAccount(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
lib/domain/repository/multiple_account/multiple_account_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
abstract class MultipleAccountRepository { | ||
Future<void> storePersistActiveAccount(String userId); | ||
|
||
Future<String?> getPersistActiveAccount(); | ||
|
||
Future<void> deletePersistActiveAccount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
abstract class MigrateSteps { | ||
const MigrateSteps(); | ||
|
||
Future<void> onMigrate(int currentVersion, int newVersion) async {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:fluffychat/data/hive/hive_collection_tom_database.dart'; | ||
import 'package:fluffychat/di/global/get_it_initializer.dart'; | ||
import 'package:fluffychat/domain/repository/multiple_account/multiple_account_repository.dart'; | ||
import 'package:fluffychat/migrate_steps/migrate_steps.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
|
||
class MigrateV6ToV7 extends MigrateSteps { | ||
@override | ||
Future<void> onMigrate(int currentVersion, int newVersion) async { | ||
Logs().d( | ||
'MigrateV6ToV7::onMigrate() Starting migration from v6 to v7', | ||
); | ||
final hiveCollectionToMDatabase = | ||
await getIt.getAsync<HiveCollectionToMDatabase>(); | ||
await hiveCollectionToMDatabase.clear(); | ||
Logs().d( | ||
'MigrateV6ToV7::onMigrate(): Delete ToM database success', | ||
); | ||
final multipleAccountRepository = getIt.get<MultipleAccountRepository>(); | ||
await multipleAccountRepository.deletePersistActiveAccount(); | ||
Logs().d( | ||
'MigrateV6ToV7::onMigrate(): Delete persist active account success', | ||
); | ||
} | ||
} |
Oops, something went wrong.