return this.Primary;
}
+
+ public ISocialAccount? GetAccountForPostId(PostId postId, AccountKey? preferedAccountKey)
+ {
+ if (preferedAccountKey != null && this.accounts.TryGetValue(preferedAccountKey.Value, out var preferedAccount))
+ {
+ if (preferedAccount.CanUsePostId(postId))
+ return preferedAccount;
+ }
+
+ var primaryAccount = this.Primary;
+ if (primaryAccount.CanUsePostId(postId))
+ return primaryAccount;
+
+ foreach (var account in this.SecondaryAccounts)
+ {
+ if (account.CanUsePostId(postId))
+ return account;
+ }
+
+ return null;
+ }
}
}
public bool IsDisposed { get; }
public void Initialize(UserAccount accountSettings, SettingCommon settingCommon);
+
+ public bool CanUsePostId(PostId postId);
}
}
{
}
+ public bool CanUsePostId(PostId postId)
+ => false;
+
public void Dispose()
=> this.IsDisposed = true;
this.twLegacy.RestrictFavCheck = settingCommon.RestrictFavCheck;
}
+ public bool CanUsePostId(PostId postId)
+ => postId is TwitterStatusId or TwitterDirectMessageId;
+
public void Dispose()
{
if (this.IsDisposed)
var post = this.statuses[statusId];
if (post == null)
{
+ var account = this.GetAccountForPostId(statusId);
+ if (account == null)
+ return;
+
try
{
- post = await this.CurrentTabAccount.Client.GetPostById(statusId, firstLoad: false);
+ post = await account.Client.GetPostById(statusId, firstLoad: false);
}
catch (WebApiException ex)
{
await this.OpenRelatedTab(post);
}
+ public ISocialAccount? GetAccountForPostId(PostId postId)
+ {
+ var preferedAccountKey = this.CurrentTab.SourceAccountKey;
+ return this.accounts.GetAccountForPostId(postId, preferedAccountKey);
+ }
+
/// <summary>
/// 指定されたツイートに対する関連発言タブを開きます
/// </summary>
var tabName = this.statuses.MakeTabName("Related Tweets");
- tabRelated = new RelatedPostsTabModel(tabName, this.CurrentTabAccount.UniqueKey, post)
+ var account = this.GetAccountForPostId(post.StatusId);
+ if (account == null)
+ return;
+
+ tabRelated = new RelatedPostsTabModel(tabName, account.UniqueKey, post)
{
UnreadManage = false,
Notify = false,
var post = TabInformations.GetInstance()[statusId];
if (post == null)
{
+ var account = this.Owner.GetAccountForPostId(statusId);
+ if (account == null)
+ return FormatQuoteTweetHtml(statusId, "This post is unavailable.", isReply);
+
try
{
- post = await this.Owner.CurrentTabAccount.Client.GetPostById(statusId, firstLoad: false)
+ post = await account.Client.GetPostById(statusId, firstLoad: false)
.ConfigureAwait(false);
}
catch (WebApiException ex)
return FormatQuoteTweetHtml(statusId, WebUtility.HtmlEncode($"Err:{ex.Message}(GetStatus)"), isReply);
}
- if (this.Owner.CurrentTabAccount.AccountState.BlockedUserIds.Contains(post.UserId))
+ if (account.AccountState.BlockedUserIds.Contains(post.UserId))
return FormatQuoteTweetHtml(statusId, "This Tweet is unavailable.", isReply);
if (!TabInformations.GetInstance().AddQuoteTweet(post))