Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Jul 30, 2022
2 parents 105812d + 1fecc8c commit 056b345
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 197 deletions.
59 changes: 59 additions & 0 deletions OpenTween.Tests/OTBaseFormTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,65 @@ public OTBaseFormTest()
protected void SetupSynchronizationContext()
=> WindowsFormsSynchronizationContext.AutoInstall = false;

[Fact]
public async Task InvokeAsync_Test()
{
using var form = new TestForm();
await Task.Run(async () =>
{
await form.InvokeAsync(() => form.Text = "hoge");
});

Assert.Equal("hoge", form.Text);
}

[Fact]
public async Task InvokeAsync_ReturnValueTest()
{
using var form = new TestForm();
form.Text = "hoge";

await Task.Run(async () =>
{
var ret = await form.InvokeAsync(() => form.Text);
Assert.Equal("hoge", ret);
});
}

[Fact]
public async Task InvokeAsync_TaskTest()
{
using var form = new TestForm();
await Task.Run(async () =>
{
await form.InvokeAsync(async () =>
{
await Task.Delay(1);
form.Text = "hoge";
});
});

Assert.Equal("hoge", form.Text);
}

[Fact]
public async Task InvokeAsync_TaskWithValueTest()
{
using var form = new TestForm();
form.Text = "hoge";

await Task.Run(async () =>
{
var ret = await form.InvokeAsync(async () =>
{
await Task.Delay(1);
return form.Text;
});

Assert.Equal("hoge", ret);
});
}

[Fact]
public void ScaleChildControl_ListViewTest()
{
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/Api/DataModel/TwitterV2TweetIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ namespace OpenTween.Api.DataModel
public class TwitterV2TweetIds
{
[DataMember(Name = "data")]
public TwitterV2TweetId[] Data { get; set; }
public TwitterV2TweetId[]? Data { get; set; }
}
}
37 changes: 0 additions & 37 deletions OpenTween/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,6 @@ public static string GetSelectedText(this WebBrowser webBrowser)
return selectedText;
}

public static Task InvokeAsync(this Control control, Action x)
{
return control.InvokeAsync(new Func<int>(() =>
{
x();
return 0;
}));
}

public static Task InvokeAsync(this Control control, Func<Task> x)
=> control.InvokeAsync<Task>(x).Unwrap();

public static Task<T> InvokeAsync<T>(this Control control, Func<Task<T>> x)
=> control.InvokeAsync<Task<T>>(x).Unwrap();

/// <summary>
/// <see cref="Control.Invoke"/> メソッドのTask版みたいなやつ
/// </summary>
public static Task<T> InvokeAsync<T>(this Control control, Func<T> x)
{
var tcs = new TaskCompletionSource<T>();
control.BeginInvoke(() =>
{
try
{
var ret = x();
tcs.SetResult(ret);
}
catch (Exception ex)
{
tcs.SetException(ex);
}
});

return tcs.Task;
}

public static ReadLockTransaction BeginReadTransaction(this ReaderWriterLockSlim lockObj)
=> new(lockObj);

Expand Down
41 changes: 41 additions & 0 deletions OpenTween/OTBaseForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public class OTBaseForm : Form
/// </remarks>
public SizeF CurrentScaleFactor { get; private set; }

private readonly SynchronizationContext synchronizationContext;

protected OTBaseForm()
{
this.CurrentScaleFactor = new SizeF(1.0f, 1.0f);
this.synchronizationContext = SynchronizationContext.Current;

this.Load += (o, e) =>
{
Expand All @@ -66,6 +69,44 @@ protected OTBaseForm()
};
}

public Task InvokeAsync(Action x)
{
return this.InvokeAsync(new Func<int>(() =>
{
x();
return 0;
}));
}

public Task InvokeAsync(Func<Task> x)
=> this.InvokeAsync<Task>(x).Unwrap();

public Task<T> InvokeAsync<T>(Func<Task<T>> x)
=> this.InvokeAsync<Task<T>>(x).Unwrap();

/// <summary>
/// <see cref="Control.Invoke"/> メソッドのTask版みたいなやつ
/// </summary>
public Task<T> InvokeAsync<T>(Func<T> x)
{
var tcs = new TaskCompletionSource<T>();
this.synchronizationContext.Post(_ =>
{
try
{
var ret = x();
tcs.SetResult(ret);
}
catch (Exception ex)
{
tcs.SetException(ex);
}
},
null);

return tcs.Task;
}

