Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the hide_globally feature #35

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/models/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ class Category {
final int? id;
final String? title;
final int? userId;
final bool? hideGlobally;

Category({
this.id,
this.title,
this.userId,
this.hideGlobally,
});

factory Category.fromJson(Map<String, dynamic> json) {
return Category(
id: json['id'],
title: json['title'],
userId: json['user_id'],
hideGlobally:
(json.containsKey('hide_globally') ? json['hide_globally'] : false),
);
}
}
4 changes: 4 additions & 0 deletions lib/models/feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Feed {
final String? userAgent;
final int? userId;
final String? userName;
final bool? hideGlobally;

Feed({
this.category,
Expand All @@ -39,6 +40,7 @@ class Feed {
this.userAgent,
this.userId,
this.userName,
this.hideGlobally,
});

factory Feed.fromJson(Map<String, dynamic> json) {
Expand All @@ -61,6 +63,8 @@ class Feed {
userAgent: json['user_agent'],
userId: json['user_id'],
userName: json['user_name'],
hideGlobally:
(json.containsKey('hide_globally') ? json['hide_globally'] : false),
);
}
}
18 changes: 12 additions & 6 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ List<Entry?> filterEntries(Data data, Nav nav) {
.where((i) => i!.feed!.category!.id == nav.currentCategoryId)
.toList();
} else if (nav.currentFeedId != null) {
entries = data.entries.where((i) => i!.feedId == nav.currentFeedId).toList();
entries =
data.entries.where((i) => i!.feedId == nav.currentFeedId).toList();
} else {
entries = data.entries;
entries = data.entries
.where((i) =>
i!.feed!.hideGlobally == false &&
i.feed!.category!.hideGlobally == false)
.toList();
}
return entries;
}
Expand Down Expand Up @@ -211,10 +216,11 @@ class MyHomeEntryList extends StatelessWidget {
),
),
subtitle: Row(children: <Widget>[
Text(
(nav.currentFeedId == null ? entry.feed!.title! + '\n' : '') +
DateFormat('yyy-MM-dd HH:mm')
.format(DateTime.parse(entry.publishedAt!))),
Text((nav.currentFeedId == null
? entry.feed!.title! + '\n'
: '') +
DateFormat('yyy-MM-dd HH:mm')
.format(DateTime.parse(entry.publishedAt!))),
Spacer(),
entry.starred!
? Icon(
Expand Down