Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Clutch
Commits
718c2f77
Commit
718c2f77
authored
3 years ago
by
Josh Slaughter
Browse files
Options
Download
Email Patches
Plain Diff
some work
parent
8367183a
state-hydration
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/packages/core/src/AppLayout/shortLinker.tsx
+3
-4
frontend/packages/core/src/AppLayout/shortLinker.tsx
frontend/packages/core/src/AppProvider/index.tsx
+1
-2
frontend/packages/core/src/AppProvider/index.tsx
frontend/packages/core/src/Contexts/storage-context.tsx
+2
-2
frontend/packages/core/src/Contexts/storage-context.tsx
with
6 additions
and
8 deletions
+6
-8
frontend/packages/core/src/AppLayout/shortLinker.tsx
+
3
-
4
View file @
718c2f77
...
...
@@ -59,8 +59,7 @@ const StyledLinkIcon = styled(IconButton)<{ $open: boolean }>(
const
ShortLinker
=
()
=>
{
const
{
workflows
}
=
useAppContext
();
const
{
tempStore
,
functions
:
{
clearData
},
functions
:
{
clearData
,
tempData
},
}
=
useStorageContext
();
const
anchorRef
=
React
.
useRef
(
null
);
const
location
=
useLocation
();
...
...
@@ -104,13 +103,13 @@ const ShortLinker = () => {
};
// Will rotate our object into an array of type IShareableState to send in the API request
const
rotateStore
=
():
IClutch
.
shortlink
.
v1
.
IShareableState
[]
=>
const
rotateStore
=
(
tempStore
):
IClutch
.
shortlink
.
v1
.
IShareableState
[]
=>
Object
.
keys
(
tempStore
).
map
(
key
=>
({
key
,
state
:
tempStore
[
key
]
}));
const
generateShortLink
=
()
=>
{
const
requestData
:
IClutch
.
shortlink
.
v1
.
ICreateRequest
=
{
path
:
`
${
location
.
pathname
}${
location
.
search
}
`
,
state
:
rotateStore
(),
state
:
rotateStore
(
tempData
()
),
};
client
...
...
This diff is collapsed.
Click to expand it.
frontend/packages/core/src/AppProvider/index.tsx
+
1
-
2
View file @
718c2f77
...
...
@@ -131,8 +131,6 @@ const ClutchApp: React.FC<ClutchAppProps> = ({
};
const
storageProviderProps
:
StorageContextProps
=
{
store
:
storageState
.
store
,
tempStore
:
storageState
.
tempStore
,
shortLinked
:
storageState
.
shortLinked
,
functions
:
{
storeData
:
(
componentName
:
string
,
key
:
string
,
data
:
any
,
local
?:
boolean
)
=>
...
...
@@ -140,6 +138,7 @@ const ClutchApp: React.FC<ClutchAppProps> = ({
removeData
:
(
componentName
:
string
,
key
:
string
,
local
?:
boolean
)
=>
dispatch
({
type
:
"
REMOVE_DATA
"
,
payload
:
{
componentName
,
key
,
local
}
}),
clearData
:
()
=>
dispatch
({
type
:
"
EMPTY_DATA
"
}),
tempData
:
()
=>
storageState
.
tempStore
,
retrieveData
,
},
};
...
...
This diff is collapsed.
Click to expand it.
frontend/packages/core/src/Contexts/storage-context.tsx
+
2
-
2
View file @
718c2f77
...
...
@@ -21,16 +21,16 @@ type StoreDataFn = (componentName: string, key: string, data: any, local?: boole
type
RemoveDataFn
=
(
componentName
:
string
,
key
:
string
,
local
?:
boolean
)
=>
void
;
type
RetrieveDataFn
=
(
componentName
:
string
,
key
:
string
,
defaultData
:
any
)
=>
any
;
type
ClearDataFn
=
()
=>
void
;
type
TempDataFn
=
()
=>
HydratedData
;
export
interface
StorageContextProps
{
shortLinked
:
boolean
;
store
?:
HydratedData
;
tempStore
?:
HydratedData
;
functions
:
{
storeData
:
StoreDataFn
;
removeData
:
RemoveDataFn
;
retrieveData
:
RetrieveDataFn
;
clearData
:
ClearDataFn
;
tempData
:
TempDataFn
;
};
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help