/// <summary>
/// source で指定されたフォントのスタイルを維持しつつ GlobalFont に置き換えた Font を返します
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
[assembly: Guid("2d0ae0ba-adac-49a2-9b10-26fd69e695bf")]

[assembly: AssemblyVersion("2.6.0.0")]
[assembly: AssemblyVersion("2.7.0.0")]

[assembly: InternalsVisibleTo("OpenTween.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // for Moq
23 changes: 12 additions & 11 deletions OpenTween/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions OpenTween/Resources/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
更新履歴

==== Ver 2.7.0(2022/07/30)
* NEW: 発言詳細部の日時ラベルをクリックするとWebブラウザを起動してツイートを表示する機能を追加
* NEW: 設定画面に「Twitter API v2 の使用を有効にする」のチェックボックスを追加
- デフォルトで API v2 が有効となり、通常は変更する必要はありません
- Twitter の API キーを独自に書き換えている場合で、Project への移行を完了できていない等の理由で API v2 を使用できない時はチェックを外してください
* CHG: 発言詳細部の名前ラベルを投稿者とRTしたユーザーで分けずに表示するように変更
* FIX: タブの移動後に発言一覧が空の表示になる不具合を修正
* FIX: 読み込み中の待機ダイアログを表示する際にエラーが発生する不具合を修正
* FIX: Recentタブの読み込み時にエラーダイアログが表示される場合がある不具合を修正
* FIX: タブ名変更後にタイムラインを取得するとエラーが発生する不具合を修正

==== Ver 2.6.0(2022/07/24)
* NEW: Recentタブの発言の取得に Twitter API v2 を使用
- 従来の API v1.1 と比べて、15分間に取得できる回数の制限が15→180回に緩和、一度に取得できる件数が200→100件になります
Expand Down
9 changes: 9 additions & 0 deletions OpenTween/Setting/Panel/ActionPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions OpenTween/Setting/Panel/ActionPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void LoadConfig(SettingCommon settingCommon, SettingLocal settingLocal)
this.BrowserPathText.Text = settingLocal.BrowserPath;
this.CheckCloseToExit.Checked = settingCommon.CloseToExit;
this.CheckMinimizeToTray.Checked = settingCommon.MinimizeToTray;
this.CheckEnableTwitterV2Api.Checked = settingCommon.EnableTwitterV2Api;
this.CheckFavRestrict.Checked = settingCommon.RestrictFavCheck;
this.chkReadOwnPost.Checked = settingCommon.ReadOwnPost;
this.CheckReadOldPosts.Checked = settingCommon.ReadOldPosts;
Expand Down Expand Up @@ -90,6 +91,7 @@ public void SaveConfig(SettingCommon settingCommon, SettingLocal settingLocal)
settingLocal.BrowserPath = this.BrowserPathText.Text.Trim();
settingCommon.CloseToExit = this.CheckCloseToExit.Checked;
settingCommon.MinimizeToTray = this.CheckMinimizeToTray.Checked;
settingCommon.EnableTwitterV2Api = this.CheckEnableTwitterV2Api.Checked;
settingCommon.RestrictFavCheck = this.CheckFavRestrict.Checked;
settingCommon.ReadOwnPost = this.chkReadOwnPost.Checked;
settingCommon.ReadOldPosts = this.CheckReadOldPosts.Checked;
Expand Down
2 changes: 2 additions & 0 deletions OpenTween/Setting/Panel/ActionPanel.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<data name="Button3.Text"><value>Open...</value></data>
<data name="CheckCloseToExit.Size" type="System.Drawing.Size, System.Drawing"><value>150, 16</value></data>
<data name="CheckCloseToExit.Text"><value>Close to Exit application</value></data>
<data name="CheckEnableTwitterV2Api.Size" type="System.Drawing.Size, System.Drawing"><value>172, 16</value></data>
<data name="CheckEnableTwitterV2Api.Text"><value>Enable use of Twitter API v2</value></data>
<data name="CheckFavRestrict.Size" type="System.Drawing.Size, System.Drawing"><value>149, 16</value></data>
<data name="CheckFavRestrict.Text"><value>Check fav result strictly</value></data>
<data name="CheckMinimizeToTray.Size" type="System.Drawing.Size, System.Drawing"><value>106, 16</value></data>
Expand Down
Loading

0 comments on commit 056b345

Please sign in to comment.