Commit 718c2f77 authored by Josh Slaughter's avatar Josh Slaughter
Browse files

some work

No related merge requests found
Showing with 6 additions and 8 deletions
+6 -8
......@@ -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
......
......@@ -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,
},
};
......
......@@ -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;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment