Refactor state management into context singletons#751
Conversation
Co-authored-by: huynhsontung <31434093+huynhsontung@users.noreply.github.com>
|
@copilot Good start. But since SessionContext is just a collection of smaller state objects, it's probably better to register these state objects to the DI directly instead of going through the SessionContext object. Each class should be in its own file. Put them in a new folder called Contexts at the root of Screenbox.Core project. Rename the classes if necessary. |
Co-authored-by: huynhsontung <31434093+huynhsontung@users.noreply.github.com>
States are now registered individually as singletons under a new Contexts folder (one class per file) and injected directly where needed. Changes in abdd839. |
|
@copilot rename the ...State classes to ...Context class instead since they are under Contexts folder |
Co-authored-by: huynhsontung <31434093+huynhsontung@users.noreply.github.com>
Centralize mutable application state in dedicated context singletons so view models remain transient and services/factories stay stateless.
Context model
Screenbox.Core/Contexts.View models to context-backed state
CommonViewModel,VolumeViewModel, andMediaListViewModelnow pull/persist state through injected context singletons, allowing transient lifetimes while retaining user/session data.Services and factories statelessness
LibVlcService, transport controls, notifications, cast, window, library services, and last-position tracker now store mutable caches in their respective context classes rather than instance fields.Example:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.