Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsubscribe from OnExtensionsChanged when unloading Extensions page #3862

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.vsconfig = .vsconfig
Directory.Build.props = Directory.Build.props
Solution.props = Solution.props
ToolingVersions.props = ToolingVersions.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome", "src\DevHome.csproj", "{60E0FD98-5396-436D-BAB7-187A853A5DC6}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public ExtensionLibraryViewModel(IExtensionService extensionService, DispatcherQ
_extensionService = extensionService;
_dispatcherQueue = dispatcherQueue;

extensionService.OnExtensionsChanged -= OnExtensionsChanged;
extensionService.OnExtensionsChanged += OnExtensionsChanged;

StorePackagesList = new();
InstalledPackagesList = new();
}
Expand All @@ -69,6 +66,21 @@ public async Task LoadedAsync()
{
await GetInstalledPackagesAndExtensionsAsync();
GetAvailablePackages();

if (_extensionService != null)
{
_extensionService.OnExtensionsChanged -= OnExtensionsChanged;
_extensionService.OnExtensionsChanged += OnExtensionsChanged;
Comment on lines +72 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this at all? To trigger some kind of "on subscribe" event?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can update the page when the list changes -- for example, if something shows up in the list of extensions available in the store, and then you install it, you'll see the UI update it from being in that list to the list of installed extensions.

}
}

[RelayCommand]
public void Unloaded()
{
if (_extensionService != null)
{
_extensionService.OnExtensionsChanged -= OnExtensionsChanged;
}
}

private async void OnExtensionsChanged(object? sender, EventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<ic:EventTriggerBehavior EventName="Loaded">
<ic:InvokeCommandAction Command="{x:Bind ViewModel.LoadedCommand}" />
</ic:EventTriggerBehavior>
<ic:EventTriggerBehavior EventName="Unloaded">
<ic:InvokeCommandAction Command="{x:Bind ViewModel.UnloadedCommand}" />
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>

<Page.Resources>
Expand Down
Loading