Add show/hide comments toggle

This commit is contained in:
Hank Grabowski 2022-12-13 07:25:03 -05:00
parent 6a05db91e0
commit 9031ab98f5

View file

@ -40,6 +40,8 @@ class _StatusControlState extends State<StatusControl> {
var showContent = true;
var showComments = false;
EntryTreeItem get item => widget.originalItem;
TimelineEntry get entry => item.entry;
@ -101,10 +103,19 @@ class _StatusControlState extends State<StatusControl> {
),
if (isPost && hasComments)
TextButton(
onPressed: () async => await manager.refreshStatusChain(item.id),
child: Text('Load Comments'),
onPressed: () async {
setState(() {
showComments = !showComments;
});
if (showComments) {
await manager.refreshStatusChain(item.id);
}
},
child:
Text(showComments ? 'Hide Comments' : 'Load & Show Comments'),
),
if (item.totalChildren > 0) buildChildComments(context),
if (item.totalChildren > 0 && showComments)
buildChildComments(context),
],
),
);