parser: preserve media grid order

Fixes #3
This commit is contained in:
Amaan Qureshi
2026-09-16 19:59:24 -04:00
parent 9b37d20b51
commit 8e1996e397
+10 -9
View File
@@ -58,17 +58,13 @@ fn parse_timeline_instructions(raw_instructions: &[Instruction]) -> Result<Timel
for instruction in raw_instructions {
if let Some(ref module_items) = instruction.module_items {
let mut module_tweets = Vec::new();
for item in module_items {
if let Some(tweet_result) = item.tweet_result()
&& let Ok(tweet) = parse_tweet_object(tweet_result)
{
module_tweets.push(tweet);
tweets.push(vec![tweet]);
}
}
if !module_tweets.is_empty() {
tweets.push(module_tweets);
}
continue;
}
@@ -81,10 +77,15 @@ fn parse_timeline_instructions(raw_instructions: &[Instruction]) -> Result<Timel
if entry_id.contains("promoted") {
continue;
}
if entry_id.starts_with("tweet-")
|| entry_id.contains("-conversation-")
|| entry_id.starts_with("profile-grid-")
{
if entry_id.starts_with("profile-grid-") {
for item in entry.items() {
if let Some(tweet_result) = item.tweet_result()
&& let Ok(tweet) = parse_tweet_object(tweet_result)
{
tweets.push(vec![tweet]);
}
}
} else if entry_id.starts_with("tweet-") || entry_id.contains("-conversation-") {
let entry_tweets = parse_timeline_entry(entry);
if !entry_tweets.is_empty() {
tweets.push(entry_tweets);