Skip to content

Commit 3a82f09

Browse files
committed
refactor: 重构代码
1 parent 9b706e6 commit 3a82f09

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/BootstrapBlazor/Components/Tab/Tab.razor.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,19 +950,26 @@ private async Task OnRefreshAsync()
950950
{
951951
// refresh the active tab item
952952
var item = TabItems.FirstOrDefault(i => i.IsActive);
953-
item.Refresh(_cache);
954953

955-
if (OnToolbarRefreshCallback != null)
954+
if (item is not null)
956955
{
957-
await OnToolbarRefreshCallback();
956+
await Refresh(item);
958957
}
959958
}
960959

961960
/// <summary>
962961
/// Refresh the tab item method
963962
/// </summary>
964963
/// <param name="item"></param>
965-
public void Refresh(TabItem item) => item.Refresh(_cache);
964+
public async Task Refresh(TabItem item)
965+
{
966+
item.Refresh(_cache);
967+
968+
if (OnToolbarRefreshCallback != null)
969+
{
970+
await OnToolbarRefreshCallback();
971+
}
972+
}
966973

967974
/// <summary>
968975
/// <inheritdoc/>

src/BootstrapBlazor/Extensions/TabItemExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public static RenderFragment RenderContent(this TabItem item, ConcurrentDictiona
2424
builder.CloseComponent();
2525
};
2626

27-
public static void Refresh(this TabItem? item, ConcurrentDictionary<TabItem, TabItemContent> cache)
27+
public static void Refresh(this TabItem item, ConcurrentDictionary<TabItem, TabItemContent> cache)
2828
{
29-
if (item is not null && cache.TryGetValue(item, out var content))
29+
if (cache.TryGetValue(item, out var content))
3030
{
3131
content.Render();
3232
}

0 commit comments

Comments
 (0)