Skip to content

Commit

Permalink
fix errors in search
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidatorCoder committed Feb 3, 2022
1 parent 69dc3d1 commit 1025c89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/models/notice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class TimestampConverter implements JsonConverter<DateTime, Timestamp> {
DateTime fromJson(Object timestamp) {
if (timestamp is Timestamp) {
return timestamp.toDate();
} else {
} else if (timestamp is String) {
return DateTime.parse(timestamp.toString());
} else {
return DateTime.fromMillisecondsSinceEpoch(timestamp as int);
}
}

Expand Down
8 changes: 3 additions & 5 deletions lib/models/notice.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/widgets/notice_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ class _NoticeTileState extends State<NoticeTile> {
.format(DateTime.parse(
widget.document?.createdAt.toString() ?? '0'))
.contains('year'))
? "${widget.document?.date.split('-')[0]} ${DateFormat('MMM').format(DateTime(0, int.parse(widget.document?.date.split('-')[1] ?? '0')))}"
? widget.document?.date.isNotEmpty == true
? "${widget.document?.date.split('-')[0]} ${DateFormat('MMM').format(DateTime(0, int.parse(widget.document?.date.split('-')[1] ?? '0')))}"
: DateFormat('dd MMM').format(
widget.document?.createdAt ?? DateTime.now())
: timeago
.format(DateTime.parse(
widget.document?.createdAt.toString() ?? '0'))
Expand Down

0 comments on commit 1025c89

Please sign in to comment.