Paginate the read notifications

This commit is contained in:
Kevin McConnell
2025-01-24 17:42:36 +00:00
parent 42fa37d347
commit 1f3bc1134f
7 changed files with 53 additions and 5 deletions
@@ -0,0 +1,25 @@
import { Controller } from "@hotwired/stimulus"
import { get } from "@rails/request.js"
export default class extends Controller {
static values = { url: String }
connect() {
this.#observe()
}
#observe() {
const observer = new IntersectionObserver((entries) => {
const visible = !!entries.find(entry => entry.isIntersecting)
if (visible) {
this.#fetch()
}
})
observer.observe(this.element)
}
#fetch() {
get(this.urlValue, { responseKind: "turbo-stream" })
}
}