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