diff --git a/lib/application/calculator_asc_materials/material_item_quantity/calculator_asc_materials_item_update_quantity_bloc.dart b/lib/application/calculator_asc_materials/material_item_quantity/calculator_asc_materials_item_update_quantity_bloc.dart index 7f4a96076..7efee5792 100644 --- a/lib/application/calculator_asc_materials/material_item_quantity/calculator_asc_materials_item_update_quantity_bloc.dart +++ b/lib/application/calculator_asc_materials/material_item_quantity/calculator_asc_materials_item_update_quantity_bloc.dart @@ -20,7 +20,7 @@ class CalculatorAscMaterialsItemUpdateQuantityBloc Stream mapEventToState(CalculatorAscMaterialsItemUpdateQuantityEvent event) async* { final s = await event.map( load: (e) async { - final material = _dataService.getMaterialFromInventory(e.key); + final material = _dataService.inventory.getMaterialFromInventory(e.key); return CalculatorAscMaterialsItemUpdateQuantityState.loaded(key: material.key, quantity: material.quantity); }, update: (e) async { @@ -34,6 +34,6 @@ class CalculatorAscMaterialsItemUpdateQuantityBloc Future _updateMaterialQuantity(String key, int quantity) async { await _telemetryService.trackItemUpdatedInInventory(key, quantity); - await _dataService.updateItemInInventory(key, ItemType.material, quantity); + await _dataService.inventory.updateItemInInventory(key, ItemType.material, quantity, _dataService.calculator.redistributeInventoryMaterial); } } diff --git a/lib/application/calculator_asc_materials/materials/calculator_asc_materials_bloc.dart b/lib/application/calculator_asc_materials/materials/calculator_asc_materials_bloc.dart index f201ae478..7df13ad50 100644 --- a/lib/application/calculator_asc_materials/materials/calculator_asc_materials_bloc.dart +++ b/lib/application/calculator_asc_materials/materials/calculator_asc_materials_bloc.dart @@ -40,7 +40,7 @@ class CalculatorAscMaterialsBloc extends Bloc getItemsKeysToExclude() => currentState.items.map((e) => e.key).toList(); Future _updateItem(int sessionKey, int index, ItemAscensionMaterials updatedItem) async { - final toAdd = await _dataService.updateCalAscMatSessionItem(sessionKey, index, updatedItem); + final toAdd = await _dataService.calculator.updateCalAscMatSessionItem(sessionKey, index, updatedItem); final items = [...currentState.items]; items.removeAt(index); items.insert(index, toAdd); diff --git a/lib/application/calculator_asc_materials/materials_order/calculator_asc_materials_order_bloc.dart b/lib/application/calculator_asc_materials/materials_order/calculator_asc_materials_order_bloc.dart index 0b3e481cb..45bd03cc8 100644 --- a/lib/application/calculator_asc_materials/materials_order/calculator_asc_materials_order_bloc.dart +++ b/lib/application/calculator_asc_materials/materials_order/calculator_asc_materials_order_bloc.dart @@ -30,10 +30,10 @@ class CalculatorAscMaterialsOrderBloc extends Bloc el.key == e.key).position; await _telemetryService.trackCalculatorAscMaterialsSessionsUpdated(); - await _dataService.updateCalAscMatSession(e.key, e.name.trim(), position); - final sessions = _dataService.getAllCalAscMatSessions(); + await _dataService.calculator.updateCalAscMatSession(e.key, e.name.trim(), position); + final sessions = _dataService.calculator.getAllCalAscMatSessions(); return CalculatorAscMaterialsSessionsState.loaded(sessions: sessions); }, deleteSession: (e) async { await _telemetryService.trackCalculatorAscMaterialsSessionsDeleted(); - await _dataService.deleteCalAscMatSession(e.key); - final sessions = _dataService.getAllCalAscMatSessions(); + await _dataService.calculator.deleteCalAscMatSession(e.key); + final sessions = _dataService.calculator.getAllCalAscMatSessions(); return CalculatorAscMaterialsSessionsState.loaded(sessions: sessions); }, deleteAllSessions: (_) async { await _telemetryService.trackCalculatorAscMaterialsSessionsDeleted(all: true); - await _dataService.deleteAllCalAscMatSession(); + await _dataService.calculator.deleteAllCalAscMatSession(); return const CalculatorAscMaterialsSessionsState.loaded(sessions: []); }, ); diff --git a/lib/application/calculator_asc_materials/sessions_order/calculator_asc_materials_sessions_order_bloc.dart b/lib/application/calculator_asc_materials/sessions_order/calculator_asc_materials_sessions_order_bloc.dart index 3774bc2ad..425131017 100644 --- a/lib/application/calculator_asc_materials/sessions_order/calculator_asc_materials_sessions_order_bloc.dart +++ b/lib/application/calculator_asc_materials/sessions_order/calculator_asc_materials_sessions_order_bloc.dart @@ -40,10 +40,10 @@ class CalculatorAscMaterialsSessionsOrderBloc extends Bloc { loading: (state) async => state, loaded: (state) async { await _telemetryService.trackItemAddedToInventory(key, 1); - await _dataService.addCharacterToInventory(key); + await _dataService.inventory.addCharacterToInventory(key); return state.copyWith.call(isInInventory: true); }, ), @@ -50,7 +50,7 @@ class CharacterBloc extends Bloc { loading: (state) async => state, loaded: (state) async { await _telemetryService.trackItemDeletedFromInventory(key); - await _dataService.deleteCharacterFromInventory(key); + await _dataService.inventory.deleteCharacterFromInventory(key); return state.copyWith.call(isInInventory: false); }, ), @@ -85,7 +85,7 @@ class CharacterBloc extends Bloc { }).toList(); final birthday = _localeService.formatCharBirthDate(char.birthday); - final isInInventory = _dataService.isItemInInventory(char.key, ItemType.character); + final isInInventory = _dataService.inventory.isItemInInventory(char.key, ItemType.character); final builds = char.builds.map((build) { return CharacterBuildCardModel( isRecommended: build.isRecommended, diff --git a/lib/application/game_codes/game_codes_bloc.dart b/lib/application/game_codes/game_codes_bloc.dart index ba28f32ff..64ad7518d 100644 --- a/lib/application/game_codes/game_codes_bloc.dart +++ b/lib/application/game_codes/game_codes_bloc.dart @@ -40,12 +40,12 @@ class GameCodesBloc extends Bloc { return _buildInitialState(); }, markAsUsed: (code, wasUsed) async { - await _dataService.markCodeAsUsed(code, wasUsed: wasUsed); + await _dataService.gameCodes.markCodeAsUsed(code, wasUsed: wasUsed); return _buildInitialState(); }, refresh: () async { final gameCodes = await _gameCodeService.getAllGameCodes(); - await _dataService.saveGameCodes(gameCodes); + await _dataService.gameCodes.saveGameCodes(gameCodes); await _telemetryService.trackGameCodesOpened(); return _buildInitialState(); @@ -57,7 +57,7 @@ class GameCodesBloc extends Bloc { } GameCodesState _buildInitialState() { - final gameCodes = _dataService.getAllGameCodes(); + final gameCodes = _dataService.gameCodes.getAllGameCodes(); return GameCodesState.loaded( workingGameCodes: gameCodes.where((code) => !code.isExpired).toList(), diff --git a/lib/application/inventory/inventory_bloc.dart b/lib/application/inventory/inventory_bloc.dart index 5a3e04084..5a0ec5a58 100644 --- a/lib/application/inventory/inventory_bloc.dart +++ b/lib/application/inventory/inventory_bloc.dart @@ -25,9 +25,9 @@ class InventoryBloc extends Bloc { this._telemetryService, ) : super(const InventoryState.loaded(characters: [], weapons: [], materials: [])) { _streamSubscriptions = [ - _dataService.itemAddedToInventory.stream.listen((type) => add(InventoryEvent.refresh(type: type))), - _dataService.itemDeletedFromInventory.stream.listen((type) => add(InventoryEvent.refresh(type: type))), - _dataService.itemUpdatedInInventory.stream.listen((type) => add(InventoryEvent.refresh(type: type))), + _dataService.inventory.itemAddedToInventory.stream.listen((type) => add(InventoryEvent.refresh(type: type))), + _dataService.inventory.itemDeletedFromInventory.stream.listen((type) => add(InventoryEvent.refresh(type: type))), + _dataService.inventory.itemUpdatedInInventory.stream.listen((type) => add(InventoryEvent.refresh(type: type))), ]; } @@ -35,50 +35,56 @@ class InventoryBloc extends Bloc { Stream mapEventToState(InventoryEvent event) async* { final s = await event.map( init: (_) async { - final characters = _dataService.getAllCharactersInInventory(); - final weapons = _dataService.getAllWeaponsInInventory(); - final materials = _dataService.getAllMaterialsInInventory(); + final characters = _dataService.inventory.getAllCharactersInInventory(); + final weapons = _dataService.inventory.getAllWeaponsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return InventoryState.loaded(characters: characters, weapons: weapons, materials: materials); }, addCharacter: (e) async { await _telemetryService.trackItemAddedToInventory(e.key, 1); - await _dataService.addCharacterToInventory(e.key, raiseEvent: false); + await _dataService.inventory.addCharacterToInventory(e.key, raiseEvent: false); return _refreshItems(ItemType.character); }, addWeapon: (e) async { await _telemetryService.trackItemAddedToInventory(e.key, 1); - await _dataService.addWeaponToInventory(e.key, raiseEvent: false); + await _dataService.inventory.addWeaponToInventory(e.key, raiseEvent: false); return _refreshItems(ItemType.weapon); }, deleteCharacter: (e) async { await _telemetryService.trackItemDeletedFromInventory(e.key); - await _dataService.deleteCharacterFromInventory(e.key, raiseEvent: false); + await _dataService.inventory.deleteCharacterFromInventory(e.key, raiseEvent: false); return _refreshItems(ItemType.character); }, deleteWeapon: (e) async { await _telemetryService.trackItemDeletedFromInventory(e.key); - await _dataService.deleteWeaponFromInventory(e.key, raiseEvent: false); + await _dataService.inventory.deleteWeaponFromInventory(e.key, raiseEvent: false); return _refreshItems(ItemType.weapon); }, updateMaterial: (e) async { await _telemetryService.trackItemUpdatedInInventory(e.key, e.quantity); - await _dataService.updateItemInInventory(e.key, ItemType.material, e.quantity, raiseEvent: false); + await _dataService.inventory.updateItemInInventory( + e.key, + ItemType.material, + e.quantity, + _dataService.calculator.redistributeInventoryMaterial, + raiseEvent: false, + ); return _refreshItems(ItemType.material); }, clearAllCharacters: (_) async { await _telemetryService.trackItemsDeletedFromInventory(ItemType.character); - await _dataService.deleteItemsFromInventory(ItemType.character, raiseEvent: false); + await _dataService.inventory.deleteItemsFromInventory(ItemType.character, raiseEvent: false); return state.copyWith.call(characters: []); }, clearAllWeapons: (_) async { await _telemetryService.trackItemsDeletedFromInventory(ItemType.weapon); - await _dataService.deleteItemsFromInventory(ItemType.weapon, raiseEvent: false); + await _dataService.inventory.deleteItemsFromInventory(ItemType.weapon, raiseEvent: false); return state.copyWith.call(weapons: []); }, clearAllMaterials: (_) async { await _telemetryService.trackItemsDeletedFromInventory(ItemType.material); - await _dataService.deleteItemsFromInventory(ItemType.material, raiseEvent: false); + await _dataService.inventory.deleteItemsFromInventory(ItemType.material, raiseEvent: false); return _refreshItems(ItemType.material); }, refresh: (e) async => _refreshItems(e.type), @@ -96,13 +102,13 @@ class InventoryBloc extends Bloc { InventoryState _refreshItems(ItemType type) { switch (type) { case ItemType.character: - return state.copyWith.call(characters: _dataService.getAllCharactersInInventory()); + return state.copyWith.call(characters: _dataService.inventory.getAllCharactersInInventory()); case ItemType.weapon: - return state.copyWith.call(weapons: _dataService.getAllWeaponsInInventory()); + return state.copyWith.call(weapons: _dataService.inventory.getAllWeaponsInInventory()); case ItemType.artifact: throw Exception('Not implemented'); case ItemType.material: - return state.copyWith.call(materials: _dataService.getAllMaterialsInInventory()); + return state.copyWith.call(materials: _dataService.inventory.getAllMaterialsInInventory()); } } diff --git a/lib/application/notification/notification_bloc.dart b/lib/application/notification/notification_bloc.dart index 7abc20502..ef38916e6 100644 --- a/lib/application/notification/notification_bloc.dart +++ b/lib/application/notification/notification_bloc.dart @@ -158,7 +158,7 @@ class NotificationBloc extends Bloc { } NotificationState _buildEditState(int key, AppNotificationType type) { - final item = _dataService.getNotification(key, type); + final item = _dataService.notifications.getNotification(key, type); NotificationState state; final images = []; switch (item.type) { @@ -381,7 +381,7 @@ class NotificationBloc extends Bloc { Future _saveResinNotification(_ResinState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateResinNotification( + final updated = await _dataService.notifications.updateResinNotification( s.key!, selectedItemKey, s.title, @@ -394,7 +394,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveResinNotification( + final notif = await _dataService.notifications.saveResinNotification( selectedItemKey, s.title, s.body, @@ -408,7 +408,7 @@ class NotificationBloc extends Bloc { Future _saveExpeditionNotification(_ExpeditionState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateExpeditionNotification( + final updated = await _dataService.notifications.updateExpeditionNotification( s.key!, selectedItemKey, s.expeditionTimeType, @@ -422,7 +422,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveExpeditionNotification( + final notif = await _dataService.notifications.saveExpeditionNotification( selectedItemKey, s.title, s.body, @@ -437,7 +437,7 @@ class NotificationBloc extends Bloc { Future _saveFarmingArtifactNotification(_FarmingArtifactState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateFarmingArtifactNotification( + final updated = await _dataService.notifications.updateFarmingArtifactNotification( s.key!, selectedItemKey, s.artifactFarmingTimeType, @@ -450,7 +450,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveFarmingArtifactNotification( + final notif = await _dataService.notifications.saveFarmingArtifactNotification( selectedItemKey, s.artifactFarmingTimeType, s.title, @@ -464,7 +464,7 @@ class NotificationBloc extends Bloc { Future _saveFarmingMaterialNotification(_FarmingMaterialState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateFarmingMaterialNotification( + final updated = await _dataService.notifications.updateFarmingMaterialNotification( s.key!, selectedItemKey, s.title, @@ -476,7 +476,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveFarmingMaterialNotification( + final notif = await _dataService.notifications.saveFarmingMaterialNotification( selectedItemKey, s.title, s.body, @@ -489,7 +489,7 @@ class NotificationBloc extends Bloc { Future _saveGadgetNotification(_GadgetState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateGadgetNotification( + final updated = await _dataService.notifications.updateGadgetNotification( s.key!, selectedItemKey, s.title, @@ -501,7 +501,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveGadgetNotification( + final notif = await _dataService.notifications.saveGadgetNotification( selectedItemKey, s.title, s.body, @@ -514,7 +514,7 @@ class NotificationBloc extends Bloc { Future _saveFurnitureNotification(_FurnitureState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateFurnitureNotification( + final updated = await _dataService.notifications.updateFurnitureNotification( s.key!, selectedItemKey, s.timeType, @@ -527,7 +527,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveFurnitureNotification( + final notif = await _dataService.notifications.saveFurnitureNotification( selectedItemKey, s.timeType, s.title, @@ -541,7 +541,7 @@ class NotificationBloc extends Bloc { Future _saveRealmCurrencyNotification(_RealmCurrencyState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateRealmCurrencyNotification( + final updated = await _dataService.notifications.updateRealmCurrencyNotification( s.key!, selectedItemKey, s.currentRealmRankType, @@ -556,7 +556,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveRealmCurrencyNotification( + final notif = await _dataService.notifications.saveRealmCurrencyNotification( selectedItemKey, s.currentRealmRankType, s.currentTrustRank, @@ -572,7 +572,7 @@ class NotificationBloc extends Bloc { Future _saveWeeklyBossNotification(_WeeklyBossState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateWeeklyBossNotification( + final updated = await _dataService.notifications.updateWeeklyBossNotification( s.key!, _settingsService.serverResetTime, selectedItemKey, @@ -585,7 +585,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveWeeklyBossNotification( + final notif = await _dataService.notifications.saveWeeklyBossNotification( selectedItemKey, _settingsService.serverResetTime, s.title, @@ -599,7 +599,7 @@ class NotificationBloc extends Bloc { Future _saveCustomNotification(_CustomState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateCustomNotification( + final updated = await _dataService.notifications.updateCustomNotification( s.key!, selectedItemKey, s.title, @@ -613,7 +613,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveCustomNotification( + final notif = await _dataService.notifications.saveCustomNotification( selectedItemKey, s.title, s.body, @@ -628,7 +628,7 @@ class NotificationBloc extends Bloc { Future _saveDailyCheckInNotification(_DailyCheckInState s) async { final selectedItemKey = _getSelectedItemKey(); if (s.key != null) { - final updated = await _dataService.updateDailyCheckInNotification( + final updated = await _dataService.notifications.updateDailyCheckInNotification( s.key!, selectedItemKey, s.title, @@ -640,7 +640,7 @@ class NotificationBloc extends Bloc { return; } - final notif = await _dataService.saveDailyCheckInNotification( + final notif = await _dataService.notifications.saveDailyCheckInNotification( selectedItemKey, s.title, s.body, diff --git a/lib/application/notifications/notifications_bloc.dart b/lib/application/notifications/notifications_bloc.dart index b34f0d945..59e2c25b8 100644 --- a/lib/application/notifications/notifications_bloc.dart +++ b/lib/application/notifications/notifications_bloc.dart @@ -36,7 +36,7 @@ class NotificationsBloc extends Bloc { } NotificationsState _buildInitialState() { - final notifications = _dataService.getAllNotifications(); + final notifications = _dataService.notifications.getAllNotifications(); return NotificationsState.initial( notifications: notifications, useTwentyFourHoursFormat: _settingsService.useTwentyFourHoursFormat, @@ -44,7 +44,7 @@ class NotificationsBloc extends Bloc { } Future _deleteNotification(int key, AppNotificationType type) async { - await _dataService.deleteNotification(key, type); + await _dataService.notifications.deleteNotification(key, type); await _notificationService.cancelNotification(key, type); final notifications = [...state.notifications]; notifications.removeWhere((el) => el.key == key && el.type == type); @@ -53,7 +53,7 @@ class NotificationsBloc extends Bloc { } Future _resetNotification(int key, AppNotificationType type) async { - final notif = await _dataService.resetNotification(key, type, _settingsService.serverResetTime); + final notif = await _dataService.notifications.resetNotification(key, type, _settingsService.serverResetTime); await _notificationService.cancelNotification(key, type); await _notificationService.scheduleNotification(key, type, notif.title, notif.body, notif.completesAt); await _telemetryService.trackNotificationRestarted(type); @@ -61,7 +61,7 @@ class NotificationsBloc extends Bloc { } Future _stopNotification(int key, AppNotificationType type) async { - final notif = await _dataService.stopNotification(key, type); + final notif = await _dataService.notifications.stopNotification(key, type); await _notificationService.cancelNotification(key, type); await _telemetryService.trackNotificationStopped(type); return _afterUpdatingNotification(notif); @@ -76,7 +76,7 @@ class NotificationsBloc extends Bloc { } Future _reduceHours(int key, AppNotificationType type, int hours) async { - final notif = await _dataService.reduceNotificationHours(key, type, hours); + final notif = await _dataService.notifications.reduceNotificationHours(key, type, hours); await _notificationService.cancelNotification(key, type); await _notificationService.scheduleNotification(key, type, notif.title, notif.body, notif.completesAt); return _afterUpdatingNotification(notif); diff --git a/lib/application/tier_list/tier_list_bloc.dart b/lib/application/tier_list/tier_list_bloc.dart index fb7dc67de..2ca1fbc44 100644 --- a/lib/application/tier_list/tier_list_bloc.dart +++ b/lib/application/tier_list/tier_list_bloc.dart @@ -65,10 +65,10 @@ class TierListBloc extends Bloc { Future _init(bool reset) async { await _telemetryService.trackTierListOpened(); if (reset) { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); } - final tierList = _dataService.getTierList(); + final tierList = _dataService.tierList.getTierList(); final defaultTierList = _genshinService.getDefaultCharacterTierList(defaultColors); if (tierList.isEmpty) { return TierListState.loaded(rows: defaultTierList, charsAvailable: [], readyToSave: false); @@ -82,21 +82,21 @@ class TierListBloc extends Bloc { Future _rowTextChanged(int index, String newValue) async { final updated = currentState.rows.elementAt(index).copyWith.call(tierText: newValue); final rows = _updateRows(updated, index, index); - await _dataService.saveTierList(rows); + await _dataService.tierList.saveTierList(rows); return currentState.copyWith.call(rows: rows); } Future _rowPositionChanged(int index, int newIndex) async { final updated = currentState.rows.elementAt(index); final rows = _updateRows(updated, newIndex, index); - await _dataService.saveTierList(rows); + await _dataService.tierList.saveTierList(rows); return currentState.copyWith.call(rows: rows); } Future _rowColorChanged(int index, int newColor) async { final updated = currentState.rows.elementAt(index).copyWith.call(tierColor: newColor); final rows = _updateRows(updated, index, index); - await _dataService.saveTierList(rows); + await _dataService.tierList.saveTierList(rows); return currentState.copyWith.call(rows: rows); } @@ -108,7 +108,7 @@ class TierListBloc extends Bloc { final newRow = TierListRowModel.row(tierText: (currentState.rows.length + 1).toString(), tierColor: color, items: []); final rows = [...currentState.rows]; rows.insert(newIndex, newRow); - await _dataService.saveTierList(rows); + await _dataService.tierList.saveTierList(rows); return currentState.copyWith.call(rows: rows); } @@ -120,7 +120,7 @@ class TierListBloc extends Bloc { final row = rows.elementAt(index); final chars = _updateAvailableChars([...currentState.charsAvailable, ...row.items], []); rows.removeAt(index); - await _dataService.saveTierList(rows); + await _dataService.tierList.saveTierList(rows); return currentState.copyWith.call(rows: rows, charsAvailable: chars); } @@ -129,14 +129,14 @@ class TierListBloc extends Bloc { final updated = row.copyWith.call(items: []); final rows = _updateRows(updated, index, index); final chars = _updateAvailableChars([...currentState.charsAvailable, ...row.items], []); - await _dataService.saveTierList(rows); + await _dataService.tierList.saveTierList(rows); return currentState.copyWith.call(rows: rows, charsAvailable: chars); } Future _clearAllRows() async { final chars = _updateAvailableChars(_genshinService.getDefaultCharacterTierList(defaultColors).expand((row) => row.items).toList(), []); final updatedRows = currentState.rows.map((row) => row.copyWith.call(items: [])).toList(); - await _dataService.saveTierList(updatedRows); + await _dataService.tierList.saveTierList(updatedRows); return currentState.copyWith.call(rows: updatedRows, charsAvailable: chars, readyToSave: false); } @@ -148,7 +148,7 @@ class TierListBloc extends Bloc { final updated = row.copyWith.call(items: [...row.items, item]); final updatedChars = _updateAvailableChars(currentState.charsAvailable, [item]); final updatedRows = _updateRows(updated, index, index); - await _dataService.saveTierList(updatedRows); + await _dataService.tierList.saveTierList(updatedRows); return currentState.copyWith.call(rows: updatedRows, charsAvailable: updatedChars); } @@ -157,7 +157,7 @@ class TierListBloc extends Bloc { final updated = row.copyWith.call(items: row.items.where((el) => el.key != item.key).toList()); final updatedChars = _updateAvailableChars([...currentState.charsAvailable, item], []); final updatedRows = _updateRows(updated, index, index); - await _dataService.saveTierList(updatedRows); + await _dataService.tierList.saveTierList(updatedRows); return currentState.copyWith.call(rows: updatedRows, charsAvailable: updatedChars, readyToSave: false); } diff --git a/lib/application/weapon/weapon_bloc.dart b/lib/application/weapon/weapon_bloc.dart index 6d70f148e..9aac4a6fc 100644 --- a/lib/application/weapon/weapon_bloc.dart +++ b/lib/application/weapon/weapon_bloc.dart @@ -32,7 +32,7 @@ class WeaponBloc extends Bloc { loading: (state) async => state, loaded: (state) async { await _telemetryService.trackItemAddedToInventory(key, 1); - await _dataService.addWeaponToInventory(key); + await _dataService.inventory.addWeaponToInventory(key); return state.copyWith.call(isInInventory: true); }, ), @@ -40,7 +40,7 @@ class WeaponBloc extends Bloc { loading: (state) async => state, loaded: (state) async { await _telemetryService.trackItemDeletedFromInventory(key); - await _dataService.deleteWeaponFromInventory(key); + await _dataService.inventory.deleteWeaponFromInventory(key); return state.copyWith.call(isInInventory: false); }, ), @@ -76,7 +76,7 @@ class WeaponBloc extends Bloc { secondaryStatValue: weapon.secondaryStatValue, description: translation.description, locationType: weapon.location, - isInInventory: _dataService.isItemInInventory(weapon.key, ItemType.weapon), + isInInventory: _dataService.inventory.isItemInInventory(weapon.key, ItemType.weapon), ascensionMaterials: ascensionMaterials, refinements: refinements, characters: charImgs, diff --git a/test/application/character/character_bloc_test.dart b/test/application/character/character_bloc_test.dart index 26c6e39d2..2d6a5ae83 100644 --- a/test/application/character/character_bloc_test.dart +++ b/test/application/character/character_bloc_test.dart @@ -93,7 +93,7 @@ void main() { 'keqing is in inventory', build: () => CharacterBloc(_genshinService, _telemetryService, _localeService, _dataService), setUp: () { - _dataService.addItemToInventory('keqing', ItemType.character, 1); + _dataService.inventory.addItemToInventory('keqing', ItemType.character, 1); }, act: (bloc) => bloc.add(const CharacterEvent.loadFromKey(key: 'keqing')), //we skip 1 because since the event is not _AddedToInventory the bloc will emit a loading diff --git a/test/application/game_codes/game_codes_bloc_test.dart b/test/application/game_codes/game_codes_bloc_test.dart index ff3d28f90..12b057e49 100644 --- a/test/application/game_codes/game_codes_bloc_test.dart +++ b/test/application/game_codes/game_codes_bloc_test.dart @@ -85,7 +85,7 @@ void main() { 'some game codes have been loaded', build: () => GameCodesBloc(_dataService, _telemetryService, _gameCodeService, _networkService), setUp: () async { - await _dataService.saveGameCodes(_defaultGameCodes); + await _dataService.gameCodes.saveGameCodes(_defaultGameCodes); }, tearDown: () async { await _dataService.deleteThemAll(); @@ -121,7 +121,7 @@ void main() { 'Mark as used', build: () => GameCodesBloc(_dataService, _telemetryService, _gameCodeService, _networkService), setUp: () async { - await _dataService.saveGameCodes(_defaultGameCodes); + await _dataService.gameCodes.saveGameCodes(_defaultGameCodes); }, tearDown: () async { await _dataService.deleteThemAll(); diff --git a/test/application/inventory/inventory_bloc_test.dart b/test/application/inventory/inventory_bloc_test.dart index 67a02e833..a6d7ecf2f 100644 --- a/test/application/inventory/inventory_bloc_test.dart +++ b/test/application/inventory/inventory_bloc_test.dart @@ -71,7 +71,7 @@ void main() { expect: () { final character = _genshinService.getCharacterForCard(_keqingKey); final weapon = _genshinService.getWeaponForCard(_aquilaFavoniaKey); - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); final material = materials.firstWhere((el) => el.key == _moraKey); expect(material.quantity, 20000); return [ @@ -97,7 +97,7 @@ void main() { skip: 1, expect: () { final character = _genshinService.getCharacterForCard(_keqingKey); - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return [ InventoryState.loaded( characters: [character], @@ -120,7 +120,7 @@ void main() { skip: 1, expect: () { final weapon = _genshinService.getWeaponForCard(_aquilaFavoniaKey); - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return [ InventoryState.loaded( characters: [], @@ -142,7 +142,7 @@ void main() { ..add(const InventoryEvent.updateMaterial(key: _moraKey, quantity: 100000)), skip: 1, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); final material = materials.firstWhere((el) => el.key == _moraKey); expect(material.quantity, 100000); return [ @@ -170,7 +170,7 @@ void main() { //here I skip only 2 cause the init event does not make an state change skip: 2, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return [ InventoryState.loaded( characters: [], @@ -194,7 +194,7 @@ void main() { //here I skip only 2 cause the init event does not make an state change skip: 2, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return [ InventoryState.loaded( characters: [], @@ -218,7 +218,7 @@ void main() { //here I skip only 1 cause the init event does not make an state change skip: 1, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); final material = materials.firstWhere((el) => el.key == _moraKey); expect(material.quantity, 0); return [ @@ -245,7 +245,7 @@ void main() { ..add(const InventoryEvent.clearAllCharacters()), skip: 2, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return [ InventoryState.loaded( characters: [], @@ -268,7 +268,7 @@ void main() { ..add(const InventoryEvent.clearAllWeapons()), skip: 2, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); return [ InventoryState.loaded( characters: [], @@ -291,7 +291,7 @@ void main() { ..add(const InventoryEvent.clearAllMaterials()), skip: 2, expect: () { - final materials = _dataService.getAllMaterialsInInventory(); + final materials = _dataService.inventory.getAllMaterialsInInventory(); expect(materials.every((el) => el.quantity == 0), isTrue); return [ InventoryState.loaded( diff --git a/test/application/notification/notification_bloc_test.dart b/test/application/notification/notification_bloc_test.dart index 232b038ea..175ab9217 100644 --- a/test/application/notification/notification_bloc_test.dart +++ b/test/application/notification/notification_bloc_test.dart @@ -140,14 +140,14 @@ void main() { blocTest( 'a resin notification', setUp: () async { - await _dataService.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 60, note: _defaultNote); + await _dataService.notifications.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 60, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.resin)); }, verify: (bloc) => bloc.state.maybeMap( @@ -164,7 +164,7 @@ void main() { 'an expedition notification', setUp: () async { final material = _genshinService.getAllMaterialsThatCanBeObtainedFromAnExpedition().first; - await _dataService.saveExpeditionNotification( + await _dataService.notifications.saveExpeditionNotification( material.key, _defaultTitle, _defaultBody, @@ -178,7 +178,7 @@ void main() { }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.expedition)); }, verify: (bloc) => bloc.state.maybeMap( @@ -196,7 +196,7 @@ void main() { 'a farming artifact notification', setUp: () async { final artifact = _genshinService.getArtifactsForCard().first; - await _dataService.saveFarmingArtifactNotification( + await _dataService.notifications.saveFarmingArtifactNotification( artifact.key, ArtifactFarmingTimeType.twelveHours, _defaultTitle, @@ -209,7 +209,7 @@ void main() { }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.farmingArtifacts)); }, verify: (bloc) => bloc.state.maybeMap( @@ -226,14 +226,14 @@ void main() { 'a farming material notification', setUp: () async { final material = _genshinService.getAllMaterialsThatHaveAFarmingRespawnDuration().first; - await _dataService.saveFarmingMaterialNotification(material.key, _defaultTitle, _defaultBody, note: _defaultNote); + await _dataService.notifications.saveFarmingMaterialNotification(material.key, _defaultTitle, _defaultBody, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.farmingMaterials)); }, verify: (bloc) => bloc.state.maybeMap( @@ -249,14 +249,14 @@ void main() { 'a gadget notification', setUp: () async { final gadget = _genshinService.getAllGadgetsForNotifications().first; - await _dataService.saveGadgetNotification(gadget.key, _defaultTitle, _defaultBody, note: _defaultNote); + await _dataService.notifications.saveGadgetNotification(gadget.key, _defaultTitle, _defaultBody, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.gadget)); }, verify: (bloc) => bloc.state.maybeMap( @@ -272,7 +272,7 @@ void main() { 'a furniture notification', setUp: () async { final furniture = _genshinService.getDefaultFurnitureForNotifications(); - await _dataService.saveFurnitureNotification( + await _dataService.notifications.saveFurnitureNotification( furniture.key, FurnitureCraftingTimeType.fourteenHours, _defaultTitle, @@ -285,7 +285,7 @@ void main() { }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.furniture)); }, verify: (bloc) => bloc.state.maybeMap( @@ -301,7 +301,7 @@ void main() { blocTest( 'a realm currency notification', setUp: () async { - await _dataService.saveRealmCurrencyNotification( + await _dataService.notifications.saveRealmCurrencyNotification( _realmCurrency, RealmRankType.luxury, 7, @@ -316,7 +316,7 @@ void main() { }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.realmCurrency)); }, verify: (bloc) => bloc.state.maybeMap( @@ -335,7 +335,7 @@ void main() { 'a weekly boss notification', setUp: () async { final boss = _genshinService.getAllMonstersForCard().where((el) => el.type == MonsterType.boss).first; - await _dataService.saveWeeklyBossNotification( + await _dataService.notifications.saveWeeklyBossNotification( boss.key, _settingsService.serverResetTime, _defaultTitle, @@ -348,7 +348,7 @@ void main() { }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.weeklyBoss)); }, verify: (bloc) => bloc.state.maybeMap( @@ -363,14 +363,14 @@ void main() { blocTest( 'a daily check in notification', setUp: () async { - await _dataService.saveDailyCheckInNotification(_primogemKey, _defaultTitle, _defaultBody, note: _defaultNote); + await _dataService.notifications.saveDailyCheckInNotification(_primogemKey, _defaultTitle, _defaultBody, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.dailyCheckIn)); }, verify: (bloc) => bloc.state.maybeMap( @@ -409,14 +409,15 @@ void main() { default: throw Exception('Not mapped type'); } - await _dataService.saveCustomNotification(key, _defaultTitle, _defaultBody, _customNotificationCompletesAt, type, note: _defaultNote); + await _dataService.notifications + .saveCustomNotification(key, _defaultTitle, _defaultBody, _customNotificationCompletesAt, type, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, build: () => _buildBloc(), act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.custom)); }, verify: (bloc) => bloc.state.maybeMap( @@ -454,13 +455,13 @@ void main() { 'on an existing notification', build: () => _buildBloc(), setUp: () async { - await _dataService.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 60, note: _defaultNote); + await _dataService.notifications.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 60, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.resin)) ..add(const NotificationEvent.titleChanged(newValue: 'Title')) @@ -499,13 +500,13 @@ void main() { 'on an existing notification', build: () => _buildBloc(), setUp: () async { - await _dataService.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 60, note: _defaultNote); + await _dataService.notifications.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 60, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.resin)) ..add(const NotificationEvent.resinChanged(newValue: 100)); @@ -545,7 +546,7 @@ void main() { 'on an existing notification', build: () => _buildBloc(), setUp: () async { - await _dataService.saveExpeditionNotification( + await _dataService.notifications.saveExpeditionNotification( 'mora', _defaultTitle, _defaultBody, @@ -558,7 +559,7 @@ void main() { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.expedition)) ..add(const NotificationEvent.expeditionTimeTypeChanged(newValue: ExpeditionTimeType.eightHours)) @@ -599,7 +600,7 @@ void main() { build: () => _buildBloc(), setUp: () async { final artifact = _genshinService.getArtifactsForCard().first; - await _dataService.saveFarmingArtifactNotification( + await _dataService.notifications.saveFarmingArtifactNotification( artifact.key, ArtifactFarmingTimeType.twelveHours, _defaultTitle, @@ -611,7 +612,7 @@ void main() { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.farmingArtifacts)) ..add(const NotificationEvent.artifactFarmingTimeTypeChanged(newValue: ArtifactFarmingTimeType.twentyFourHours)); @@ -654,13 +655,13 @@ void main() { build: () => _buildBloc(), setUp: () async { final material = _genshinService.getAllMaterialsThatHaveAFarmingRespawnDuration().first; - await _dataService.saveFarmingMaterialNotification(material.key, _defaultTitle, _defaultBody, note: _defaultNote); + await _dataService.notifications.saveFarmingMaterialNotification(material.key, _defaultTitle, _defaultBody, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; final newMaterial = _genshinService.getAllMaterialsThatHaveAFarmingRespawnDuration().last; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.farmingMaterials)) @@ -705,13 +706,13 @@ void main() { build: () => _buildBloc(), setUp: () async { final gadget = _genshinService.getAllGadgetsForNotifications().first; - await _dataService.saveGadgetNotification(gadget.key, _defaultTitle, _defaultBody, note: _defaultNote); + await _dataService.notifications.saveGadgetNotification(gadget.key, _defaultTitle, _defaultBody, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; final gadget = _genshinService.getAllGadgetsForNotifications().last; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.gadget)) @@ -752,7 +753,7 @@ void main() { build: () => _buildBloc(), setUp: () async { final furniture = _genshinService.getDefaultFurnitureForNotifications(); - await _dataService.saveFurnitureNotification( + await _dataService.notifications.saveFurnitureNotification( furniture.key, FurnitureCraftingTimeType.sixteenHours, _defaultTitle, @@ -764,7 +765,7 @@ void main() { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.furniture)) ..add(const NotificationEvent.furnitureCraftingTimeTypeChanged(newValue: FurnitureCraftingTimeType.sixteenHours)); @@ -806,7 +807,7 @@ void main() { 'on an existing notification', build: () => _buildBloc(), setUp: () async { - await _dataService.saveRealmCurrencyNotification( + await _dataService.notifications.saveRealmCurrencyNotification( _realmCurrency, RealmRankType.luxury, 10, @@ -820,7 +821,7 @@ void main() { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.realmCurrency)) ..add(const NotificationEvent.realmCurrencyChanged(newValue: 1000)) @@ -861,7 +862,7 @@ void main() { build: () => _buildBloc(), setUp: () async { final boss = _genshinService.getAllMonstersForCard().firstWhere((el) => el.type == MonsterType.boss).key; - await _dataService.saveWeeklyBossNotification( + await _dataService.notifications.saveWeeklyBossNotification( boss, AppServerResetTimeType.northAmerica, _defaultTitle, @@ -874,7 +875,7 @@ void main() { }, act: (bloc) { final boss = _genshinService.getAllMonstersForCard().lastWhere((el) => el.type == MonsterType.boss); - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.weeklyBoss)) ..add(NotificationEvent.imageChanged(newValue: boss.image)); @@ -914,7 +915,7 @@ void main() { build: () => _buildBloc(), setUp: () async { final boss = _genshinService.getAllMonstersForCard().firstWhere((el) => el.type == MonsterType.boss).key; - await _dataService.saveCustomNotification( + await _dataService.notifications.saveCustomNotification( boss, _defaultTitle, _defaultBody, @@ -927,7 +928,7 @@ void main() { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc ..add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.custom)) ..add(const NotificationEvent.itemTypeChanged(newValue: AppNotificationItemType.artifact)); @@ -963,13 +964,13 @@ void main() { 'on an existing notification', build: () => _buildBloc(), setUp: () async { - await _dataService.saveDailyCheckInNotification(_primogemKey, _defaultTitle, _defaultBody, note: _defaultNote); + await _dataService.notifications.saveDailyCheckInNotification(_primogemKey, _defaultTitle, _defaultBody, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); }, act: (bloc) { - final notification = _dataService.getAllNotifications().first; + final notification = _dataService.notifications.getAllNotifications().first; return bloc.add(NotificationEvent.edit(key: notification.key, type: AppNotificationType.dailyCheckIn)); }, verify: (bloc) => bloc.state.maybeMap( diff --git a/test/application/notifications/notifications_bloc_test.dart b/test/application/notifications/notifications_bloc_test.dart index e8b845a75..79bf5ff6e 100644 --- a/test/application/notifications/notifications_bloc_test.dart +++ b/test/application/notifications/notifications_bloc_test.dart @@ -67,7 +67,7 @@ void main() { 'Init', build: () => NotificationsBloc(_dataService, _notificationService, _settingsService, _telemetryService), setUp: () async { - await _dataService.saveCustomNotification( + await _dataService.notifications.saveCustomNotification( _keqingKey, _defaultTitle, _defaultBody, @@ -100,7 +100,7 @@ void main() { blocTest( 'Delete', setUp: () async { - await _dataService.saveCustomNotification( + await _dataService.notifications.saveCustomNotification( _keqingKey, _defaultTitle, _defaultBody, @@ -123,7 +123,7 @@ void main() { blocTest( 'Reset', setUp: () async { - await _dataService.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 100, note: _defaultNote); + await _dataService.notifications.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 100, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); @@ -152,7 +152,7 @@ void main() { blocTest( 'Stop', setUp: () async { - await _dataService.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 100, note: _defaultNote); + await _dataService.notifications.saveResinNotification(_fragileResinKey, _defaultTitle, _defaultBody, 100, note: _defaultNote); }, tearDown: () async { await _dataService.deleteThemAll(); @@ -181,7 +181,7 @@ void main() { blocTest( 'Reduce hours', setUp: () async { - await _dataService.saveCustomNotification( + await _dataService.notifications.saveCustomNotification( _keqingKey, _defaultTitle, _defaultBody, diff --git a/test/application/tier_list/tier_list_bloc_test.dart b/test/application/tier_list/tier_list_bloc_test.dart index fbba18f1e..4bc5a7f59 100644 --- a/test/application/tier_list/tier_list_bloc_test.dart +++ b/test/application/tier_list/tier_list_bloc_test.dart @@ -67,13 +67,13 @@ void main() { 'should return custom tier list', setUp: () async { final defaultTierList = _genshinService.getDefaultCharacterTierList(TierListBloc.defaultColors); - await _dataService.saveTierList([ + await _dataService.tierList.saveTierList([ TierListRowModel.row(tierText: 'SSS', tierColor: TierListBloc.defaultColors.first, items: defaultTierList.first.items), TierListRowModel.row(tierText: 'SS', tierColor: TierListBloc.defaultColors[1], items: defaultTierList.last.items), ]); }, tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), act: (bloc) => bloc.add(const TierListEvent.init()), @@ -89,7 +89,7 @@ void main() { 'custom tier list exist but a reset is made', setUp: () async { final defaultTierList = _genshinService.getDefaultCharacterTierList(TierListBloc.defaultColors); - await _dataService.saveTierList([ + await _dataService.tierList.saveTierList([ TierListRowModel.row(tierText: 'SSS', tierColor: TierListBloc.defaultColors.first, items: defaultTierList.first.items), TierListRowModel.row(tierText: 'SS', tierColor: TierListBloc.defaultColors[1], items: defaultTierList.last.items), ]); @@ -111,7 +111,7 @@ void main() { 'text changed', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -125,7 +125,7 @@ void main() { 'position changed', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -141,7 +141,7 @@ void main() { 'color changed', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -154,7 +154,7 @@ void main() { blocTest( 'add character', tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), act: (bloc) { @@ -173,7 +173,7 @@ void main() { blocTest( 'delete character', tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), act: (bloc) { @@ -195,7 +195,7 @@ void main() { 'add new one above the first one', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -211,7 +211,7 @@ void main() { 'add new one below the first one', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -227,7 +227,7 @@ void main() { 'clear', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -242,7 +242,7 @@ void main() { 'clear all', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -259,7 +259,7 @@ void main() { 'was successfully taken', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) @@ -274,7 +274,7 @@ void main() { 'could not be taken', build: () => TierListBloc(_genshinService, _dataService, _telemetryService, _loggingService), tearDown: () async { - await _dataService.deleteTierList(); + await _dataService.tierList.deleteTierList(); }, act: (bloc) => bloc ..add(const TierListEvent.init()) diff --git a/test/application/weapon/weapon_bloc_test.dart b/test/application/weapon/weapon_bloc_test.dart index 6a67c9af8..0f1a764f3 100644 --- a/test/application/weapon/weapon_bloc_test.dart +++ b/test/application/weapon/weapon_bloc_test.dart @@ -83,7 +83,7 @@ void main() { 'keqing is in inventory', build: () => WeaponBloc(_genshinService, _telemetryService, _dataService), setUp: () { - _dataService.addItemToInventory(_key, ItemType.weapon, 1); + _dataService.inventory.addItemToInventory(_key, ItemType.weapon, 1); }, act: (bloc) => bloc.add(const WeaponEvent.loadFromKey(key: _key)), //we skip 1 because since the event is not _AddedToInventory the bloc will emit a loading diff --git a/test/infrastructure/data_service_test.dart b/test/infrastructure/data_service_test.dart index 4425553d7..79621523f 100644 --- a/test/infrastructure/data_service_test.dart +++ b/test/infrastructure/data_service_test.dart @@ -44,11 +44,11 @@ void main() { group('Sessions', () { test('create 1 session with 1 item', () async { - final existingSessions = _dataService.getAllCalAscMatSessions(); + final existingSessions = _dataService.calculator.getAllCalAscMatSessions(); expect(existingSessions.length, equals(0)); const sessionName = 'Keqing session'; - final sessionKey = await _dataService.createCalAscMatSession(sessionName, 0); + final sessionKey = await _dataService.calculator.createCalAscMatSession(sessionName, 0); final char = _genshinService.getCharacter('keqing'); const currentAscensionLevel = 1; const desiredAscensionLevel = 5; @@ -102,9 +102,9 @@ void main() { useMaterialsFromInventory: false, ), ); - await _dataService.addCalAscMatSessionItems(sessionKey, items); + await _dataService.calculator.addCalAscMatSessionItems(sessionKey, items); - final created = _dataService.getCalcAscMatSession(sessionKey); + final created = _dataService.calculator.getCalcAscMatSession(sessionKey); expect(created.key, sessionKey); expect(created.name, equals(sessionName)); expect(created.items, isNotEmpty);