-
Notifications
You must be signed in to change notification settings - Fork 0
feat filter bookmarked entry model #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1535c84
feat(lib): add SavedFilter model for user-defined filters
fulleni 7a4fc1a
build(json_serializable): generate SavedFilter model serialization
fulleni 5226f4a
feat(core): add saved filter fixtures
fulleni 2000e76
feat(config): add saved filters limits to user preference config
fulleni c45ee0e
feat(user preferences): add savedFilters to UserContentPreferences model
fulleni 32e18ea
test(models): add saved filters to user content preferences tests
fulleni d735872
chore: file rename
fulleni 95f48b1
feat(remote-config): add saved filters limits for different user types
fulleni 42d4d8a
fix(core): update saved_filter import path and const correctness
fulleni 7395c43
refactor(models): create user_presets directory and move saved_filter
fulleni f694d1a
refactor(models): update import paths for saved_filter
fulleni f4ccb1f
fix(fixtures): update fixture file exports
fulleni c55209b
test: simulate server-side抹除 of saved filters
fulleni 2113118
test(user_presets): add SavedFilter model tests
fulleni 1721512
docs(README): add SavedFilter model description to User Presets section
fulleni e35a29c
build(core): bump version to 1.2.0
fulleni 5bfa80e
feat(CHANGELOG): add changelog for 1.2.0 release
fulleni 120e6ad
test(user_preferences): remove unnecessary code in test case
fulleni cfedeb7
refactor: update saved filter fixture IDs comment
fulleni 5f09f9e
feat(user_presets): add `@immutable` annotation to `SavedFilter` model
fulleni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # 1.2.0 - 2024-05-21 | ||
|
|
||
| - feat: add SavedFilter model for storing user-defined filter combinations. | ||
| - **BREAKING** feat!: link SavedFilter to UserContentPreferences, making `savedFilters` a required field. | ||
| - **BREAKING** feat!: add limits for saved filters to UserPreferenceConfig. | ||
| - **BREAKING** refactor!: organize saved models into a new `user_presets` directory. | ||
| - test: add unit tests for SavedFilter model. | ||
| - test: update tests for UserContentPreferences to include saved filters. | ||
| - docs: update README to reflect new User Presets section and model. | ||
| - chore: add fixture data for SavedFilter. | ||
| - chore: synchronize all related fixtures with recent model updates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import 'package:core/src/fixtures/countries.dart'; | ||
| import 'package:core/src/fixtures/fixture_ids.dart'; | ||
| import 'package:core/src/fixtures/sources.dart'; | ||
| import 'package:core/src/fixtures/topics.dart'; | ||
| import 'package:core/src/models/user_presets/saved_filter.dart'; | ||
|
|
||
| /// A list of predefined saved searches for fixture data. | ||
| final savedFiltersFixturesData = <SavedFilter>[ | ||
| SavedFilter( | ||
| id: kSavedFilterId1, | ||
| name: 'UK Tech & Politics', | ||
| topics: [ | ||
| topicsFixturesData.firstWhere((t) => t.name == 'Technology'), | ||
| topicsFixturesData.firstWhere((t) => t.name == 'Politics'), | ||
| ], | ||
| sources: [sourcesFixturesData.firstWhere((s) => s.name == 'BBC News')], | ||
| countries: [ | ||
| countriesFixturesData.firstWhere((c) => c.name == 'United Kingdom'), | ||
| ], | ||
| ), | ||
| SavedFilter( | ||
| id: kSavedFilterId2, | ||
| name: 'US Business News', | ||
| topics: [topicsFixturesData.firstWhere((t) => t.name == 'Business')], | ||
| sources: const [], | ||
| countries: [ | ||
| countriesFixturesData.firstWhere((c) => c.name == 'United States'), | ||
| ], | ||
| ), | ||
| ]; |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
lib/src/models/user_preferences/user_content_preferences.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import 'package:core/src/models/entities/country.dart'; | ||
| import 'package:core/src/models/entities/source.dart'; | ||
| import 'package:core/src/models/entities/topic.dart'; | ||
| import 'package:equatable/equatable.dart'; | ||
| import 'package:json_annotation/json_annotation.dart'; | ||
fulleni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import 'package:meta/meta.dart'; | ||
|
|
||
| part 'saved_filter.g.dart'; | ||
|
|
||
| /// {@template saved_filter} | ||
| /// Represents a user-defined filter combination for filtering headlines. | ||
| /// | ||
| /// This model stores a named set of criteria, including topics, sources, and | ||
| /// countries, allowing users to quickly re-apply complex filters. | ||
| /// {@endtemplate} | ||
| @immutable | ||
| @JsonSerializable(explicitToJson: true, includeIfNull: true, checked: true) | ||
fulleni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| class SavedFilter extends Equatable { | ||
| /// {@macro saved_filter} | ||
| const SavedFilter({ | ||
| required this.id, | ||
| required this.name, | ||
| required this.topics, | ||
| required this.sources, | ||
| required this.countries, | ||
| }); | ||
|
|
||
| /// Factory method to create a [SavedFilter] instance from a JSON map. | ||
| factory SavedFilter.fromJson(Map<String, dynamic> json) => | ||
| _$SavedFilterFromJson(json); | ||
|
|
||
| /// The unique identifier for the saved filter. | ||
| final String id; | ||
|
|
||
| /// The user-provided name for this saved filter. | ||
| final String name; | ||
|
|
||
| /// The list of topics to include in the filter. | ||
| /// An empty list means no topic filter is applied. | ||
| final List<Topic> topics; | ||
|
|
||
| /// The list of sources to include in the filter. | ||
| /// An empty list means no source filter is applied. | ||
| final List<Source> sources; | ||
|
|
||
| /// The list of countries to include in the filter. | ||
| /// An empty list means no country filter is applied. | ||
| final List<Country> countries; | ||
|
|
||
| /// Converts this [SavedFilter] instance to a JSON map. | ||
| Map<String, dynamic> toJson() => _$SavedFilterToJson(this); | ||
|
|
||
| @override | ||
| List<Object?> get props => [id, name, topics, sources, countries]; | ||
|
|
||
| @override | ||
| bool get stringify => true; | ||
|
|
||
| /// Creates a copy of this [SavedFilter] but with the given fields | ||
| /// replaced with the new values. | ||
| SavedFilter copyWith({ | ||
| String? id, | ||
| String? name, | ||
| List<Topic>? topics, | ||
| List<Source>? sources, | ||
| List<Country>? countries, | ||
| }) { | ||
| return SavedFilter( | ||
| id: id ?? this.id, | ||
| name: name ?? this.name, | ||
| topics: topics ?? this.topics, | ||
| sources: sources ?? this.sources, | ||
| countries: countries ?? this.countries, | ||
| ); | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.