diff --git a/.app_version b/.app_version index 697f087f..48f7a71d 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.28.0 +0.28.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5baa275b..76608f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +# 0.28.1 - 2025-06-11 + +## Fixed + +- Limit notifications in navbar to 10. Fresh one will replace the oldest one. #1184 + +## Changed + +- No osm point types are being ignored anymore. + # 0.28.0 - 2025-06-09 ⚠️ This release includes a breaking change. ⚠️ diff --git a/app/javascript/controllers/notifications_controller.js b/app/javascript/controllers/notifications_controller.js index c40a4db5..7af20b52 100644 --- a/app/javascript/controllers/notifications_controller.js +++ b/app/javascript/controllers/notifications_controller.js @@ -48,17 +48,53 @@ export default class extends BaseController { return } + // Create divider and notification item to match server-side structure + const divider = this.createDivider() const li = this.createNotificationListItem(notification) - const divider = this.listTarget.querySelector(".divider") - if (divider) { - divider.parentNode.insertBefore(li, divider.nextSibling) + + // Find the "See all" link to determine where to insert + const seeAllLink = this.listTarget.querySelector('li:first-child') + if (seeAllLink) { + // Insert after the "See all" link + seeAllLink.insertAdjacentElement('afterend', divider) + divider.insertAdjacentElement('afterend', li) } else { + // Fallback: prepend to list + this.listTarget.prepend(divider) this.listTarget.prepend(li) } + // Enforce limit of 10 notification items (excluding the "See all" link) + this.enforceNotificationLimit() + this.updateBadge() } + createDivider() { + const divider = document.createElement("div") + divider.className = "divider p-0 m-0" + return divider + } + + enforceNotificationLimit() { + const limit = 10 + const notificationItems = this.listTarget.querySelectorAll('.notification-item') + + // Remove excess notifications if we exceed the limit + if (notificationItems.length > limit) { + // Remove the oldest notifications (from the end of the list) + for (let i = limit; i < notificationItems.length; i++) { + const itemToRemove = notificationItems[i] + // Also remove the divider that comes before it + const previousSibling = itemToRemove.previousElementSibling + if (previousSibling && previousSibling.classList.contains('divider')) { + previousSibling.remove() + } + itemToRemove.remove() + } + } + } + createNotificationListItem(notification) { const li = document.createElement("li") li.className = "notification-item" diff --git a/app/services/reverse_geocoding/places/fetch_data.rb b/app/services/reverse_geocoding/places/fetch_data.rb index 8dc40df0..458bd5b9 100644 --- a/app/services/reverse_geocoding/places/fetch_data.rb +++ b/app/services/reverse_geocoding/places/fetch_data.rb @@ -4,9 +4,6 @@ class ReverseGeocoding::Places::FetchData attr_reader :place - IGNORED_OSM_VALUES = %w[house residential yes detached].freeze - IGNORED_OSM_KEYS = %w[highway railway].freeze - def initialize(place_id) @place = Place.find(place_id) end @@ -14,6 +11,7 @@ class ReverseGeocoding::Places::FetchData def call unless DawarichSettings.reverse_geocoding_enabled? Rails.logger.warn('Reverse geocoding is not enabled') + return end @@ -102,10 +100,5 @@ class ReverseGeocoding::Places::FetchData radius: 1, units: :km ) - - data.reject do |place| - place.data['properties']['osm_value'].in?(IGNORED_OSM_VALUES) || - place.data['properties']['osm_key'].in?(IGNORED_OSM_KEYS) - end end end