{
public interface ISocialProtocolClient
{
+ public Task<PostClass> GetPostById(PostId postId, bool firstLoad);
+
public Task<TimelineResponse> GetHomeTimeline(int count, IQueryCursor? cursor, bool firstLoad);
public Task DeletePost(PostId postId);
#nullable enable
+using System.Linq;
using System.Threading.Tasks;
using OpenTween.Api.GraphQL;
using OpenTween.Models;
this.account = account;
}
+ public async Task<PostClass> GetPostById(PostId postId, bool firstLoad)
+ {
+ this.account.Legacy.CheckAccountState();
+
+ var statusId = this.AssertTwitterStatusId(postId);
+ var request = new TweetDetailRequest
+ {
+ FocalTweetId = statusId,
+ };
+
+ var tweets = await request.Send(this.account.Connection)
+ .ConfigureAwait(false);
+
+ var status = tweets.Select(x => x.ToTwitterStatus())
+ .Where(x => x.IdStr == statusId.Id)
+ .FirstOrDefault() ?? throw new WebApiException("Empty result set");
+
+ var post = this.account.Legacy.CreatePostsFromStatusData(status, firstLoad, favTweet: false);
+
+ return post;
+ }
+
public async Task<TimelineResponse> GetHomeTimeline(int count, IQueryCursor? cursor, bool firstLoad)
{
this.account.Legacy.CheckAccountState();
this.account = account;
}
+ public async Task<PostClass> GetPostById(PostId postId, bool firstLoad)
+ {
+ this.account.Legacy.CheckAccountState();
+
+ var statusId = this.AssertTwitterStatusId(postId);
+ var status = await this.account.Legacy.Api.StatusesShow(statusId)
+ .ConfigureAwait(false);
+
+ var post = this.account.Legacy.CreatePostsFromStatusData(status, firstLoad, favTweet: false);
+
+ return post;
+ }
+
public async Task<TimelineResponse> GetHomeTimeline(int count, IQueryCursor? cursor, bool firstLoad)
{
this.account.Legacy.CheckAccountState();
{
try
{
- var post = await this.tw.GetStatusApi(currentPost.StatusId.ToTwitterStatusId());
+ var post = await this.CurrentTabAccount.Client.GetPostById(currentPost.StatusId, firstLoad: false);
currentPost = currentPost with
{
{
await Task.Run(async () =>
{
- var post = await this.tw.GetStatusApi(currentPost.InReplyToStatusId.ToTwitterStatusId())
+ var post = await this.CurrentTabAccount.Client.GetPostById(currentPost.InReplyToStatusId, firstLoad: false)
.ConfigureAwait(false);
this.statuses.AddPost(post);
{
try
{
- post = await this.tw.GetStatusApi(statusId.ToTwitterStatusId());
+ post = await this.CurrentTabAccount.Client.GetPostById(statusId, firstLoad: false);
}
catch (WebApiException ex)
{
{
try
{
- var twitterAccount = (SocialProtocol.Twitter.TwitterAccount)this.Owner.CurrentTabAccount;
- post = await twitterAccount.Legacy.GetStatusApi(statusId.ToTwitterStatusId())
+ post = await this.Owner.CurrentTabAccount.Client.GetPostById(statusId, firstLoad: false)
.ConfigureAwait(false);
}
catch (WebApiException ex)