Fix chat new messages fixed button
This commit is contained in:
parent
eeeb3c96d2
commit
e8ed9cd379
3 changed files with 21 additions and 12 deletions
|
|
@ -45,13 +45,9 @@ export const syncChecked = () => {
|
||||||
.map((_, i, segments) => segments.slice(0, i + 1).join("/"))
|
.map((_, i, segments) => segments.slice(0, i + 1).join("/"))
|
||||||
.slice(1)
|
.slice(1)
|
||||||
|
|
||||||
// Set checked when we enter and when we leave a given page
|
|
||||||
return page.subscribe($page => {
|
return page.subscribe($page => {
|
||||||
|
// Set checked when we leave a given page
|
||||||
checked.update($checked => {
|
checked.update($checked => {
|
||||||
for (const path of getPaths($page.url.pathname)) {
|
|
||||||
$checked[path] = now()
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const path of getPaths(prev)) {
|
for (const path of getPaths(prev)) {
|
||||||
$checked[path] = now()
|
$checked[path] = now()
|
||||||
}
|
}
|
||||||
|
|
@ -59,6 +55,17 @@ export const syncChecked = () => {
|
||||||
return $checked
|
return $checked
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Set checked when we visit a given page - but delay it a tad
|
||||||
|
setTimeout(() => {
|
||||||
|
checked.update($checked => {
|
||||||
|
for (const path of getPaths($page.url.pathname)) {
|
||||||
|
$checked[path] = now()
|
||||||
|
}
|
||||||
|
|
||||||
|
return $checked
|
||||||
|
})
|
||||||
|
}, 300)
|
||||||
|
|
||||||
prev = $page.url.pathname
|
prev = $page.url.pathname
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +74,7 @@ export const syncChecked = () => {
|
||||||
|
|
||||||
export const allNotifications = derived(
|
export const allNotifications = derived(
|
||||||
throttled(
|
throttled(
|
||||||
2000,
|
1000,
|
||||||
derived(
|
derived(
|
||||||
[
|
[
|
||||||
pubkey,
|
pubkey,
|
||||||
|
|
|
||||||
|
|
@ -176,13 +176,14 @@
|
||||||
|
|
||||||
const newMessages = document.getElementById("new-messages")
|
const newMessages = document.getElementById("new-messages")
|
||||||
|
|
||||||
if (!newMessages || newMessagesSeen) {
|
if (newMessagesSeen) {
|
||||||
showFixedNewMessages = false
|
showFixedNewMessages = false
|
||||||
} else {
|
} else if (newMessages) {
|
||||||
const {y} = newMessages.getBoundingClientRect()
|
const {y} = newMessages.getBoundingClientRect()
|
||||||
|
|
||||||
if (y > 300) {
|
if (y > 0 && y < 300) {
|
||||||
newMessagesSeen = true
|
newMessagesSeen = true
|
||||||
|
showFixedNewMessages = false
|
||||||
} else {
|
} else {
|
||||||
showFixedNewMessages = y < 0
|
showFixedNewMessages = y < 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,13 +109,14 @@
|
||||||
|
|
||||||
const newMessages = document.getElementById("new-messages")
|
const newMessages = document.getElementById("new-messages")
|
||||||
|
|
||||||
if (!newMessages || newMessagesSeen) {
|
if (newMessagesSeen) {
|
||||||
showFixedNewMessages = false
|
showFixedNewMessages = false
|
||||||
} else {
|
} else if (newMessages) {
|
||||||
const {y} = newMessages.getBoundingClientRect()
|
const {y} = newMessages.getBoundingClientRect()
|
||||||
|
|
||||||
if (y > 300) {
|
if (y > 0 && y < 300) {
|
||||||
newMessagesSeen = true
|
newMessagesSeen = true
|
||||||
|
showFixedNewMessages = false
|
||||||
} else {
|
} else {
|
||||||
showFixedNewMessages = y < 0
|
showFixedNewMessages = y < 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue