FIX: sync changes of the localstorage in the left drawer
This is a bit of a HACK. going a bit "against" React philosophy.
This commit is contained in:
@@ -30,6 +30,7 @@ function App() {
|
|||||||
const [showWelcomeDialog, setShowWelcomeDialog] = useState(false);
|
const [showWelcomeDialog, setShowWelcomeDialog] = useState(false);
|
||||||
const [isTemplatesDialogOpen, setTemplatesDialogOpen] = useState(false);
|
const [isTemplatesDialogOpen, setTemplatesDialogOpen] = useState(false);
|
||||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
||||||
|
const [localStorageId, setLocalStorageId] = useState<number>(1);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function start() {
|
async function start() {
|
||||||
@@ -129,6 +130,7 @@ function App() {
|
|||||||
newModel={handleNewModel}
|
newModel={handleNewModel}
|
||||||
setModel={handleSetModel}
|
setModel={handleSetModel}
|
||||||
onDelete={handleDeleteModelByUuid}
|
onDelete={handleDeleteModelByUuid}
|
||||||
|
localStorageId={localStorageId}
|
||||||
/>
|
/>
|
||||||
<MainContent isDrawerOpen={isDrawerOpen}>
|
<MainContent isDrawerOpen={isDrawerOpen}>
|
||||||
{isDrawerOpen && (
|
{isDrawerOpen && (
|
||||||
@@ -153,6 +155,7 @@ function App() {
|
|||||||
onDelete={handleDeleteModel}
|
onDelete={handleDeleteModel}
|
||||||
isDrawerOpen={isDrawerOpen}
|
isDrawerOpen={isDrawerOpen}
|
||||||
setIsDrawerOpen={setIsDrawerOpen}
|
setIsDrawerOpen={setIsDrawerOpen}
|
||||||
|
setLocalStorageId={setLocalStorageId}
|
||||||
/>
|
/>
|
||||||
<IronCalc model={model} />
|
<IronCalc model={model} />
|
||||||
</MainContent>
|
</MainContent>
|
||||||
@@ -240,7 +243,7 @@ const MobileOverlay = styled("div")`
|
|||||||
background-color: rgba(255, 255, 255, 0.8);
|
background-color: rgba(255, 255, 255, 0.8);
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
@media (min-width: 441px) {
|
@media (min-width: 441px) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export function FileBar(properties: {
|
|||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
isDrawerOpen: boolean;
|
isDrawerOpen: boolean;
|
||||||
setIsDrawerOpen: (open: boolean) => void;
|
setIsDrawerOpen: (open: boolean) => void;
|
||||||
|
setLocalStorageId: (updater: (id: number) => number) => void;
|
||||||
}) {
|
}) {
|
||||||
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
||||||
const spacerRef = useRef<HTMLDivElement>(null);
|
const spacerRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -67,7 +68,6 @@ export function FileBar(properties: {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DrawerButton
|
<DrawerButton
|
||||||
// $isDrawerOpen={properties.isDrawerOpen}
|
|
||||||
onClick={() => properties.setIsDrawerOpen(!properties.isDrawerOpen)}
|
onClick={() => properties.setIsDrawerOpen(!properties.isDrawerOpen)}
|
||||||
disableRipple
|
disableRipple
|
||||||
>
|
>
|
||||||
@@ -96,6 +96,7 @@ export function FileBar(properties: {
|
|||||||
onNameChange={(name) => {
|
onNameChange={(name) => {
|
||||||
properties.model.setName(name);
|
properties.model.setName(name);
|
||||||
updateNameSelectedWorkbook(properties.model, name);
|
updateNameSelectedWorkbook(properties.model, name);
|
||||||
|
properties.setLocalStorageId((id) => id + 1);
|
||||||
}}
|
}}
|
||||||
maxWidth={maxTitleWidth}
|
maxWidth={maxTitleWidth}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ interface LeftDrawerProps {
|
|||||||
newModel: () => void;
|
newModel: () => void;
|
||||||
setModel: (key: string) => void;
|
setModel: (key: string) => void;
|
||||||
onDelete: (uuid: string) => void;
|
onDelete: (uuid: string) => void;
|
||||||
|
localStorageId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function LeftDrawer({
|
function LeftDrawer({
|
||||||
|
|||||||
Reference in New Issue
Block a user