Skip to content

Commit a82da9b

Browse files
committed
🐛 Sort notification by create/update time.
1 parent e6edd6e commit a82da9b

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

lib/model/notificationModel.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ class NotificationModel {
3535

3636
extension NotificationModelHelper on NotificationModel {
3737
UserModel get user => UserModel.fromJson(this.data);
38+
39+
DateTime get timeStamp => DateTime.tryParse(this.updatedAt ?? this.createdAt);
3840
}

lib/state/authState.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class AuthState extends AppState {
4545
if (isSignInWithGoogle) {
4646
_googleSignIn.signOut();
4747
Utility.logEvent('google_logout');
48+
isSignInWithGoogle = false;
4849
}
4950
_firebaseAuth.signOut();
5051
notifyListeners();

lib/state/notificationState.dart

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,8 @@ class NotificationState extends AppState {
7575
var model = NotificationModel.fromJson(tweetKey, map);
7676
addNotificationList(model);
7777
});
78-
_notificationList.sort((x, y) {
79-
if (x.updatedAt != null && y.updatedAt != null) {
80-
return DateTime.parse(y.updatedAt)
81-
.compareTo(DateTime.parse(x.updatedAt));
82-
} else if (x.updatedAt != null) {
83-
return 1;
84-
} else
85-
return 0;
86-
});
78+
_notificationList
79+
.sort((x, y) => y.timeStamp.compareTo(x.timeStamp));
8780
}
8881
}
8982
loading = false;

lib/widgets/url_text/link_preview.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class LinkPreview extends StatelessWidget {
8484
),
8585
child: CachedNetworkImage(
8686
imageUrl: webInfo.image,
87-
fit: BoxFit.contain,
87+
fit: BoxFit.cover,
8888
),
8989
),
9090
),

0 commit comments

Comments
 (0)