-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Refactor the way items are handled in Vuex stores #801
Comments
Two things: • I wouldn't put the That we we have a clear distinction between our custom prefs, the API supported ones and the session-based stuff. • Don't know which name we could use, but if we plan to follow @Perseusdehond design concepts, we're going to have multiple "homepages", one for each content type that the server has available. So we should reconsider the |
True, though for organization it makes a bit more sense there. I was seeing the DisplayPreferences store as more of a "setting that applies to the general way the client behaves", with more specific settings being part of other more specific stores. Thinking more about it, we should probably treat the HomeHeader has just another section, for it to really make sense. The only special thing would be that it's ALWAYS at ID 0 in This also has the benefit of moving the contents of HomeHeader outside of the component and into the proper store.
I think |
TLDR of some of the stuff @ThibaultNocchi and me threw at the air while talking about the store situation (specially while discussing #632), so they don't end up missing: • Item-agnostic stores for API items (exactly as it's proposed in this issue, but you actually formalised it :D). • DisplayPreferences store that saves the few API-supported fields that the API has (like Chromecast version, view types, etc etc), syncs and diffs between local and remote state on disconnections and casts custom preferences to the Javascript datatypes. • Settings store for simple data (colors, themes, seek length... Booleans, integers, etc). Although API only supports strings for this, the state is fully casted and typed. (All of this, except the API-supported fields of the DisplayPreferences API and diff syncing is already implemented in #632. The approach follows a similar fashion to what you propose with items, but for settings: "core" that handles raw API stuff and "secondary" for abstracted data) • Specific stores for more complex data like arrays and dictionaries and full UI-wise features (like home sections). This is exactly another thing you're formalising here. I think we all agree somewhat in the architecture we are aiming for, however there are a few key challenges we have with this API and I think we're missing, specially if we want to develop the connection between DisplayPreferences - "Core" stores or DisplayPreferences - Settings stores: • How are we going to store data that mixes API-supported fields and not API-supported fields? You had a really nice suggestion for handling the For Homesections, we can use We should think about how we're going to structure that kind of data, because I discovered how limited are we API-wise while working in that PR. We store them in the relevant store (alongside with complex data) and then "divide" them later and "redirect" it properly to where it fits? Or leave them separated "logically" but correctly placed so they don't need to be destructured? This are concerns that we can decide to ignore though, as we could simply serialize everything to JSON and store the JSON string in the server. In fact, we almost went that route in #632 to avoid casting issues, until we managed to get it to work in an state that's practically impossible to have issues while casting. We finally went the way of casting and doing things right API-wise (although that meant doing workarounds) as the data is more manageable in JF database and having a mediocre schema doesn't mean we should stick with the mediocrity, specially when we want to get rid of JSON blobs in the library database completely. |
I don't understand 😅. If you consider them landing pages (that's the best term to describe them, yeah, couldn't find it before ^^) what's the point of keeping |
My "HomeSections" store is specifically for the actual home page :p |
So, how are we going to store that data then, if we plan to follow his design approach? |
For #498 specifically, we can just assume that, depending on the type of home section, index 0 is a special item (The library, the collection, the actor, etc). This keeps a consistent way to store data for everything, which doesn't involve having to make (and handle) different data for all the different sections. When we render that section, we just treat 0 as a special item, but most of the logic stays the same.
This is mostly an helper for the home header, specifically. There is an API for storing home sections which would be used for handling the list of actual sections. We don't have to store booleans for each section, fortunately :) |
Issues go stale after 60 days of inactivity. Mark the issue as fresh by adding a comment or commit. Stale issues close after an additional 14 days of inactivity. If this issue is safe to close now please do so. If you have any questions you can reach us on Matrix or Social Media. |
Sorry bot |
Issues go stale after 60 days of inactivity. Mark the issue as fresh by adding a comment or commit. Stale issues close after an additional 14 days of inactivity. If this issue is safe to close now please do so. If you have any questions you can reach us on Matrix or Social Media. |
Multiple design issues plague our current Vuex stores.
Among them is the way we store items coming from the API ("items" here refers to BaseItemDto, UserDto and PublicSystemInfo, the basic item types of the API)
We currently store multiple copies of these in various stores, which makes no sense (It creates more noise, makes store testing more complex and makes updates through the Websocket completely nonsensical, since they have to be done everywhere...)
Proposal
The proposed schema (containing only the relevant fields for each store) is as follows:
Some corrections apply to this schema, however:
Users
store,publicUsers
should be of the typestring[]
TheIn theHomeSections
store should be renamed toHomeScreen
, andHomeSections
store,sections
should be of the typestring[]
and another propertysectionContent
of typeRecord<number, string[]>
should be added. AnenableHeader
flag should also be part of the store.Explanations
Core stores
The
Servers
,Users
andItems
stores are the central stores of the client. They store "raw" objects from the API in their respective types:ServerInfo
,UserDto
andBaseItemDto
(Note:ServerInfo
is built in the Vue client, but it acts as a core data type here).These stores get referenced from other stores as the main source of data.
Related:
Session
This store is a combination of a few of our current stores:
userViews
,user
and part ofserver
. It's goal is, as the name implies, to represent the current user's session, with everything needed for it (It's sort of a "fit-all" store for things that don't really need their own stores)It currently contains:
currentServer
(string
) - Contains the ID of the currently connected serveraccessToken
(string
) - Contains the "raw" access token for the APIuserViews
(string
) - Contains the ID of the BaseItemDto representing the user's librariesBoth
currentServer
anduserViews
are primarily accessed through getters which consolidate the list of IDs with the contents of the respective stores.HomeSection
In order to be more modular, this store is completely refactored.
It now features a list of strings (
sections
), representing the various section types that make up the user's home screen.Another property,
sectionContent
, contain the index of the section, as well as a list of IDs for the items in that section.Finally, anAnenableHeader
boolean sets the visibility of the HomeHeader component.enableHeader
getter checks if the first index ofsections
is the HomeHeader.ShowSeasons
This store contains the relationships between BaseItems representing a show's seasons and episodes.
showSeasons
contains a dictionary where keys represent the ID of the show and the value is a list of strings containing the IDs of the seasons.seasonEpisodes
contains a dictionary where keys represent the ID of the season and the value is a list of strings containing the IDs of the episodes.Libraries
librariesContent
contains a dictionary where keys represent the ID of the user view and the value is a list of strings containing the IDs of the contents.librariesPrefs
contains a dictionary where the keys represent the ID of the user view and the value is a DisplayPreferenceDto object containing that library's display preferences.Note: To properly support folder-based libraries, a
parentChild
(or similar) property might be needed, in order to be able to build a proper tree of items to navigate.PlaybackManager
queueItems
would be changed to contain a list of strings representing the IDs of items in the queue.To simplify the way shuffling and the queue in general is handled, a
queueOrder
property should be added, which by default would contain the indexes of items inqueueItems
.By default, for a normal queue, this property would look like this:
[0, 1, 2, 3, 4, ..., n]
, each entry pointing to an index inqueueItems
.When shuffling,
queueItems
would remain untouched. OnlyqueueOrder
would be shuffled. Unshuffling the queue would then only reset the array to be a sequence of numbers.When adding an item to a shuffled queue, the store would proceed as such:
queueItems
queueOrder
When adding an item to an unshuffled queue, the store would proceed as normal (Adding the item where needed, then re-generating the order).
The text was updated successfully, but these errors were encountered: