11<template >
22 <div class =" work-view my-3 my-sm-3 mx-sm-auto rounded-3 mx-3 shadow position-relative" >
3- <router-link rel =" noreferrer noopener" target =' _blank' to =" /form" >
4- <button class =" btn text-white position-absolute new-work-btn shadow fw-bolder fs-6 mx-2 my-2" type =" button" >+
5- </button >
6- </router-link >
7- <h1 class =" py-3 py-sm-3 my-0" >
3+ <div class =" position-absolute new-work-btn-area" >
4+ <router-link rel =" noreferrer noopener" target =' _blank' to =" /form" >
5+ <button class =" btn text-white position-relative shadow fw-bolder fs-6 mx-2 my-2" type =" button" >+
6+ </button >
7+ </router-link >
8+ <p class =" user-select-none live" >
9+ <span class =" circle" />
10+ Live
11+ </p >
12+ </div >
13+ <h1 class =" py-4 py-sm-4 my-0" >
814 <svg class =" d-svg" viewBox =" 0 0 1 1" >
915 <use xlink:href =" #todo.svg" />
1016 </svg >
1420 <div class =" container py-3 px-3 mw-100" >
1521 <CircleProgress v-if =" processing " :msg =" progressMsg " />
1622 <div :class =" {'wall__show':processing}" class =" wall position-absolute" />
17- <div :class =" {'invisible':processing}" class =" row mw-100 position-relative mx-auto justify-content-center" >
23+ <div :key =" workViewKey" :class =" {'invisible':processing}"
24+ class =" row mw-100 position-relative mx-auto justify-content-center" >
1825 <WorkCard v-for =" (work , k ) in works " :key =" k "
1926 :subtitle =" work .subtitle "
2027 :thumbnail =" work .thumbnail "
3744import {defineComponent , inject , onMounted , reactive , toRefs , defineAsyncComponent , nextTick } from ' vue' ;
3845import ' @/scss/components/work-view.scss'
3946import {dbType , Work } from " @/firebase/type" ;
40- import {getCurrentWorks } from " @/firebase/getWork" ;
47+ import {getCurrentWorks , liveSubscribe } from " @/firebase/getWork" ;
4148import ' @/svg/todo.svg'
4249import ' @/svg/add.svg'
4350
@@ -52,7 +59,8 @@ export default defineComponent({
5259 const data = reactive ({
5360 processing: false ,
5461 works: undefined as unknown as Array <Work >,
55- progressMsg: ' '
62+ progressMsg: ' ' ,
63+ workViewKey: 0
5664 })
5765
5866 const remove = async (uid : string ) => {
@@ -72,22 +80,22 @@ export default defineComponent({
7280
7381 const checkIfNeedToShowEmptyCard = () => {
7482 const emptyCard = document .getElementById (' empty-card' ) as HTMLDivElement
75- if (data .works .length ) {
76- emptyCard .classList .add (' d-none' )
77- } else {
78- emptyCard .classList .remove (' d-none' )
79- }
83+ emptyCard .classList .toggle (' d-none' , !! data .works .length )
8084 }
8185
8286 const displayWorks = async () => {
83- data .processing = true
8487 data .works = await getCurrentWorks (store )
85- checkIfNeedToShowEmptyCard ()
86- data .processing = false
88+ data .workViewKey ++
89+ await nextTick (() => {
90+ checkIfNeedToShowEmptyCard ()
91+ })
8792 }
8893
8994 onMounted (async () => {
95+ data .processing = true
9096 await displayWorks ()
97+ liveSubscribe (store , displayWorks )
98+ data .processing = false
9199 })
92100
93101 return {
0 commit comments