File tree Expand file tree Collapse file tree 2 files changed +25
-18
lines changed
Expand file tree Collapse file tree 2 files changed +25
-18
lines changed Original file line number Diff line number Diff line change 11import { useDataQuery } from '@dhis2/app-runtime'
2+ import { useEffect , useState } from 'react'
23
34const changelogQuery = {
45 changelog : {
@@ -8,30 +9,35 @@ const changelogQuery = {
89}
910
1011const useChangelog = ( { appId, hasChangelog } ) => {
11- const { data, refetch : fetchChangelog } = useDataQuery ( changelogQuery , {
12+ const [ changelog , setChangelog ] = useState ( { } )
13+
14+ const { refetch : fetchChangelog } = useDataQuery ( changelogQuery , {
1215 lazy : true ,
13- variables : {
14- id : appId ,
15- } ,
16- } )
16+ onComplete : ( data ) => {
17+ const changelog = new Changelog ( data ?. changelog ?. changelog )
1718
18- if ( data ) {
19- const changelog = new Changelog ( data ?. changelog ?. changelog )
19+ const changelogByVersion = changelog ?. data ?. reduce ?. (
20+ ( acc , item ) => {
21+ acc [ item . version ] = item . rawChangeSummary
2022
21- const changelogByVersion = changelog ?. data ?. reduce ?. ( ( acc , item ) => {
22- acc [ item . version ] = item . rawChangeSummary
23+ return acc
24+ } ,
25+ { }
26+ )
2327
24- return acc
25- } , { } )
28+ setChangelog ( changelogByVersion )
29+ } ,
30+ } )
2631
27- return changelogByVersion
28- }
32+ useEffect ( ( ) => {
33+ if ( appId && hasChangelog ) {
34+ fetchChangelog ( {
35+ id : appId ,
36+ } )
37+ }
38+ } , [ appId , fetchChangelog , hasChangelog ] )
2939
30- if ( ! hasChangelog ) {
31- return { }
32- } else {
33- fetchChangelog ( )
34- }
40+ return changelog
3541}
3642
3743class Changelog {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const coreApps = [
1313 { name : 'Event Visualizer' , shortName : 'event-visualizer' } ,
1414 { name : 'Import/Export' , shortName : 'import-export' } ,
1515 { name : 'Interpretations' , shortName : 'interpretation' } ,
16+ { name : 'Line Listing' , shortName : 'line-listing' } ,
1617 { name : 'Maintenance' , shortName : 'maintenance' } ,
1718 { name : 'Maps' , shortName : 'maps' } ,
1819 { name : 'Menu Management' , shortName : 'menu-management' } ,
You can’t perform that action at this time.
0 commit comments