Skip to content

Commit

Permalink
Merge pull request #375 from opentween/rename-twitter-classes
Browse files Browse the repository at this point in the history
OpenTween.SocialProtocol.Twitter名前空間への不要な参照を削除
  • Loading branch information
upsilon authored Jun 21, 2024
2 parents e8fe7e8 + 433ffad commit ebcba50
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion OpenTween.Tests/SocialProtocol/AccountCollectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void LoadFromSettings_RemoveTest()

// 欠けている ID は削除される
Assert.Empty(accounts.Items);
Assert.Equal(APIAuthType.None, ((TwitterAccount)accounts.Primary).AuthType);
Assert.IsType<InvalidAccount>(accounts.Primary);
Assert.True(accountItem1.IsDisposed);
}

Expand Down
2 changes: 0 additions & 2 deletions OpenTween/ApplicationEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
#nullable enable

using System;
using System.Linq;
using System.Windows.Forms;
using OpenTween.Connection;
using OpenTween.Models;
using OpenTween.Setting;
using OpenTween.SocialProtocol;
using OpenTween.SocialProtocol.Twitter;

namespace OpenTween
{
Expand Down
3 changes: 1 addition & 2 deletions OpenTween/SocialProtocol/AccountCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
using System.Collections.Generic;
using System.Linq;
using OpenTween.Models;
using OpenTween.SocialProtocol.Twitter;

namespace OpenTween.SocialProtocol
{
public sealed class AccountCollection : IDisposable
{
private Dictionary<AccountKey, ISocialAccount> accounts = new();
private AccountKey? primaryAccountKey;
private readonly ISocialAccount emptyAccount = new TwitterAccount(AccountKey.Empty);
private readonly ISocialAccount emptyAccount = new InvalidAccount(AccountKey.Empty);

public bool IsDisposed { get; private set; }

Expand Down
12 changes: 10 additions & 2 deletions OpenTween/SocialProtocol/InvalidAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using OpenTween.Api;
using OpenTween.Connection;
using OpenTween.Models;
using OpenTween.SocialProtocol.Twitter;

namespace OpenTween.SocialProtocol
{
Expand Down Expand Up @@ -64,6 +63,15 @@ public bool CanUsePostId(PostId postId)
public void Dispose()
=> this.IsDisposed = true;

private class InvalidPersonId : PersonId
{
public override string IdType
=> "invalid";

public override string Id
=> "0";
}

private class InvalidAccountConnection : IApiConnection
{
public void ThrowIfUnauthorizedScope(string scope)
Expand Down Expand Up @@ -135,7 +143,7 @@ private WebApiException CreateException()
private class InvalidAccountState : ISocialAccountState
{
public PersonId UserId
=> new TwitterUserId("0");
=> new InvalidPersonId();

public string UserName
=> "(Unknown account)";
Expand Down

0 comments on commit ebcba50

Please sign in to comment.