Commit 04dc782e authored by Evan You's avatar Evan You

tweaks

parent 9c56cde1
......@@ -30,9 +30,8 @@
export default {
name: 'news-item',
props: ['item'],
serverCacheKey: ({ item: { id, __lastUpdated } }) => {
console.log(__lastUpdated)
return `${id}::${__lastUpdated}`
serverCacheKey: props => {
return `${props.item.id}::${props.item.__lastUpdated}`
}
}
</script>
......
......@@ -50,6 +50,7 @@ function fetch (child) {
return new Promise((resolve, reject) => {
api.child(child).once('value', snapshot => {
const val = snapshot.val()
// mark the timestamp when this item is cached
val.__lastUpdated = Date.now()
cache && cache.set(child, val)
resolve(val)
......
......@@ -21,7 +21,7 @@ const store = new Vuex.Store({
actions: {
// ensure data for rendering given list type
FETCH_LIST_DATA: ({ commit, dispatch, state, getters }, { type }) => {
FETCH_LIST_DATA: ({ commit, dispatch, state }, { type }) => {
commit('SET_ACTIVE_TYPE', { type })
return fetchIdsByType(type)
.then(ids => commit('SET_LIST', { type, ids }))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment