Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const optionHomeInitialTab = 'home.initial_tab';

const optionMediaSize = 'media.size';

const optionRegexFilter = 'regex_filter';
const optionSubscriptionGroupsOrderByAscending = 'subscription_groups.order_by.ascending';
const optionSubscriptionGroupsOrderByField = 'subscription_groups.order_by.field';
const optionSubscriptionOrderByAscending = 'subscription.order_by.ascending';
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class MessageLookup extends MessageLookupByLibrary {
"prefix": MessageLookupByLibrary.simpleMessage("prefix"),
"private_profile":
MessageLookupByLibrary.simpleMessage("Private profile"),
"regex_filter": MessageLookupByLibrary.simpleMessage("Filter tweets via regex"),
"released_under_the_mit_license": MessageLookupByLibrary.simpleMessage(
"Released under the MIT License"),
"replying_to": MessageLookupByLibrary.simpleMessage("Replying to"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

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

5 changes: 3 additions & 2 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,6 @@
"fritter_blue": "Fritter blue",
"blue_theme_based_on_the_twitter_color_scheme": "Blue theme based on the Twitter color scheme",
"something_broke_in_fritter": "Something broke in Fritter.",
"unable_to_run_the_database_migrations": "Unable to run the database migrations"
}
"unable_to_run_the_database_migrations": "Unable to run the database migrations",
"regex_filter": "Filter tweets via regex"
}
6 changes: 6 additions & 0 deletions lib/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
subtitle: Text(L10n.of(context).export_your_data),
onTap: () => Navigator.pushNamed(context, routeSettingsExport),
),
PrefTitle(title: Text(L10n.of(context).filters)),
PrefText(
label: L10n.of(context).regex_filter,
pref: optionRegexFilter,
// TODO: Add regex validator
hintText: "ExampleFilter1|ExampleFilter[2-3]"),
PrefTitle(title: Text(L10n.of(context).logging)),
PrefCheckbox(
title: Text(L10n.of(context).enable_sentry),
Expand Down
20 changes: 20 additions & 0 deletions lib/tweet/tweet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:timeago/timeago.dart' as timeago;
import 'package:url_launcher/url_launcher.dart';
import 'package:pref/pref.dart';

class TweetTile extends StatefulWidget {
final bool clickable;
Expand Down Expand Up @@ -276,6 +277,25 @@ class TweetTileState extends State<TweetTile> with SingleTickerProviderStateMixi
var numberFormat = NumberFormat.compact();

TweetWithCard tweet = this.tweet.retweetedStatusWithCard == null ? this.tweet : this.tweet.retweetedStatusWithCard!;

// Get filter string from options:
var prefService = PrefService.of(context);
var regexFilterString = prefService.get(optionRegexFilter);

if (regexFilterString != null && regexFilterString.isNotEmpty){
RegExp regexFilter = RegExp('$regexFilterString', caseSensitive: false, multiLine: true);

// Check if regex filter matches tweet text:
if (regexFilter.hasMatch( tweet.fullText.toString() )) {

// TODO: completely remove the card instead of showing "This tweet was filtered"
tweet.text = L10n.of(context).this_tweet_was_filtered;
tweet.fullText = L10n.of(context).this_tweet_was_filtered;
tweet.idStr = '';
tweet.isTombstone = true;
return const SizedBox.shrink(); // Empty widget
}
}

if (tweet.isTombstone ?? false) {
return SizedBox(
Expand Down