@stoker-platform/web-app 0.5.125 → 0.5.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.127
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: fix Dashboard background cutoff issue
8
+
9
+ ## 0.5.126
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: fix preload cache spinner issue
14
+
3
15
  ## 0.5.125
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.125",
3
+ "version": "0.5.127",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -710,15 +710,15 @@ function Collection({
710
710
  const cacheLoading = useCallback(() => {
711
711
  if (!cacheLoadingStarted.current) {
712
712
  isCacheLoading.current = true
713
- setIsRouteLoading("+", location.pathname)
713
+ setIsRouteLoading("+", location.pathname, true)
714
714
  cacheLoadingStarted.current = true
715
715
  }
716
- }, [location, isCacheLoading.current, cacheLoadingStarted.current])
716
+ }, [location.pathname, setIsRouteLoading])
717
717
  const cacheLoaded = useCallback(() => {
718
718
  isCacheLoading.current = false
719
- setIsRouteLoading("-", location.pathname)
719
+ setIsRouteLoading("-", location.pathname, true)
720
720
  setCacheLoadingCompleted(true)
721
- }, [location, isCacheLoading.current])
721
+ }, [location.pathname, setIsRouteLoading])
722
722
 
723
723
  const hasRunSingleton = useRef(false)
724
724
 
@@ -727,7 +727,6 @@ function Collection({
727
727
  const isPreloading = getLoadingState()[labels.collection]
728
728
  if (!isPreloading || isPreloading === "Loading") {
729
729
  cacheLoading()
730
- cacheLoadingStarted.current = true
731
730
  }
732
731
  document.addEventListener(`stoker:loading:${labels.collection}`, cacheLoading)
733
732
  // Prevent UI flicker
package/src/Dashboard.tsx CHANGED
@@ -62,7 +62,7 @@ export const Dashboard = () => {
62
62
  <title>Dashboard</title>
63
63
  <meta name="description" content={`Dashboard for ${appName}`} />
64
64
  </Helmet>
65
- <div className="h-[100vh] xl:overflow-y-auto">
65
+ <div className="xl:h-[100vh] xl:overflow-y-auto">
66
66
  <div className="flex flex-col lg:pt-4">
67
67
  <header className="sticky top-0 z-30 flex h-14 items-center gap-4 border-b bg-background px-4 py-1 lg:static lg:h-auto lg:border-0 lg:bg-transparent lg:px-6 lg:py-0 print:border-none select-none">
68
68
  <Card className="flex items-center gap-2 h-12 sm:min-w-[300px] p-5">
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useMemo, useState } from "react"
1
+ import { createContext, useCallback, useContext, useRef, useState } from "react"
2
2
  import debounce from "lodash/debounce.js"
3
3
  import { serverReadOnly } from "@/utils/serverReadOnly"
4
4
  import { useLocation } from "react-router"
@@ -91,25 +91,33 @@ export const RouteLoadingProvider: React.FC<RouteLoadingProviderProps> = ({ chil
91
91
  const [isRouteLoading, setLoading] = useState<Set<string>>(new Set<string>())
92
92
  const [isRouteLoadingImmediate, setLoadingImmediate] = useState<Set<string>>(new Set<string>())
93
93
 
94
- const setIsRouteLoadingDebounced = useMemo(() => {
95
- const debouncedSet = debounce((operation: "+" | "-", route: string) => {
96
- if (operation === "+") {
97
- setLoading((prev) => {
98
- const newSet = new Set(prev)
99
- newSet.add(route)
100
- return newSet
101
- })
102
- } else {
103
- setLoading((prev) => {
104
- const newSet = new Set(prev)
105
- newSet.delete(route)
106
- return newSet
107
- })
108
- }
109
- }, 500)
94
+ const debouncedByRouteRef = useRef(new Map<string, ReturnType<typeof debounce>>())
110
95
 
111
- return (operation: "+" | "-", route: string) => {
112
- debouncedSet(operation, route)
96
+ const setIsRouteLoadingDebounced = useCallback((operation: "+" | "-", route: string) => {
97
+ let debounced = debouncedByRouteRef.current.get(route)
98
+ if (!debounced) {
99
+ debounced = debounce((op: "+" | "-") => {
100
+ if (op === "+") {
101
+ setLoading((prev) => {
102
+ const newSet = new Set(prev)
103
+ newSet.add(route)
104
+ return newSet
105
+ })
106
+ } else {
107
+ setLoading((prev) => {
108
+ const newSet = new Set(prev)
109
+ newSet.delete(route)
110
+ return newSet
111
+ })
112
+ }
113
+ }, 500)
114
+ debouncedByRouteRef.current.set(route, debounced)
115
+ }
116
+ debounced(operation)
117
+ if (operation === "-") {
118
+ debounced.flush()
119
+ debounced.cancel()
120
+ debouncedByRouteRef.current.delete(route)
113
121
  }
114
122
  }, [])
115
123
 
@@ -153,6 +161,8 @@ export const RouteLoadingProvider: React.FC<RouteLoadingProviderProps> = ({ chil
153
161
  // eslint-disable-next-line security/detect-object-injection
154
162
  const collection = schema.collections[collectionName]
155
163
  if ((collection && serverReadOnly(collection)) || immediate) {
164
+ debouncedByRouteRef.current.get(route)?.cancel()
165
+ debouncedByRouteRef.current.delete(route)
156
166
  setIsRouteLoadingImmediate(operation, route)
157
167
  } else {
158
168
  setIsRouteLoadingDebounced(operation, route)