feat: add listener for share actions#24
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (7)
WalkthroughAdds a share-listener callback feature: frontend dispatches named "driver-clicked" events; Java API accepts a ShareEasyClickListener via withShareListener(...); new event and listener types, Driver.fromName lookup, demo and UI test, README docs, and version/dependency bump. ChangesShare Listener Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/com/flowingcode/vaadin/addons/shareeasy/BaseShareEasy.java (1)
180-190: 💤 Low valueConsider validating driverName before dispatching the event.
The frontend should always provide a driver name, but if the event payload is malformed or a future change breaks this contract,
driverNamecould be null. Consider adding a guard to skip calling the listener or log a warning when critical event data is missing.🛡️ Optional defensive check
private void registerShareListener() { if (shareListener == null) { return; } component.getElement().addEventListener("driver-clicked", event -> { JsonObject detail = event.getEventData(); String driverName = getStringOrNull(detail, "event.detail.name"); String link = getStringOrNull(detail, "event.detail.link"); + if (driverName == null) { + // Log warning or skip event if critical data is missing + return; + } shareListener.onShare(new ShareEasyClickEvent(component, driverName, link)); }).addEventData("event.detail.name").addEventData("event.detail.link"); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/flowingcode/vaadin/addons/shareeasy/BaseShareEasy.java` around lines 180 - 190, The registerShareListener method currently dispatches a ShareEasyClickEvent without checking that driverName is present; update registerShareListener to validate driverName (using getStringOrNull result) before calling shareListener.onShare — if driverName is null or empty, skip calling shareListener (and optionally log a warning via a Logger) so malformed events are ignored; keep the rest of the logic (link handling and adding event data) unchanged and reference registerShareListener, shareListener, getStringOrNull, driverName, and ShareEasyClickEvent when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/main/java/com/flowingcode/vaadin/addons/shareeasy/BaseShareEasy.java`:
- Around line 180-190: The registerShareListener method currently dispatches a
ShareEasyClickEvent without checking that driverName is present; update
registerShareListener to validate driverName (using getStringOrNull result)
before calling shareListener.onShare — if driverName is null or empty, skip
calling shareListener (and optionally log a warning via a Logger) so malformed
events are ignored; keep the rest of the logic (link handling and adding event
data) unchanged and reference registerShareListener, shareListener,
getStringOrNull, driverName, and ShareEasyClickEvent when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dce88ace-9ad6-4728-9cd7-bbfd2987df39
📒 Files selected for processing (10)
README.mdpom.xmlsrc/main/java/com/flowingcode/vaadin/addons/shareeasy/BaseShareEasy.javasrc/main/java/com/flowingcode/vaadin/addons/shareeasy/ShareEasyClickEvent.javasrc/main/java/com/flowingcode/vaadin/addons/shareeasy/ShareEasyClickListener.javasrc/main/java/com/flowingcode/vaadin/addons/shareeasy/enums/Driver.javasrc/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.jssrc/test/java/com/flowingcode/vaadin/addons/shareeasy/NormalModeDemo.javasrc/test/java/com/flowingcode/vaadin/addons/shareeasy/it/ShareEasyElement.javasrc/test/java/com/flowingcode/vaadin/addons/shareeasy/it/ShareEasyNormalModeIT.java
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/flowingcode/vaadin/addons/shareeasy/ShareEasyClickEvent.java`:
- Around line 49-53: The ShareEasyClickEvent constructor should validate
required params: in ShareEasyClickEvent(Component source, String driverName,
String link) add null checks (e.g., Objects.requireNonNull or explicit checks)
for driverName (and optionally source) and throw an IllegalArgumentException
with a clear message if missing so the event cannot be created with a null
driverName; update the constructor to perform these checks before assigning
fields so getDriverName() never returns null.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7cc97a56-f4fc-483c-bba8-46ea9c196c9e
📒 Files selected for processing (10)
README.mdpom.xmlsrc/main/java/com/flowingcode/vaadin/addons/shareeasy/BaseShareEasy.javasrc/main/java/com/flowingcode/vaadin/addons/shareeasy/ShareEasyClickEvent.javasrc/main/java/com/flowingcode/vaadin/addons/shareeasy/ShareEasyClickListener.javasrc/main/java/com/flowingcode/vaadin/addons/shareeasy/enums/Driver.javasrc/main/resources/META-INF/resources/frontend/src/fc-sharee-connector.jssrc/test/java/com/flowingcode/vaadin/addons/shareeasy/NormalModeDemo.javasrc/test/java/com/flowingcode/vaadin/addons/shareeasy/it/ShareEasyElement.javasrc/test/java/com/flowingcode/vaadin/addons/shareeasy/it/ShareEasyNormalModeIT.java
930d89a to
278285f
Compare
|



Description
Adds the ability to listen for share actions, as requested in #12.
A new
withShareListener(ShareEasyClickListener)builder method registers alistener that is notified whenever a share driver is clicked. The
ShareEasyClickEventexposes:getDriverName()- the clicked driver's name (e.g."telegram")getDriver()- the resolvedDriverfor default drivers (Optional)getLink()- the share link (the copied URL for the copy driver)getSource()- the component the Share Easy instance is attached toHow it works
This builds on the upstream
driver-clickedevent added in sharee 1.1.24(parsagholipour/sharee#6). The connector:
getNameso the event carries a stabledriver key instead of the bundled (build-dependent) class name;
onClickis fullyoverridden by the add-on - carrying the actual copied URL.
Additional changes
build: bumpwebdrivermanagerto 5.9.2 so the integration tests canresolve a driver for current Chrome versions.
build: set version to 2.2.0-SNAPSHOT.Testing
ShareEasyNormalModeIT.withShareListener_clickDriver_firesEvent.Close #12
Summary by CodeRabbit
New Features
Behavior
Documentation
Tests / Demos