Add History Filter Feature (Fixes Issue #511) #513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds a filtering system to the account history view, allowing users to filter transaction events by event type. The implementation includes a new
HistoryFiltercomponent and auseHistoryFilterhook that manages filter state and behavior.Fixes Issue #511
What Was Added
New Files
hooks/filter/useHistoryFilter.ts- Custom hook for managing filter state and logiccomponents/HistoryView/HistoryFilter.tsx- Filter popover componentModified Files
components/HistoryView/index.tsx- Integrated the filter component into the history viewComponent Walkthrough
HistoryFilterComponentThe
HistoryFiltercomponent renders a filter button and popover interface:Filter Button (
PopoverTrigger)Popover Content
Clear- Removes all selected filtersFilters- Title textDone- Closes the popoverposition: stickyto remain visible while scrolling through filter optionsScrollable Filter List
Styling Details
marginRight: "$3") on all screen sizes to prevent edge touchingHook Walkthrough
useHistoryFilterHookThe hook manages all filter-related state and logic:
State Management
selectedEventTypes- Array of currently selected event type stringsisFilterOpen- Boolean controlling popover visibilityEvent Type Configuration
EVENT_TYPE_LABELS- Maps GraphQL event type names to human-readable labels:BondEvent→ "Bonded"DepositFundedEvent→ "Deposit Funded"NewRoundEvent→ "Initialize Round"RebondEvent→ "Rebond"UnbondEvent→ "Unbond"RewardEvent→ "Reward"TranscoderUpdateEvent→ "Transcoder Update"WithdrawStakeEvent→ "Withdraw Stake"WithdrawFeesEvent→ "Withdraw Fees"WinningTicketRedeemedEvent→ "Winning Ticket Redeemed"ReserveFundedEvent→ "Reserve Funded"ALL_EVENT_TYPES- Array of all available event typesFiltering Logic
filteredEvents- Memoized filtered array of events__typenamewhen filters are activetoggleEventType- Adds/removes event types from selectionclearFilters- Resets all selected filtersUX Behavior
composedPath()to detect if scroll originated from within the popoverFeatures
✅ Filter events by event type
✅ Visual indicator (badge) showing number of active filters
✅ Clear all filters button
✅ Sticky header that remains visible while scrolling filter options
✅ Auto-close popover when scrolling the main page
✅ Responsive design with proper spacing on all screen sizes
Integration
The filter is integrated into the
HistoryViewcomponent:Note: First Pass Implementation
This is the first pass of the history filter feature, implemented to gather feedback on:
Additional Features Needed:
Filter Button Location:
Let me know and I can add the changes.