You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The version range string from the forum topic is used for compatibility checks. The topic is also used as the name of the add-on. When parsing the community marketplace entries, the range string is stripped from the topic string.
However, when an add-on is installed, the version range is not stripped. The "full topic" is stored in the JSONDB, and is later retrieved from there for already installed add-ons, leading to the version range being displayed in the UI whenever the add-on name is displayed.
Expected Behavior
Add-on names should be displayed without the version range also when installed locally.
Current Behavior
Add-on names include the version range string after they are installed.
Possible Solution
I managed to fix this with the following:
.../internal/community/CommunityMarketplaceAddonService.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java
index 3d791d447..ca62ac7cc 100644
--- a/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java+++ b/bundles/org.openhab.core.addon.marketplace/src/main/java/org/openhab/core/addon/marketplace/internal/community/CommunityMarketplaceAddonService.java@@ -437,8 +437,18 @@ public class CommunityMarketplaceAddonService extends AbstractRemoteAddonService
boolean installed = addonHandlers.stream()
.anyMatch(handler -> handler.supports(type, contentType) && handler.isInstalled(uid));
+ String title = topic.title;+ int compatibilityStart = topic.title.lastIndexOf("["); // version range always starts with [+ if (topic.title.lastIndexOf(" ") < compatibilityStart) { // check includes [ not present+ String potentialRange = topic.title.substring(compatibilityStart);+ Matcher matcher = BundleVersion.RANGE_PATTERN.matcher(potentialRange);+ if (matcher.matches()) {+ title = topic.title.substring(0, compatibilityStart).trim();+ }+ }+
Addon.Builder builder = Addon.create(uid).withType(type).withId(id).withContentType(contentType)
- .withLabel(topic.title).withImageLink(topic.imageUrl)+ .withLabel(title).withImageLink(topic.imageUrl)
.withLink(COMMUNITY_TOPIC_URL + topic.id.toString())
.withAuthor(topic.postStream.posts[0].displayUsername).withMaturity(maturity)
.withDetailedDescription(detailedDescription).withInstalled(installed).withProperties(properties);
This logic could be made more "elegant" and robust (like also working if there's no space between the name and the version range, not depending on the start bracket being [ etc.), but I just copied the existing logic to make sure they work exactly the same.
I'm sure some will say that this should have been a PR - but that's not an option because the CLA requires you to state your full name and e-mail in public. As such, there isn't any point in "making the logic more robust" either, since my code won't be used anyway. I'm merely posting it here as a "suggestion" of how this could be solved.
Steps to Reproduce (for Bugs)
Install an add-on that has a version range string (for example Mill LAN Binding) and refresh the marketplace page - or add a new Thing manually and watch the binding name in the "select binding" dialog.
The text was updated successfully, but these errors were encountered:
Nadahar
added
the
bug
An unexpected problem or unintended behavior of the Core
label
Dec 26, 2024
Nadahar
changed the title
Community Marketplace add-ons shows the version range from the topic after being installed
Community Marketplace add-ons show the version range from the topic after being installed
Dec 26, 2024
The version range string from the forum topic is used for compatibility checks. The topic is also used as the name of the add-on. When parsing the community marketplace entries, the range string is stripped from the topic string.
However, when an add-on is installed, the version range is not stripped. The "full topic" is stored in the JSONDB, and is later retrieved from there for already installed add-ons, leading to the version range being displayed in the UI whenever the add-on name is displayed.
Expected Behavior
Add-on names should be displayed without the version range also when installed locally.
Current Behavior
Add-on names include the version range string after they are installed.
Possible Solution
I managed to fix this with the following:
This logic could be made more "elegant" and robust (like also working if there's no space between the name and the version range, not depending on the start bracket being
[
etc.), but I just copied the existing logic to make sure they work exactly the same.I'm sure some will say that this should have been a PR - but that's not an option because the CLA requires you to state your full name and e-mail in public. As such, there isn't any point in "making the logic more robust" either, since my code won't be used anyway. I'm merely posting it here as a "suggestion" of how this could be solved.
Steps to Reproduce (for Bugs)
Install an add-on that has a version range string (for example
Mill LAN Binding
) and refresh the marketplace page - or add a new Thing manually and watch the binding name in the "select binding" dialog.The text was updated successfully, but these errors were encountered: