Fix chat new messages fixed button

This commit is contained in:
Jon Staab
2026-03-30 13:22:22 -07:00
parent eeeb3c96d2
commit e8ed9cd379
3 changed files with 21 additions and 12 deletions
+13 -6
View File
@@ -45,13 +45,9 @@ export const syncChecked = () => {
.map((_, i, segments) => segments.slice(0, i + 1).join("/"))
.slice(1)
// Set checked when we enter and when we leave a given page
return page.subscribe($page => {
// Set checked when we leave a given page
checked.update($checked => {
for (const path of getPaths($page.url.pathname)) {
$checked[path] = now()
}
for (const path of getPaths(prev)) {
$checked[path] = now()
}
@@ -59,6 +55,17 @@ export const syncChecked = () => {
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
})
}
@@ -67,7 +74,7 @@ export const syncChecked = () => {
export const allNotifications = derived(
throttled(
2000,
1000,
derived(
[
pubkey,
+4 -3
View File
@@ -176,13 +176,14 @@
const newMessages = document.getElementById("new-messages")
if (!newMessages || newMessagesSeen) {
if (newMessagesSeen) {
showFixedNewMessages = false
} else {
} else if (newMessages) {
const {y} = newMessages.getBoundingClientRect()
if (y > 300) {
if (y > 0 && y < 300) {
newMessagesSeen = true
showFixedNewMessages = false
} else {
showFixedNewMessages = y < 0
}
+4 -3
View File
@@ -109,13 +109,14 @@
const newMessages = document.getElementById("new-messages")
if (!newMessages || newMessagesSeen) {
if (newMessagesSeen) {
showFixedNewMessages = false
} else {
} else if (newMessages) {
const {y} = newMessages.getBoundingClientRect()
if (y > 300) {
if (y > 0 && y < 300) {
newMessagesSeen = true
showFixedNewMessages = false
} else {
showFixedNewMessages = y < 0
}