Skip to content

Commit

Permalink
Fix issue #63 (ads) - part 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fbriere committed Sep 3, 2023
1 parent 4a6d098 commit 9b434e4
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,15 @@ class Twitter {
for (var entry in addEntries) {
var entryId = entry['entryId'] as String;
if (entryId.startsWith('tweet-')) {
var result = entry['content']['itemContent']['tweet_results']?['result'];
if (entry['content']['itemContent']['promotedMetadata'] == null) {
var result = entry['content']['itemContent']['tweet_results']?['result'];

if (result != null) {
result = result['rest_id'] == null ? result['tweet'] : result;
replies.add(TweetChain(id: result['rest_id'], tweets: [TweetWithCard.fromGraphqlJson(result)], isPinned: false));
} else {
replies.add(TweetChain(id: entryId.substring(6), tweets: [TweetWithCard.tombstone({})], isPinned: false));
if (result != null) {
result = result['rest_id'] == null ? result['tweet'] : result;
replies.add(TweetChain(id: result['rest_id'], tweets: [TweetWithCard.fromGraphqlJson(result)], isPinned: false));
} else {
replies.add(TweetChain(id: entryId.substring(6), tweets: [TweetWithCard.tombstone({})], isPinned: false));
}
}
}

Expand All @@ -358,15 +360,17 @@ class Twitter {
for (var item in entry['content']['items']) {
var itemType = item['item']?['itemContent']?['itemType'];
if (itemType == 'TimelineTweet') {
var result = item['item']['itemContent']['tweet_results']?['result'];
if (result != null) {
if (result['rest_id'] != null || result['tweet'] != null) {
tweets.add(TweetWithCard.fromGraphqlJson(result['rest_id'] != null ? result : result['tweet']));
if (item['item']['itemContent']['promotedMetadata'] == null) {
var result = item['item']['itemContent']['tweet_results']?['result'];
if (result != null) {
if (result['rest_id'] != null || result['tweet'] != null) {
tweets.add(TweetWithCard.fromGraphqlJson(result['rest_id'] != null ? result : result['tweet']));
} else {
tweets.add(TweetWithCard.tombstone({}));
}
} else {
tweets.add(TweetWithCard.tombstone({}));
}
} else {
tweets.add(TweetWithCard.tombstone({}));
}
}
}
Expand All @@ -382,14 +386,14 @@ class Twitter {
static Future<TweetStatus> getTweet(String id, {String? cursor}) async {
var variables = {
'focalTweetId': id,
'referrer': 'tweet',
'with_rux_injections': false,
//'referrer': 'tweet',
//'with_rux_injections': false,
'includePromotedContent': false,
'withCommunity': true,
//'withCommunity': true,
'withQuickPromoteEligibilityTweetFields': false,
'includeHasBirdwatchNotes': false,
'withBirdwatchNotes': false,
'withVoice': true,
'withVoice': false,
'withV2Timeline': true
};

Expand Down Expand Up @@ -808,6 +812,10 @@ class Twitter {
return false;
}

if (t['content']['itemContent']['promotedMetadata'] != null) {
return false;
}

if (includeReplies) {
return true;
}
Expand Down

0 comments on commit 9b434e4

Please sign in to comment.