99 mdiShare ,
1010 mdiStar ,
1111 mdiStarOutline ,
12- mdiUpload ,
12+ mdiUpload
1313} from "@mdi/js" ;
1414import Icon from "@mdi/react" ;
1515import {
@@ -20,20 +20,20 @@ import {
2020 Menu ,
2121 MenuItem ,
2222 Skeleton ,
23- Tooltip ,
23+ Tooltip
2424} from "@mui/material" ;
25- import humanizeDuration from "humanize-duration" ;
2625import R from "ramda" ;
2726import React , { useEffect , useState } from "react" ;
2827import { store as RNC } from "react-notifications-component" ;
2928import { useDispatch , useSelector } from "react-redux" ;
3029import LinkComponent from "_atoms/LinkComponent" ;
30+ import { dateElapsed , dateToString } from "_frontend/utils/date" ;
3131import {
3232 attemptArchiveItem ,
3333 attemptDeleteItem ,
3434 attemptGetItem ,
3535 attemptGetItemChildren ,
36- attemptPublishItem ,
36+ attemptPublishItem
3737} from "_thunks/item" ;
3838import { attemptAddBookmark , attemptRemoveBookmark } from "_thunks/user" ;
3939import { deepEqual } from "_utils/compare" ;
@@ -47,9 +47,7 @@ const borderRadius = {
4747// Maximum number of line of the content
4848const LINE_CLAMP = 4 ;
4949
50- const content = ( item , itemChildren ) => {
51- const dispatch = useDispatch ( ) ;
52-
50+ const renderContent = ( item , itemChildren ) => {
5351 if ( item == null || ! item . hasOwnProperty ( "content" ) ) return null ;
5452
5553 if ( item . type === "card" ) {
@@ -84,17 +82,6 @@ const content = (item, itemChildren) => {
8482 } ) ;
8583} ;
8684
87- const dateElapsed = ( date ) => {
88- const created = new Date ( date ) ;
89- const now = new Date ( ) ;
90- return `${ humanizeDuration ( now - created , {
91- language : "ko" ,
92- largest : 1 ,
93- spacer : "" ,
94- round : true ,
95- } ) } 전`;
96- } ;
97-
9885const statusIcon = {
9986 archived : mdiPackageDown ,
10087 public : mdiEarth ,
@@ -116,9 +103,7 @@ export default function Item({
116103
117104 const itemId =
118105 itemObject != null
119- ? itemObject . hasOwnProperty ( "Id" )
120- ? itemObject . Id // id from local store
121- : itemObject . hasOwnProperty ( "_id" )
106+ ? itemObject . hasOwnProperty ( "_id" )
122107 ? itemObject . _id // id from API response
123108 : id
124109 : id ; // id from props
@@ -253,7 +238,7 @@ export default function Item({
253238 ? "public"
254239 : null ;
255240
256- const isCurrentUserOwner = item ? item . owner . _id === user . Id : false ;
241+ const isCurrentUserOwner = item ? item . owner . _id === user . _id : false ;
257242 const isCurrentUserEditor =
258243 item != null && item . hasOwnProperty ( "accessGroups" )
259244 ? item . accessGroups . edit . includes ( user . group )
@@ -292,10 +277,7 @@ export default function Item({
292277 // don't render if visible is false
293278 if ( visible == false ) return null ;
294279
295- const createdDate = new Date ( item . created ) ;
296- const createdString = `${ createdDate . toLocaleDateString (
297- "ko-KR"
298- ) } ${ createdDate . toLocaleTimeString ( "en-GB" ) } `;
280+ const content = renderContent ( item , itemChildren )
299281
300282 return item == null ? (
301283 < div className = "item" key = { itemId } >
@@ -362,10 +344,18 @@ export default function Item({
362344 < div />
363345 ) }
364346 </ div >
365- < div className = "item-content" > { content ( item , itemChildren ) } </ div >
347+ { content != null ? (
348+ < div className = "item-content" > { content } </ div >
349+ ) : (
350+ < div className = "item-content" >
351+ < Skeleton width = "100%" />
352+ < Skeleton width = "100%" />
353+ < Skeleton width = "75%" />
354+ </ div >
355+ ) }
366356 </ ButtonBase >
367357 < div className = "item-footer" >
368- < Tooltip title = { createdString } arrow >
358+ < Tooltip title = { dateToString ( item . created ) } arrow >
369359 < div className = "item-description" >
370360 { `${ item . owner . rank } ${ item . owner . name } · ${ dateElapsed (
371361 item . created
0 commit comments