}
impl<Type: FileType, Source: FileDataSource> File<Type, Source> {
- fn new(client: &mut Client, source: Source, desc: ColouredString) ->
+ fn new(client: &mut Client, source: Source, desc: ColouredString,
+ initial_pos: Option<FilePosition>) ->
Result<Self, ClientError>
{
source.init(client)?;
contents.update_items(client);
// FIXME: once we have an LDB, that's where initial pos comes from
- let initial_pos = FilePosition::item_bottom(
- contents.last_index() as isize);
+ let mut initial_pos = initial_pos.unwrap_or_else(
+ || FilePosition::item_bottom(isize::MAX));
+
+ initial_pos.item = max(initial_pos.item, contents.first_index());
+ initial_pos.item = min(initial_pos.item, contents.last_index());
+
+ dbg!(initial_pos);
let ff = File {
contents,
let file = File::<StatusFeedType, _>::new(
client, FeedSource::new(FeedId::Home), ColouredString::general(
"Home timeline <H>",
- "HHHHHHHHHHHHHHHHHKH"))?;
+ "HHHHHHHHHHHHHHHHHKH"), None)?;
Ok(Box::new(file))
}
let file = File::<StatusFeedType, _>::new(
client, FeedSource::new(FeedId::Local), ColouredString::general(
"Local public timeline <L>",
- "HHHHHHHHHHHHHHHHHHHHHHHHHKH"))?;
+ "HHHHHHHHHHHHHHHHHHHHHHHHHKH"), None)?;
Ok(Box::new(file))
}
let file = File::<StatusFeedType, _>::new(
client, FeedSource::new(FeedId::Public), ColouredString::general(
"Public timeline <P>",
- "HHHHHHHHHHHHHHHHHHHKH"))?;
+ "HHHHHHHHHHHHHHHHHHHKH"), None)?;
Ok(Box::new(file))
}
let file = File::<NotificationStatusFeedType, _>::new(
client, FeedSource::new(FeedId::Mentions), ColouredString::general(
"Mentions [ESC][R]",
- "HHHHHHHHHHHHKKKHHKH"))?;
+ "HHHHHHHHHHHHKKKHHKH"), None)?;
Ok(Box::new(file))
}
let file = File::<EgoNotificationFeedType, _>::new(
client, FeedSource::new(FeedId::Ego), ColouredString::general(
"Ego Log [ESC][L][L][E]",
- "HHHHHHHHHHHKKKHHKHHKHHKH"))?;
+ "HHHHHHHHHHHKKKHHKHHKHHKH"), None)?;
Ok(Box::new(file))
}
let file = File::<UserListFeedType, _>::new(
client, FeedSource::new(FeedId::Favouriters(id.to_owned())),
ColouredString::uniform(
- &format!("Users who favourited post {id}"), 'H'))?;
+ &format!("Users who favourited post {id}"), 'H'), None)?;
Ok(Box::new(file))
}
let file = File::<UserListFeedType, _>::new(
client, FeedSource::new(FeedId::Boosters(id.to_owned())),
ColouredString::uniform(
- &format!("Users who boosted post {id}"), 'H'))?;
+ &format!("Users who boosted post {id}"), 'H'), None)?;
Ok(Box::new(file))
}
let file = File::<UserListFeedType, _>::new(
client, FeedSource::new(FeedId::Followers(id.to_owned())),
ColouredString::uniform(
- &format!("Users who follow {name}"), 'H'))?;
+ &format!("Users who follow {name}"), 'H'), None)?;
Ok(Box::new(file))
}
let file = File::<UserListFeedType, _>::new(
client, FeedSource::new(FeedId::Followees(id.to_owned())),
ColouredString::uniform(
- &format!("Users who {name} follows"), 'H'))?;
+ &format!("Users who {name} follows"), 'H'), None)?;
Ok(Box::new(file))
}
let title = ColouredString::uniform(
&format!("Posts mentioning hashtag #{tag}"), 'H');
let file = File::<StatusFeedType, _>::new(
- client, FeedSource::new(FeedId::Hashtag(tag.to_owned())), title)?;
+ client, FeedSource::new(FeedId::Hashtag(tag.to_owned())), title, None)?;
Ok(Box::new(file))
}
&format!("Information about user {username}"), 'H');
let file = File::<ExamineUserFileType, _>::new(
- client, StaticSource::singleton(ac.id), title)?;
+ client, StaticSource::singleton(ac.id), title, None)?;
Ok(Box::new(file))
}
&format!("Information about post {}", st.id), 'H');
let file = File::<DetailedStatusFileType, _>::new(
- client, StaticSource::singleton(st.id), title)?;
+ client, StaticSource::singleton(st.id), title, None)?;
Ok(Box::new(file))
}
let title = ColouredString::uniform(&title, 'H');
let file = File::<StatusFeedType, _>::new(
- client, StaticSource::vector(ids), title)?;
+ client, StaticSource::vector(ids), title, None)?;
Ok(Box::new(file))
}