-
Notifications
You must be signed in to change notification settings - Fork 64
Feature: Add recent filters drop-down to the message browser #279
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
Merged
mgaffigan
merged 5 commits into
OpenIntegrationEngine:main
from
mgaffigan:feature/mru-filters
Jul 2, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ace49c6
Move toString to MessageFilter/out of MessageBrowser, add tests
mgaffigan 1f656fe
Add MessageFilter.equals(MessageFilter) and tests
mgaffigan e496d45
Add recent filters list to message browser
mgaffigan 74c2772
Avoid storing PHI to preferences
mgaffigan 2a5b15c
Clean up some pre-Java 17 smell
mgaffigan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
272 changes: 91 additions & 181 deletions
272
client/src/com/mirth/connect/client/ui/browsers/message/MessageBrowser.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
client/src/com/mirth/connect/client/ui/browsers/message/MessageBrowserRecentFilterStore.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
| // SPDX-FileCopyrightText: 2025 Mitch Gaffigan | ||
|
|
||
| package com.mirth.connect.client.ui.browsers.message; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| import com.mirth.connect.model.converters.ObjectXMLSerializer; | ||
| import com.mirth.connect.model.filters.MessageFilter; | ||
|
|
||
| class MessageBrowserRecentFilterStore { | ||
| private static final int MAX_RECENT_FILTERS = 10; | ||
|
jonbartels marked this conversation as resolved.
|
||
| private static final String RECENT_FILTERS_PREFERENCE_PREFIX = "messageBrowserRecentFilters."; | ||
| // TODO: Replace with a cross-session time-limited encrypted store | ||
| // (In-memory assuming text searches represent PHI) | ||
| private static final Map<String, String> RECENT_FILTERS_BY_CHANNEL = new ConcurrentHashMap<>(); | ||
| private Logger logger = LogManager.getLogger(this.getClass()); | ||
|
|
||
| private final String prefKey; | ||
|
|
||
| public MessageBrowserRecentFilterStore(String channelId) { | ||
| this.prefKey = RECENT_FILTERS_PREFERENCE_PREFIX + channelId; | ||
| } | ||
|
|
||
| public List<MessageFilter> getRecentFilters() { | ||
| try { | ||
| String serialized = RECENT_FILTERS_BY_CHANNEL.getOrDefault(prefKey, ""); | ||
| if (serialized.isBlank()) return List.of(); | ||
|
|
||
| var result = ObjectXMLSerializer.getInstance().deserializeList(serialized, MessageFilter.class); | ||
| if (result == null) return List.of(); | ||
|
|
||
| return result; | ||
| } catch (Exception e) { | ||
| // Fail quietly if the stored filters cannot be deserialized for any reason. | ||
| logger.warn("Failed to deserialize recent message filters for key {}.", prefKey, e); | ||
| return List.of(); | ||
|
mgaffigan marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
| public void addRecentFilter(MessageFilter filter) { | ||
| if (filter == null) { | ||
| throw new IllegalArgumentException("Filter cannot be null"); | ||
| } | ||
|
|
||
| var filters = new ArrayList<>(getRecentFilters()); | ||
|
|
||
| // Remove then re-add to avoid duplicates | ||
| filters.remove(filter); | ||
| filters.add(0, filter); | ||
|
|
||
| // Trim to the maximum number of recent filters | ||
| if (filters.size() > MAX_RECENT_FILTERS) { | ||
| filters.subList(MAX_RECENT_FILTERS, filters.size()).clear(); | ||
| } | ||
|
jonbartels marked this conversation as resolved.
|
||
|
|
||
| try { | ||
| RECENT_FILTERS_BY_CHANNEL.put(prefKey, ObjectXMLSerializer.getInstance().serialize(filters)); | ||
| } catch (Exception e) { | ||
| logger.warn("Failed to serialize recent message filters for key {}.", prefKey, e); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.