completed migrating data scope from user to workspace
This commit is contained in:
@@ -148,14 +148,14 @@ class HomeController extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<ApiResponse<List<Map<String, dynamic>>>> getTransactions(
|
||||
String userId,
|
||||
String workspaceId,
|
||||
) async {
|
||||
model.isLoading = true;
|
||||
if (!_disposed) notifyListeners();
|
||||
|
||||
try {
|
||||
Map<String, dynamic> response = await http.get(
|
||||
'/public/transaction?sort=createdAt,desc&size=3&page=0&partyType=INDIVIDUAL&userId=$userId',
|
||||
'/public/transaction?sort=createdAt,desc&size=3&page=0&partyType=INDIVIDUAL,GROUP&workspaceId=$workspaceId',
|
||||
);
|
||||
|
||||
PageableModel pageableModel = PageableModel.fromJson(response);
|
||||
|
||||
@@ -127,11 +127,11 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
});
|
||||
}
|
||||
|
||||
if (prefs.getString("userId") == null) {
|
||||
prefs.setString("userId", Uuid().v4());
|
||||
if (prefs.getString("workspaceId") == null) {
|
||||
prefs.setString("workspaceId", Uuid().v4());
|
||||
}
|
||||
|
||||
await homeController.getTransactions(prefs.getString("userId")!);
|
||||
await homeController.getTransactions(prefs.getString("workspaceId")!);
|
||||
}
|
||||
|
||||
void _onCurrencySelected(String currency) {
|
||||
@@ -155,8 +155,8 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
await homeController.getProviders(_selectedCurrency);
|
||||
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.getString("userId") != null) {
|
||||
await homeController.getTransactions(prefs.getString("userId")!);
|
||||
if (prefs.getString("workspaceId") != null) {
|
||||
await homeController.getTransactions(prefs.getString("workspaceId")!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,11 +165,11 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
|
||||
if (location.startsWith('/home')) {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
|
||||
if (prefs.getString("userId") == null) {
|
||||
prefs.setString("userId", Uuid().v4());
|
||||
if (prefs.getString("workspaceId") == null) {
|
||||
prefs.setString("workspaceId", Uuid().v4());
|
||||
}
|
||||
|
||||
await homeController.getTransactions(prefs.getString("userId")!);
|
||||
await homeController.getTransactions(prefs.getString("workspaceId")!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user