forked from coracle/flotilla
Fix chat new messages fixed button
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user