fix: update star icon on star/unstar

This commit is contained in:
Yohan Boniface 2024-12-19 10:44:32 +01:00
parent 24511d796d
commit f93d0b5ca7
2 changed files with 7 additions and 6 deletions

View file

@ -1346,6 +1346,11 @@ export default class Umap extends ServerStored {
el.textContent = this.sync.getNumberOfConnectedPeers() el.textContent = this.sync.getNumberOfConnectedPeers()
}) })
}, },
'properties.starred': () => {
Utils.eachElement('.map-star', (el) => {
el.classList.toggle('starred', this.properties.starred)
})
},
} }
for (const [field, impact] of Object.entries(impacts)) { for (const [field, impact] of Object.entries(impacts)) {
if (!fields.length || fields.includes(field)) { if (!fields.length || fields.includes(field)) {
@ -1531,7 +1536,7 @@ export default class Umap extends ServerStored {
? translate('Map has been starred') ? translate('Map has been starred')
: translate('Map has been unstarred') : translate('Map has been unstarred')
) )
this.render(['starred']) this.render(['properties.starred'])
} }
processFileToImport(file, layer, type) { processFileToImport(file, layer, type) {

View file

@ -541,11 +541,7 @@ U.StarControl = L.Control.Button.extend({
options: { options: {
position: 'topleft', position: 'topleft',
title: L._('Star this map'), title: L._('Star this map'),
}, className: 'leaflet-control-star map-star umap-control',
getClassName: function () {
const status = this._umap.properties.starred ? ' starred' : ''
return `leaflet-control-star umap-control${status}`
}, },
onClick: function () { onClick: function () {