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

Implement Sheet State - Phase 1 #17

Closed
5 tasks done
kgar opened this issue Nov 1, 2023 · 2 comments
Closed
5 tasks done

Implement Sheet State - Phase 1 #17

kgar opened this issue Nov 1, 2023 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@kgar
Copy link
Owner

kgar commented Nov 1, 2023

Implement sheet state tracking.

Note

Phase 1: Track it on the sheet and don't worry about persisting between full browser tab reloads.

Use the application subclass / base class features to track:

  • current tab: will need to handle this myself since I'm not using the application's tab controller; notify of current tab change when a tab is selected, calling to a contextual function
  • scroll top: will attempt to let the application handle this by tagging my scrollable areas and setting options; backup plan is to handle it myself
  • expanded items: will attempt to let the application handle this; backup plans are either to find a hybrid solution or to handle it myself. Most likely, a hybrid solution will be needed where the toggle function in svelte calls a provided contextual function to declare that an item ID was expanded or collapsed, then update the _expanded set accordingly.
  • search filter texts: move away from using an actor flag to just using a sheet class prop so everyone can search independently; handle this myself during getData() and emit search filter changes from svelte to the sheet through a contextual function.
  • expanded favorites: with the base expandedData approach, expanded items are tracked by item ID, which means when I expand a favorited item on its main tab and then close/reopen the sheet, the same item will be expanded on its own tab and in favorites. This will definitely lead to some confusion. Devise an approach that allows for differentiating items by an additional dimension, such as the tab ID.

If something cannot be captured while it is happening, I will attempt to capture it on component destruction. Components are destroyed before a full re-render and when the application is closed, so this particular time is the last moment where we can peer into the state of the sheet before it's gone.

@kgar kgar added bug Something isn't working enhancement New feature or request labels Nov 1, 2023
@kgar kgar self-assigned this Nov 6, 2023
@kgar kgar changed the title Implement Sheet State Implement Sheet State - Phase 1 Nov 6, 2023
@kgar
Copy link
Owner Author

kgar commented Nov 7, 2023

Demo of using the search filter as two different users simultaneously, without stepping on one another:

demo-searching-separately

kgar added a commit that referenced this issue Nov 8, 2023
…ilter Texts (#33)

* Began implementing current tab caching support.

* Attempting scrollY tracking with the built-in stuff.

* Finished adding support for scrollY tracking in the style of default 5e sheets.

Corrected sheet render return types.

Adjusted some of the layout to allow for more streamlined tracking of scrollY.

Replaced some overreaching global styles with more component-/module-bound alternatives.

* Replaced ListContainer component with a simple div with layout class "scroll-container". It's more transparent and removes some additional SCSS ceremony to fold in more local styles with the target scroll container.

* Added useTransition option to ItemSummary to allow for rehydrating cached data without unintended delay time in rendering. Without this, scrollY would have trouble restoring because of a different scroll top due to unexpanded items waiting their configured delay.

Implemented expanded item caching between renders and ensured it respects srollY cache restore as well.

* Updated ItemFilterSearch to leverage a `searchFilters` map from context and to provide a `filterId` for caching to the map.

Updated each of the sheet types to support searchFilter caching.

* Refactored cacheable interfaces to exclude implementation details like how the cache data is held.

Removed search filter cacheability from Vehicles. Will add back if they ever get search.

Refactored so that mutations to cache data require a function call. This, and the interface changes, are to prepare for side-effecting persistence mechanisms 👀

* Fixed disabled input issue in Favorites for ItemUses.

* Converted personality info toggle to a button.

* Added location awareness to components via the Context API. Location awareness is opt-in and builds a path string representing where in the sheet we currently are. It is not tied to all components; it is conceptually tied to "locations," such as "Within the Attributes Tab."

Leveraged location awareness to support independent cached item expansion restoration.

Took over item expansion to do it custom, because location-aware cache restoring of expanded items is otherwise not feasible.

Implemented location-aware expanded item caching and cache restore for player characters.

* Implemented location-aware expanded item caching to NPCs and Vehicles.

* Converted search filter caching to use location awareness and to remove the required filterId.

* Extracted location declaration to a utility function.

* Removed item window auto-resize. If the community really wants it, it can be added back later via a fresh approach.

Adjusted some types.

* Renamed item caching props for conciseness.
Renamed types for clarity.
Cleaned up unused context data.

* Renamed interfaces for clarity.

* Move interface implementation to bottom of sheet with comment header.
@kgar
Copy link
Owner Author

kgar commented Nov 8, 2023

All done 👏

@kgar kgar closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant