@stoker-platform/web-app 0.5.124 → 0.5.126
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 +12 -0
- package/package.json +1 -1
- package/src/App.css +6 -0
- package/src/Collection.tsx +26 -22
- package/src/Tenant.tsx +3 -3
- package/src/main.tsx +9 -0
- package/src/providers/LoadingProvider.tsx +29 -19
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/App.css
CHANGED
package/src/Collection.tsx
CHANGED
|
@@ -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
|
|
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,
|
|
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
|
|
@@ -1687,20 +1686,23 @@ function Collection({
|
|
|
1687
1686
|
[recordTitle],
|
|
1688
1687
|
)
|
|
1689
1688
|
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1689
|
+
const willHaveRangeRow = useMemo(() => {
|
|
1690
|
+
return (
|
|
1691
|
+
!formList &&
|
|
1692
|
+
!relationList?.loadAll &&
|
|
1693
|
+
tab !== "calendar" &&
|
|
1694
|
+
(hasRangeFilter ||
|
|
1695
|
+
(isPreloadCacheEnabled && !!preloadCache?.range) ||
|
|
1696
|
+
filters.some((filter) => filter.type === "range") ||
|
|
1697
|
+
(Array.isArray(collection.admin?.filters) &&
|
|
1698
|
+
collection.admin.filters.some((filter) => filter.type === "range")))
|
|
1699
|
+
)
|
|
1700
|
+
}, [formList, relationList, tab, hasRangeFilter, isPreloadCacheEnabled, filters, collection])
|
|
1698
1701
|
|
|
1699
1702
|
if (!permissions.collections?.[labels.collection]) return null
|
|
1700
1703
|
|
|
1701
1704
|
return (
|
|
1702
|
-
!collection.singleton &&
|
|
1703
|
-
showCollection && (
|
|
1705
|
+
!collection.singleton && (
|
|
1704
1706
|
<>
|
|
1705
1707
|
<div
|
|
1706
1708
|
ref={mainContentRef}
|
|
@@ -1826,7 +1828,9 @@ function Collection({
|
|
|
1826
1828
|
<Tabs defaultValue="list" onValueChange={onTabChange} value={tab}>
|
|
1827
1829
|
<div
|
|
1828
1830
|
className={cn(
|
|
1829
|
-
"flex flex-col items-center print:hidden select-none",
|
|
1831
|
+
"flex flex-col items-center justify-between print:hidden select-none",
|
|
1832
|
+
willHaveRangeRow ? "h-[116px]" : "h-[72px]",
|
|
1833
|
+
"lg:h-auto",
|
|
1830
1834
|
relationList ? "xl:flex-row" : "lg:flex-row",
|
|
1831
1835
|
)}
|
|
1832
1836
|
>
|
|
@@ -2545,17 +2549,17 @@ function Collection({
|
|
|
2545
2549
|
) : (
|
|
2546
2550
|
!relationList &&
|
|
2547
2551
|
(tab === "list" ? (
|
|
2548
|
-
<div className="
|
|
2549
|
-
<Card className="min-h-
|
|
2552
|
+
<div className="py-2">
|
|
2553
|
+
<Card className="min-h-screen lg:min-h-full lg:h-[calc(100vh-250px)]"></Card>
|
|
2550
2554
|
</div>
|
|
2551
2555
|
) : tab === "map" ? (
|
|
2552
|
-
<div className="
|
|
2553
|
-
<Card className="min-h-
|
|
2556
|
+
<div className="py-2">
|
|
2557
|
+
<Card className="min-h-screen lg:min-h-full lg:h-[calc(100vh-204px)]"></Card>
|
|
2554
2558
|
</div>
|
|
2555
2559
|
) : (
|
|
2556
2560
|
tab === "calendar" && (
|
|
2557
|
-
<div className="
|
|
2558
|
-
<Card className="min-h-
|
|
2561
|
+
<div className="py-2">
|
|
2562
|
+
<Card className="min-h-screen lg:min-h-full lg:h-[calc(100vh-204px)]"></Card>
|
|
2559
2563
|
</div>
|
|
2560
2564
|
)
|
|
2561
2565
|
))
|
package/src/Tenant.tsx
CHANGED
|
@@ -60,7 +60,7 @@ import { getFunctions, httpsCallable } from "firebase/functions"
|
|
|
60
60
|
import { getApp } from "firebase/app"
|
|
61
61
|
import { useTheme } from "./components/theme-provider"
|
|
62
62
|
|
|
63
|
-
const MOBILE_SHEET_CLOSE_MS =
|
|
63
|
+
const MOBILE_SHEET_CLOSE_MS = 320
|
|
64
64
|
|
|
65
65
|
function Tenant() {
|
|
66
66
|
const [dialogContent, setDialogContent] = useDialog()
|
|
@@ -290,9 +290,9 @@ function Tenant() {
|
|
|
290
290
|
|
|
291
291
|
const navigateFromSidebar = useCallback(
|
|
292
292
|
(path: string) => {
|
|
293
|
-
|
|
293
|
+
setSidebarOpen(false)
|
|
294
294
|
window.setTimeout(() => {
|
|
295
|
-
|
|
295
|
+
runViewTransition(() => navigate(path))
|
|
296
296
|
}, MOBILE_SHEET_CLOSE_MS)
|
|
297
297
|
},
|
|
298
298
|
[navigate],
|
package/src/main.tsx
CHANGED
|
@@ -89,6 +89,15 @@ function Main() {
|
|
|
89
89
|
const [, setDialogContent] = useDialog()
|
|
90
90
|
const { toast } = useToast()
|
|
91
91
|
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const root = document.documentElement
|
|
94
|
+
if (mode === "app" && !maintenance) {
|
|
95
|
+
root.dataset.mode = "app"
|
|
96
|
+
} else {
|
|
97
|
+
delete root.dataset.mode
|
|
98
|
+
}
|
|
99
|
+
}, [mode, maintenance])
|
|
100
|
+
|
|
92
101
|
useEffect(() => {
|
|
93
102
|
if (mode === "maintenance") return
|
|
94
103
|
const getRoutes = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useContext,
|
|
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
|
|
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
|
-
|
|
112
|
-
|
|
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)
|