mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
commit
131e0eb345
4 changed files with 51 additions and 12 deletions
|
|
@ -1 +1 @@
|
||||||
0.28.0
|
0.28.1
|
||||||
|
|
|
||||||
10
CHANGELOG.md
10
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/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
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
|
# 0.28.0 - 2025-06-09
|
||||||
|
|
||||||
⚠️ This release includes a breaking change. ⚠️
|
⚠️ This release includes a breaking change. ⚠️
|
||||||
|
|
|
||||||
|
|
@ -48,17 +48,53 @@ export default class extends BaseController {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create divider and notification item to match server-side structure
|
||||||
|
const divider = this.createDivider()
|
||||||
const li = this.createNotificationListItem(notification)
|
const li = this.createNotificationListItem(notification)
|
||||||
const divider = this.listTarget.querySelector(".divider")
|
|
||||||
if (divider) {
|
// Find the "See all" link to determine where to insert
|
||||||
divider.parentNode.insertBefore(li, divider.nextSibling)
|
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 {
|
} else {
|
||||||
|
// Fallback: prepend to list
|
||||||
|
this.listTarget.prepend(divider)
|
||||||
this.listTarget.prepend(li)
|
this.listTarget.prepend(li)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enforce limit of 10 notification items (excluding the "See all" link)
|
||||||
|
this.enforceNotificationLimit()
|
||||||
|
|
||||||
this.updateBadge()
|
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) {
|
createNotificationListItem(notification) {
|
||||||
const li = document.createElement("li")
|
const li = document.createElement("li")
|
||||||
li.className = "notification-item"
|
li.className = "notification-item"
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@
|
||||||
class ReverseGeocoding::Places::FetchData
|
class ReverseGeocoding::Places::FetchData
|
||||||
attr_reader :place
|
attr_reader :place
|
||||||
|
|
||||||
IGNORED_OSM_VALUES = %w[house residential yes detached].freeze
|
|
||||||
IGNORED_OSM_KEYS = %w[highway railway].freeze
|
|
||||||
|
|
||||||
def initialize(place_id)
|
def initialize(place_id)
|
||||||
@place = Place.find(place_id)
|
@place = Place.find(place_id)
|
||||||
end
|
end
|
||||||
|
|
@ -14,6 +11,7 @@ class ReverseGeocoding::Places::FetchData
|
||||||
def call
|
def call
|
||||||
unless DawarichSettings.reverse_geocoding_enabled?
|
unless DawarichSettings.reverse_geocoding_enabled?
|
||||||
Rails.logger.warn('Reverse geocoding is not enabled')
|
Rails.logger.warn('Reverse geocoding is not enabled')
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -102,10 +100,5 @@ class ReverseGeocoding::Places::FetchData
|
||||||
radius: 1,
|
radius: 1,
|
||||||
units: :km
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue