Skip to content

Commit

Permalink
Enhancement change from #8 Makes quoted status cards optional to #16
Browse files Browse the repository at this point in the history
…make link previews in tweets optional
  • Loading branch information
j-fbriere committed Jul 19, 2023
1 parent fa0468a commit d8e5e9e
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-GB/changelogs/10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Enhancement change from #8 Makes quoted status cards optional to #16 make link previews in tweets optional
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Enhancement change from #8 Makes quoted status cards optional to #16 make link previews in tweets optional
28 changes: 14 additions & 14 deletions lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ class Twitter {
'count': limit.toString(),
'tweet_mode': 'extended',
'skip_status': '1',
'cards_platform': 'Web-12',
'include_cards': '1',
'include_entities': '1',
'include_user_entities': '1',
'include_can_media_tag': '1',
Expand All @@ -474,6 +472,10 @@ class Twitter {
'send_error_codes': '1',
'tweet_search_mode': 'live',
};
if (!leanerFeeds) {
queryParameters['cards_platform'] = 'Web-12';
queryParameters['include_cards'] = '1';
}

if (cursor != null) {
queryParameters['since_id'] = cursor;
Expand All @@ -488,19 +490,19 @@ class Twitter {
return TweetStatus(chains: [], cursorBottom: null, cursorTop: null);
}

var tweetChains = _createTweetsChains(tweets, includeReplies, leanerFeeds: leanerFeeds);
var tweetChains = _createTweetsChains(tweets, includeReplies);

var cursorBottom = result['search_metadata']['max_id_str'] as String?;
var cursorTop = result['search_metadata']['since_id_str'] as String?;

return TweetStatus(chains: tweetChains, cursorBottom: cursorBottom, cursorTop: cursorTop);
}

static List<TweetChain> _createTweetsChains(List<dynamic> tweets, bool includeReplies, {bool leanerFeeds = false}) {
static List<TweetChain> _createTweetsChains(List<dynamic> tweets, bool includeReplies) {
var tweetMap = <String, TweetWithCard>{};

for (var tweetData in tweets) {
var tweet = _fromCardJsonLegacy(tweetData, leanerFeeds: leanerFeeds);
var tweet = _fromCardJsonLegacy(tweetData);

if (!includeReplies && tweet.inReplyToStatusIdStr != null) {
// Exclude replies
Expand Down Expand Up @@ -529,20 +531,18 @@ class Twitter {
return chains;
}

static TweetWithCard _fromCardJsonLegacy(Map<String,dynamic> tweetData, {bool leanerFeeds = false}) {
static TweetWithCard _fromCardJsonLegacy(Map<String,dynamic> tweetData) {
var tweet = TweetWithCard.fromJson(tweetData);

if (!leanerFeeds) {
var quotedStatusMap = tweetData['quoted_status'];
if (quotedStatusMap != null) {
TweetWithCard quotedStatus = _fromCardJsonLegacy(quotedStatusMap, leanerFeeds: leanerFeeds);
tweet.quotedStatus = quotedStatus;
tweet.quotedStatusWithCard = quotedStatus;
}
var quotedStatusMap = tweetData['quoted_status'];
if (quotedStatusMap != null) {
TweetWithCard quotedStatus = _fromCardJsonLegacy(quotedStatusMap);
tweet.quotedStatus = quotedStatus;
tweet.quotedStatusWithCard = quotedStatus;
}
var retweetedStatusMap = tweetData['retweeted_status'];
if (retweetedStatusMap != null) {
TweetWithCard retweetedStatus = _fromCardJsonLegacy(retweetedStatusMap, leanerFeeds: leanerFeeds);
TweetWithCard retweetedStatus = _fromCardJsonLegacy(retweetedStatusMap);
tweet.retweetedStatus = retweetedStatus;
tweet.retweetedStatusWithCard = retweetedStatus;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Requires a restart"),
"large": MessageLookupByLibrary.simpleMessage("Large"),
"leaner_feeds_description": MessageLookupByLibrary.simpleMessage(
"The tweets from feeds do not display quotes"),
"The tweets from feeds do not display preview links"),
"leaner_feeds_label":
MessageLookupByLibrary.simpleMessage("Leaner feeds"),
"legacy_android_import":
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/intl/messages_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Nécessite un redémarrage"),
"large": MessageLookupByLibrary.simpleMessage("Grand"),
"leaner_feeds_description": MessageLookupByLibrary.simpleMessage(
"Les tweets de flux ne montrent pas de tweet en citation"),
"Les tweets de flux ne montrent pas d\'aperçu de liens\'"),
"leaner_feeds_label":
MessageLookupByLibrary.simpleMessage("Flux plus léger"),
"legacy_android_import": MessageLookupByLibrary.simpleMessage(
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/l10n.dart

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

2 changes: 1 addition & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -414,5 +414,5 @@
"functionality_unsupported": "This functionality is no longer supported by Twitter!",
"add_subscriptions": "Add subscriptions",
"leaner_feeds_label": "Leaner feeds",
"leaner_feeds_description": "The tweets from feeds do not display quotes"
"leaner_feeds_description": "The tweets from feeds do not display preview links"
}
2 changes: 1 addition & 1 deletion lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -492,5 +492,5 @@
"add_subscriptions": "Ajouter des abonnements",
"@add_subscriptions": {},
"leaner_feeds_label": "Flux plus léger",
"leaner_feeds_description": "Les tweets de flux ne montrent pas de tweet en citation"
"leaner_feeds_description": "Les tweets de flux ne montrent pas d'aperçu de liens'"
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 3.1.6+9
version: 3.1.7+10

environment:
sdk: ">=2.18.0 <3.0.0"
Expand Down

0 comments on commit d8e5e9e

Please sign in to comment.