Compare commits

...

4 commits

Author SHA1 Message Date
Yohan Boniface
97c9f9ed88
Merge e666f02b88 into fb6df6f955 2025-02-12 10:11:16 +01:00
Yohan Boniface
fb6df6f955
feat: make the tooltip sticky in hover mode for paths (#2507)
Some checks failed
Test & Docs / tests (postgresql, 3.10) (push) Has been cancelled
Test & Docs / tests (postgresql, 3.12) (push) Has been cancelled
Test & Docs / lint (push) Has been cancelled
Until now, it was displayed on the path (line or polygon) "center". So
when zoomed in, if the center is not on the screen, the tooltip will not
be visible.
2025-02-11 18:01:01 +01:00
Yohan Boniface
04966cc068 feat: make the tooltip sticky in hover mode for paths
Until now, it was displayed on the path (line or polygon)
"center". So when zoomed in, if the center is not on the
screen, the tooltip will not be visible.
2025-02-11 15:51:43 +01:00
Yohan Boniface
e666f02b88 feat(sync): display an alert when disconnected
fix #2500
cf #2235
2025-02-11 12:26:29 +01:00
2 changed files with 18 additions and 5 deletions

View file

@ -293,6 +293,11 @@ const PathMixin = {
this.on('popupclose', this._redraw) this.on('popupclose', this._redraw)
}, },
bindTooltip: function (content, options) {
options.sticky = !options.permanent
this.parentClass.prototype.bindTooltip.call(this, content, options)
},
highlightPath: function () { highlightPath: function () {
this.parentClass.prototype.setStyle.call(this, { this.parentClass.prototype.setStyle.call(this, {
fillOpacity: Math.sqrt(this.feature.getDynamicOption('fillOpacity', 1.0)), fillOpacity: Math.sqrt(this.feature.getDynamicOption('fillOpacity', 1.0)),

View file

@ -1,3 +1,6 @@
import { uMapAlert as Alert } from '../../components/alerts/alert.js'
import { translate } from '../i18n.js'
const PONG_TIMEOUT = 5000 const PONG_TIMEOUT = 5000
const PING_INTERVAL = 30000 const PING_INTERVAL = 30000
const FIRST_CONNECTION_TIMEOUT = 2000 const FIRST_CONNECTION_TIMEOUT = 2000
@ -14,15 +17,20 @@ export class WebSocketTransport {
} }
this.websocket.addEventListener('message', this.onMessage.bind(this)) this.websocket.addEventListener('message', this.onMessage.bind(this))
this.websocket.onclose = () => { this.websocket.onclose = () => {
console.log('websocket closed') console.debug('websocket closed')
if (!this.receiver.closeRequested) { if (!this.receiver.closeRequested) {
console.log('Not requested, reconnecting...') Alert.info(
translate(
'This map has enabled real-time synchronization with other users, but you are currently disconnected. We will try to reconnect in the background and reconcile with other users, but this feature is still experimental, and you might lose data. Have fun!'
)
)
console.debug('Not requested, reconnecting...')
this.receiver.reconnect() this.receiver.reconnect()
} }
} }
this.websocket.onerror = (error) => { this.websocket.onerror = (error) => {
console.log('WS ERROR', error) console.debug('WS ERROR', error)
} }
this.ensureOpen = setInterval(() => { this.ensureOpen = setInterval(() => {
@ -38,7 +46,7 @@ export class WebSocketTransport {
// See https://making.close.com/posts/reliable-websockets/ for more details. // See https://making.close.com/posts/reliable-websockets/ for more details.
this.pingInterval = setInterval(() => { this.pingInterval = setInterval(() => {
if (this.websocket.readyState === WebSocket.OPEN) { if (this.websocket.readyState === WebSocket.OPEN) {
console.log('sending ping') console.debug('sending ping')
this.websocket.send('ping') this.websocket.send('ping')
this.pongReceived = false this.pongReceived = false
setTimeout(() => { setTimeout(() => {
@ -68,7 +76,7 @@ export class WebSocketTransport {
} }
close() { close() {
console.log('Closing') console.debug('Closing')
this.receiver.closeRequested = true this.receiver.closeRequested = true
this.websocket.close() this.websocket.close()
} }