Skip to content

Commit

Permalink
FIX: Communities: Loading About & Featured Posts DevCom-IITB#47
Browse files Browse the repository at this point in the history
  • Loading branch information
Prayas-Agrawal committed Jan 28, 2024
1 parent aeffd79 commit 49bbedd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/src/blocs/community_post_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CommunityPostBloc {
// _communitySubject.add(defCommunities);
// print("refresh");

_communitySubject.add([]);
// _communitySubject.add([]);
if (id == null) {
return;
}
Expand Down
65 changes: 37 additions & 28 deletions lib/src/routes/communitydetails.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class _CommunityDetailsState extends State<CommunityDetails> {
});
}
});

}

@override
Expand Down Expand Up @@ -297,27 +296,27 @@ class CommunityAboutSectionState extends State<CommunityAboutSection> {
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: TabBar(
tabs: [
Tab(
child: Text(
"About",
style: theme.textTheme.bodyText1,
),
child: TabBar(
tabs: [
Tab(
child: Text(
"About",
style: theme.textTheme.bodyText1,
),
Tab(
child: Text(
"Members",
style: theme.textTheme.bodyText1,
),
)
],
onTap: (index) {
setState(() {
_selectedIndex = index;
});
},
),
),
Tab(
child: Text(
"Members",
style: theme.textTheme.bodyText1,
),
)
],
onTap: (index) {
setState(() {
_selectedIndex = index;
});
},
),
),
IndexedStack(
children: [
Expand Down Expand Up @@ -425,7 +424,11 @@ class CommunityAboutSectionState extends State<CommunityAboutSection> {

Widget _buildFeaturedPosts(ThemeData theme, List<CommunityPost>? posts) {
if (posts == null || posts.isEmpty) {
return Container();
return Center(
child: CircularProgressIndicatorExtended(
label: Text("Getting Featured Posts"),
),
);
}
return Column(
children: [
Expand Down Expand Up @@ -494,8 +497,8 @@ class _CommunityPostSectionState extends State<CommunityPostSection> {
var theme = Theme.of(context);
var bloc = BlocProvider.of(context)!.bloc;
var communityPostBloc = bloc.communityPostBloc;
loading=false;

loading = false;
if (firstBuild) {
communityPostBloc.query = "";
communityPostBloc.refresh(id: widget.community?.id);
Expand Down Expand Up @@ -530,8 +533,7 @@ class _CommunityPostSectionState extends State<CommunityPostSection> {
cpType = CPType.All;
});
await communityPostBloc.refresh(
type: CPType.All,
id: widget.community?.id);
type: CPType.All, id: widget.community?.id);
setState(() {
loading = false;
});
Expand Down Expand Up @@ -573,8 +575,7 @@ class _CommunityPostSectionState extends State<CommunityPostSection> {
});
await communityPostBloc.refresh(
type: CPType.PendingPosts,
id: widget.community?.id
);
id: widget.community?.id);
setState(() {
loading = false;
});
Expand Down Expand Up @@ -624,6 +625,14 @@ class _CommunityPostSectionState extends State<CommunityPostSection> {
stream: communityPostBloc.communityposts,
builder: (BuildContext context,
AsyncSnapshot<List<CommunityPost>> snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Center(
child: CircularProgressIndicatorExtended(
label: Text("Getting the latest posts"),
),
);
}
return Column(
children: _buildPostList(snapshot, theme,
communityPostBloc, community.id),
Expand Down

0 comments on commit 49bbedd

Please sign in to comment.