Skip to content

Commit

Permalink
feat: packages/alice_objectbox
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Jun 28, 2024
1 parent ef6b620 commit dbf32ce
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions packages/alice/lib/core/alice_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ class AliceCore {
/// Icon url for notification
final String notificationIcon;

final AliceStorage aliceStorage;
final AliceStorage _aliceStorage;

@protected
late final NotificationDetails notificationDetails = NotificationDetails(
late final NotificationDetails _notificationDetails = NotificationDetails(
android: AndroidNotificationDetails(
'Alice',
'Alice',
Expand Down Expand Up @@ -78,14 +77,14 @@ class AliceCore {
required this.showInspectorOnShake,
required this.notificationIcon,
required this.maxCallsCount,
required this.aliceStorage,
required AliceStorage aliceStorage,
this.directionality,
this.showShareButton,
}) {
}) : _aliceStorage = aliceStorage {
if (showNotification) {
_initializeNotificationsPlugin();
_requestNotificationPermissions();
aliceStorage.subscribeToCallChanges(onCallsChanged);
_aliceStorage.subscribeToCallChanges(onCallsChanged);
}
if (showInspectorOnShake) {
if (Platform.isAndroid || Platform.isIOS) {
Expand Down Expand Up @@ -127,7 +126,7 @@ class AliceCore {
@protected
Future<void> onCallsChanged(List<AliceHttpCall>? calls) async {
if (calls != null && calls.isNotEmpty) {
final AliceStats stats = aliceStorage.getStats();
final AliceStats stats = _aliceStorage.getStats();

_notificationMessage = _getNotificationMessage(stats);
if (_notificationMessage != _notificationMessageShown &&
Expand Down Expand Up @@ -210,7 +209,7 @@ class AliceCore {
0,
'Alice (total: ${stats.total} requests)',
message,
notificationDetails,
_notificationDetails,
payload: '',
);

Expand All @@ -221,34 +220,34 @@ class AliceCore {
}

/// Add alice http call to calls subject
void addCall(AliceHttpCall call) => aliceStorage.addCall(call);
void addCall(AliceHttpCall call) => _aliceStorage.addCall(call);

/// Add error to existing alice http call
void addError(AliceHttpError error, int requestId) =>
aliceStorage.addError(error, requestId);
_aliceStorage.addError(error, requestId);

/// Add response to existing alice http call
void addResponse(AliceHttpResponse response, int requestId) =>
aliceStorage.addResponse(response, requestId);
_aliceStorage.addResponse(response, requestId);

/// Add alice http call to calls subject
void addHttpCall(AliceHttpCall aliceHttpCall) =>
aliceStorage.addHttpCall(aliceHttpCall);
_aliceStorage.addHttpCall(aliceHttpCall);

/// Remove all calls from calls subject
void removeCalls() => aliceStorage.removeCalls();
void removeCalls() => _aliceStorage.removeCalls();

@protected
AliceHttpCall? selectCall(int requestId) =>
aliceStorage.selectCall(requestId);
_aliceStorage.selectCall(requestId);

Stream<List<AliceHttpCall>> get callsStream => aliceStorage.callsStream;
Stream<List<AliceHttpCall>> get callsStream => _aliceStorage.callsStream;

List<AliceHttpCall> getCalls() => aliceStorage.getCalls();
List<AliceHttpCall> getCalls() => _aliceStorage.getCalls();

/// Save all calls to file
void saveHttpRequests(BuildContext context) {
AliceSaveHelper.saveCalls(context, aliceStorage.getCalls());
AliceSaveHelper.saveCalls(context, _aliceStorage.getCalls());
}

/// Adds new log to Alice logger.
Expand Down

0 comments on commit dbf32ce

Please sign in to comment.