Nice website for doing the diff:
class PostsController < ApplicationController
...
def index
respond_to do |format|
format.html
format.turbo_stream { @pagy, @posts = pagy_countless(Post.all) }
end
end
...Notification prompting can only be done from a user gesture.
async function startServiceWorker() {
const vapidPublicKey = document.head
.querySelector('meta[name="vapid_public_key"]')
.getAttribute('content');
await registerServiceWorker();
const subscription = await getPushSubscription(vapidPublicKey);
if (!subscription) return;
await sendSubscriptionToServer(subscription);
}