-
Notifications
You must be signed in to change notification settings - Fork 581
Feature - #551 - Auto Clear History #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - #551 - Auto Clear History #616
Conversation
History Service Implementation for Auto-Clearing API Requests
Team Dart Knight
- User -
Vishwa Karthik - Mail -
vishwa.prarthana@gmail.com
Do Checkout
Overview
This document outlines the implementation of the autoClearHistory feature in APIDASH to efficiently manage stored API request history while maintaining a smooth user experience across all supported platforms.
Features
Auto-Clear History on App Launch
-
When the app is launched, it automatically clears 50 old API records to prevent excessive local storage usage.
-
This helps in keeping the app responsive and prevents unnecessary memory consumption.
-
Triggered using autoClearHistory() from HistoryServiceImpl.
Dynamic Auto-Clear Trigger (State Management-Based)
-
Uses Riverpod StateNotifier to monitor the API request list dynamically.
-
If the length exceeds 50, the history clearance is automatically triggered, just to avoid heavy duty on app launch.
-
Reason to use State management here is to resist unnecessary local database call because user may keep switching apps/window during development cycle.
Platform-Specific Cleanup Handling
-
For Android & iOS: Uses AppLifecycleState.paused via WidgetsBindingObserver to trigger autoClearHistory() when the app goes to the background.
-
For Windows, macOS, Linux:Uses window_manager to detect app minimize events and trigger cleanup accordingly.
-
Ensures proper handling since AppLifecycleState does not work on desktops.
Batch Deletion Strategy
-
Deleting 50 records at a time minimizes performance issues.
-
Ensures smooth UX by avoiding excessive database transactions.
-
Users can continue adding new requests seamlessly without experiencing lag.
cc: @ashitaprasad
To be reviewed by @DenserMeerkat
Platforms tested
- Windows
- Android
Observation
The auto-clearing works in the platforms tested.
But the history providers are not updated after clearing files hence the deleted history cards are still shown in the UI.
Other Comments
The app.dart now has 2 ConsumerStatefulWidget with WindowListener mixins which feels redundant and can be tidied up
Uh oh!
There was an error while loading. Please reload this page.
Foss Hack 2025 - Auto Clear History via WidgetBindingObserver & State Mgmt for Dynamic Clean Up
Team Dart Knight
Vishwa Karthikvishwa.prarthana@gmail.comRelevant PR for Clearing API History
Debug Considerations
Checklist
mainbranch before making this PRflutter upgradeand verify)flutter test) and all tests are passingAdded/updated tests?
We encourage you to add relevant test cases.
OS on which you have developed and tested the feature?
cc: @ashitaprasad