Skip to content

Commit 69b5d69

Browse files
committed
add user's post to their own feed
1 parent d5e7f14 commit 69b5d69

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ final googleSignIn = new GoogleSignIn();
1818
final ref = Firestore.instance.collection('insta_users');
1919
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
2020

21+
2122
User currentUserModel;
2223

2324
Future<void> main() async {
2425
await Firestore.instance.settings(timestampsInSnapshotsEnabled: true);
25-
2626
runApp(new Fluttergram());
2727
}
2828

@@ -129,7 +129,7 @@ tryCreateUserRecord(BuildContext context) async {
129129
"displayName": user.displayName,
130130
"bio": "",
131131
"followers": {},
132-
"following": {},
132+
"following": {user.id: true}, // add current user so they can see their own posts in feed,
133133
});
134134
}
135135
}

lib/profile_page.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class ProfilePage extends StatefulWidget {
1313
_ProfilePage createState() => new _ProfilePage(this.userId);
1414
}
1515

16-
class _ProfilePage extends State<ProfilePage> with AutomaticKeepAliveClientMixin<ProfilePage> {
16+
class _ProfilePage extends State<ProfilePage>
17+
with AutomaticKeepAliveClientMixin<ProfilePage> {
1718
final String profileId;
1819
String currentUserId = googleSignIn.currentUser.id;
1920
String view = "grid"; // default view
@@ -398,6 +399,9 @@ class _ProfilePage extends State<ProfilePage> with AutomaticKeepAliveClientMixin
398399
}
399400
}
400401

402+
// hacky fix to enable a user's post to appear in their feed without skewing the follower/following count
403+
if (followings[profileId] != null && followings[profileId]) count -= 1;
404+
401405
followings.forEach(countValues);
402406

403407
return count;

0 commit comments

Comments
 (0)