forked from cybrespace/pinafore
tweak offline mode
This commit is contained in:
parent
6cf4a11283
commit
b8d7ae3d8b
|
@ -1,5 +1,5 @@
|
|||
<:Window bind:online />
|
||||
<div class="timeline" role="feed" aria-label="{{label}}">
|
||||
<div class="timeline" role="feed" aria-label="{{label}}" >
|
||||
<VirtualList component="{{StatusListItem}}"
|
||||
items="{{keyedStatuses}}"
|
||||
on:scrollToBottom="onScrollToBottom()" />
|
||||
|
@ -23,7 +23,6 @@
|
|||
import { mark, stop } from '../_utils/marks'
|
||||
import { timelines } from '../_static/timelines'
|
||||
|
||||
|
||||
const FETCH_LIMIT = 20
|
||||
|
||||
export default {
|
||||
|
@ -38,11 +37,13 @@
|
|||
insertStatusesIntoDatabase(instanceName, this.get('timeline'), statuses)
|
||||
}
|
||||
this.addStatuses(statuses)
|
||||
this.set({initialized: true})
|
||||
},
|
||||
data: () => ({
|
||||
StatusListItem: StatusListItem,
|
||||
statuses: [],
|
||||
runningUpdate: false
|
||||
runningUpdate: false,
|
||||
initialized: false
|
||||
}),
|
||||
computed: {
|
||||
keyedStatuses: (statuses) => statuses.map(status => ({
|
||||
|
@ -60,10 +61,13 @@
|
|||
splice: splice,
|
||||
push: push,
|
||||
async onScrollToBottom() {
|
||||
mark('onScrollToBottom')
|
||||
if (!this.get('initialized')) {
|
||||
return
|
||||
}
|
||||
if (this.get('runningUpdate')) {
|
||||
return
|
||||
}
|
||||
mark('onScrollToBottom')
|
||||
this.set({ runningUpdate: true })
|
||||
let lastStatusId = this.get('lastStatusId')
|
||||
let instanceName = this.store.get('currentInstance')
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
import { toast } from './toast'
|
||||
import { keyval } from './database/keyval'
|
||||
|
||||
function onUpdateFound(registration) {
|
||||
const newWorker = registration.installing
|
||||
|
||||
newWorker.addEventListener('statechange', async () => {
|
||||
if (!(await keyval.get('serviceworker_installed'))) {
|
||||
await keyval.set('serviceworker_installed', true)
|
||||
return
|
||||
}
|
||||
if (newWorker.state === 'activated' && navigator.serviceWorker.controller) {
|
||||
toast.say('App update available. Reload to update.')
|
||||
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
||||
toast.say('Update available. Refresh to update.')
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue