Show toast when offline

This commit is contained in:
Jon Staab 2024-06-11 14:11:18 -07:00
parent 62e51f2157
commit 7710058e98
2 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,9 @@
# Changelog
# 0.4.7
- [x] Show toast when offline
# 0.4.6
- [x] Improve search results loading indicator

View File

@ -21,6 +21,16 @@
export const showWarning = (message, opts = {}) => showToast({message, theme: "warning", ...opts})
export const showPublishInfo = (pub, opts = {}) => showToast({pub, type: "publish", ...opts})
window.addEventListener('online', () => {
if (toast.get()?.id === 'offline') {
toast.set(null)
}
})
window.addEventListener('offline', () => {
showInfo("You are currently offline.", {id: 'offline', timeout: null})
})
</script>
<script lang="ts">