fix show/hide of timelines

This commit is contained in:
Nolan Lawson 2018-02-11 16:10:39 -08:00
parent c3a82a15bf
commit 650071568d
4 changed files with 20 additions and 8 deletions

View file

@ -6,7 +6,7 @@ import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
async function removeDuplicates (instanceName, timelineName, updates) { async function removeDuplicates (instanceName, timelineName, updates) {
// remove duplicates, including duplicates due to reblogs // remove duplicates, including duplicates due to reblogs
let timelineItemIds = store.getForTimeline(instanceName, timelineName, 'timelineItemIds') let timelineItemIds = store.getForTimeline(instanceName, timelineName, 'timelineItemIds') || []
let reblogIds = (await Promise.all(timelineItemIds.map(async timelineItemId => { let reblogIds = (await Promise.all(timelineItemIds.map(async timelineItemId => {
let status = await database.getStatus(instanceName, timelineItemId) let status = await database.getStatus(instanceName, timelineItemId)
return status.reblog && status.reblog.id return status.reblog && status.reblog.id
@ -30,11 +30,13 @@ async function handleFreshChanges (instanceName, timelineName) {
await database.insertTimelineItems(instanceName, timelineName, updates) await database.insertTimelineItems(instanceName, timelineName, updates)
let itemIdsToAdd = store.getForTimeline(instanceName, timelineName, 'itemIdsToAdd') || [] let itemIdsToAdd = store.getForTimeline(instanceName, timelineName, 'itemIdsToAdd')
if (itemIdsToAdd && itemIdsToAdd.length) {
itemIdsToAdd = itemIdsToAdd.concat(updates.map(_ => _.id)) itemIdsToAdd = itemIdsToAdd.concat(updates.map(_ => _.id))
store.setForTimeline(instanceName, timelineName, {itemIdsToAdd: itemIdsToAdd}) store.setForTimeline(instanceName, timelineName, {itemIdsToAdd: itemIdsToAdd})
} }
} }
}
function handleStreamMessage (instanceName, timelineName, message) { function handleStreamMessage (instanceName, timelineName, message) {
console.log('handleStreamMessage') console.log('handleStreamMessage')

View file

@ -59,6 +59,7 @@ export function initializeTimeline () {
let timeline = store.get('currentTimeline') let timeline = store.get('currentTimeline')
requestAnimationFrame(() => { requestAnimationFrame(() => {
requestAnimationFrame(() => { requestAnimationFrame(() => {
console.log('initialized')
store.setForTimeline(instanceName, timeline, {initialized: true}) store.setForTimeline(instanceName, timeline, {initialized: true})
}) })
}) })

View file

@ -1,4 +1,4 @@
<div class="loading-page"> <div class="loading-page {{shown ? '' : 'hidden'}}">
<LoadingSpinner /> <LoadingSpinner />
</div> </div>
<style> <style>
@ -12,11 +12,17 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 50; z-index: 50;
transition: opacity 0.25s linear;
} }
</style> </style>
<script> <script>
import LoadingSpinner from './LoadingSpinner.html' import LoadingSpinner from './LoadingSpinner.html'
export default { export default {
oncreate() {
setTimeout(() => {
this.set({shown: true})
}, 200)
},
components: { components: {
LoadingSpinner LoadingSpinner
} }

View file

@ -75,8 +75,10 @@
let timelineName = this.get('timeline') let timelineName = this.get('timeline')
this.observe('itemIdsToAdd', itemIdsToAdd => { this.observe('itemIdsToAdd', itemIdsToAdd => {
console.log('itemIdsToAdd', itemIdsToAdd) console.log('itemIdsToAdd', itemIdsToAdd)
if (itemIdsToAdd && itemIdsToAdd.length) {
addTimelineItemIds(instanceName, timelineName, itemIdsToAdd) addTimelineItemIds(instanceName, timelineName, itemIdsToAdd)
this.store.setForTimeline(instanceName, timelineName, {itemIdsToAdd: []}) this.store.setForTimeline(instanceName, timelineName, {itemIdsToAdd: []})
}
}) })
}, },
ondestroy() { ondestroy() {
@ -151,9 +153,10 @@
}, },
methods: { methods: {
initialize() { initialize() {
if (this.store.get('initialized') || !this.store.get('timelineItemIds')) { if (this.get('initializeStarted')) {
return return
} }
this.set({initializeStarted: true})
console.log('timeline initialize()') console.log('timeline initialize()')
initializeTimeline() initializeTimeline()
}, },