Skip to content

Commit

Permalink
🐛 Sort notification by create/update time.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlphamerc committed Jul 30, 2021
1 parent e6edd6e commit a82da9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/model/notificationModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ class NotificationModel {

extension NotificationModelHelper on NotificationModel {
UserModel get user => UserModel.fromJson(this.data);

DateTime get timeStamp => DateTime.tryParse(this.updatedAt ?? this.createdAt);
}
1 change: 1 addition & 0 deletions lib/state/authState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AuthState extends AppState {
if (isSignInWithGoogle) {
_googleSignIn.signOut();
Utility.logEvent('google_logout');
isSignInWithGoogle = false;
}
_firebaseAuth.signOut();
notifyListeners();
Expand Down
11 changes: 2 additions & 9 deletions lib/state/notificationState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,8 @@ class NotificationState extends AppState {
var model = NotificationModel.fromJson(tweetKey, map);
addNotificationList(model);
});
_notificationList.sort((x, y) {
if (x.updatedAt != null && y.updatedAt != null) {
return DateTime.parse(y.updatedAt)
.compareTo(DateTime.parse(x.updatedAt));
} else if (x.updatedAt != null) {
return 1;
} else
return 0;
});
_notificationList
.sort((x, y) => y.timeStamp.compareTo(x.timeStamp));
}
}
loading = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/url_text/link_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class LinkPreview extends StatelessWidget {
),
child: CachedNetworkImage(
imageUrl: webInfo.image,
fit: BoxFit.contain,
fit: BoxFit.cover,
),
),
),
Expand Down

0 comments on commit a82da9b

Please sign in to comment.