@@ -890,25 +890,26 @@ <h1 class="ev-name">${name || 'Untitled Event'}</h1>
890890 </ div > `
891891}
892892
893- function TrackerColumn ( { url } ) {
893+ function TrackerColumn ( { url, hideCompleted } ) {
894894 const t = useTracker ( url )
895895 const [ draft , setDraft ] = useState ( '' )
896896 const submit = ( e ) => { e ?. preventDefault ?. ( ) ; const v = draft . trim ( ) ; if ( ! v ) return ; t . addIssue ( v ) ; setDraft ( '' ) }
897897
898898 if ( t . loading ) return html `< div class ="col "> < div class ="col-head "> < div class ="col-title "> Loading…</ div > </ div > </ div > `
899899 if ( t . error && ! t . doc ) return html `< div class ="col "> < div class ="col-head "> < div class ="col-title "> Error</ div > </ div > < div class ="err "> ${ t . error } </ div > </ div > `
900900 const doc = t . doc || { }
901- const issues = Array . isArray ( doc . issue ) ? doc . issue : ( doc . issue ? [ doc . issue ] : [ ] )
902- const open = issues . filter ( i => i . status !== 'COMPLETED' ) . length
901+ const allIssues = Array . isArray ( doc . issue ) ? doc . issue : ( doc . issue ? [ doc . issue ] : [ ] )
902+ const open = allIssues . filter ( i => i . status !== 'COMPLETED' ) . length
903+ const visible = hideCompleted ? allIssues . filter ( i => i . status !== 'COMPLETED' ) : allIssues
903904 return html `
904905 < div class ="col ">
905906 < div class ="col-head ">
906907 < div class ="col-title "> ${ doc . title || url . split ( '/' ) . pop ( ) } </ div >
907- < div class ="col-count "> ${ open } /${ issues . length } </ div >
908+ < div class ="col-count "> ${ open } /${ allIssues . length } </ div >
908909 ${ t . status && html `< div class =${ 'col-status ' + t . status } > ${ t . status === 'saving' ? '\u2026 saving' : t . status === 'saved' ? '\u2713 saved' : '\u26a0 ' + ( t . error || 'error' ) } </ div > ` }
909910 </ div >
910911 < div class ="issues ">
911- ${ issues . map ( it => html `< ${ IssueRow } key =${ it [ '@id' ] } issue=${ it }
912+ ${ visible . map ( it => html `< ${ IssueRow } key =${ it [ '@id' ] } issue=${ it }
912913 onToggle=${ ( ) => t . toggleIssue ( it [ '@id' ] ) }
913914 onEdit=${ ( v ) => t . editIssue ( it [ '@id' ] , v ) }
914915 onDelete=${ ( ) => t . deleteIssue ( it [ '@id' ] ) } /> ` ) }
@@ -919,10 +920,14 @@ <h1 class="ev-name">${name || 'Untitled Event'}</h1>
919920 </ div > `
920921}
921922
923+ const HIDE_KEY = 'solid-preact.hideCompleted'
924+
922925function TasksView ( { identity } ) {
923926 const webid = identity ?. type === 'solid' ? identity . id : null
924927 const ti = useTypeIndex ( webid )
925928 const urls = findRegistrations ( ti . data , TRACKER_CLASS ) . map ( r => r . instance ) . filter ( Boolean )
929+ const [ hideCompleted , setHideCompleted ] = useState ( ( ) => localStorage . getItem ( HIDE_KEY ) === '1' )
930+ useEffect ( ( ) => { localStorage . setItem ( HIDE_KEY , hideCompleted ? '1' : '0' ) } , [ hideCompleted ] )
926931
927932 if ( ! webid ) return html `
928933 < div >
@@ -939,13 +944,17 @@ <h1 class="page-title">Tasks</h1>
939944 < div style =${ { marginBottom : '14px' , fontSize : '12px' , color : 'var(--muted)' , display : 'flex' , gap : '8px' , alignItems : 'center' } } >
940945 < span class ="island-badge " style =${ { background : '#d1fae5' , color : '#065f46' } } > discovery</ span >
941946 < span > ${ status } </ span >
947+ < label style =${ { marginLeft : 'auto' , display : 'inline-flex' , alignItems : 'center' , gap : '6px' , cursor : 'pointer' , userSelect : 'none' , color : 'var(--text)' } } >
948+ < input type ="checkbox " checked =${ hideCompleted } onChange =${ ( e ) => setHideCompleted ( e . target . checked ) } style=${ { accentColor : '#6366f1' } } />
949+ < span > Hide completed</ span >
950+ </ label >
942951 </ div >
943952 < h1 class ="page-title "> Tasks</ h1 >
944953 < p class ="page-sub "> Discovered via your TypeIndex. All edits PUT back to your pod.</ p >
945954 ${ urls . length === 0 && ! ti . loading
946955 ? html `< div class ="card " style =${ { marginTop : '18px' , color : 'var(--muted)' } } > No < code > wf:Tracker</ code > registrations in your TypeIndex yet.</ div > `
947956 : html `< div class ="columns ">
948- ${ urls . map ( u => html `< ${ TrackerColumn } key =${ u } url=${ u } /> ` ) }
957+ ${ urls . map ( u => html `< ${ TrackerColumn } key =${ u } url=${ u } hideCompleted= ${ hideCompleted } /> ` ) }
949958 </ div > ` }
950959 </ div > `
951960}
0 commit comments