From 0705efa7bc97b4d43c5ea40bee763fec8978b7ba Mon Sep 17 00:00:00 2001 From: Israel Adura Date: Sun, 5 Jan 2020 20:25:29 +0000 Subject: [PATCH] Set default project name --- src/components/EditableText.tsx | 4 ++++ src/index.tsx | 10 +++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/EditableText.tsx b/src/components/EditableText.tsx index e9ffecd1d..cf32d6def 100644 --- a/src/components/EditableText.tsx +++ b/src/components/EditableText.tsx @@ -20,6 +20,10 @@ export default class EditableText extends Component { }; } + componentWillReceiveProps(props: Props) { + this.setState({ value: props.value }); + } + private handleEdit(e: React.ChangeEvent) { this.setState({ value: e.target.value }); } diff --git a/src/index.tsx b/src/index.tsx index d1299765e..2a297f4ae 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -24,6 +24,8 @@ const LOCAL_STORAGE_KEY_STATE = "excalidraw-state"; const elements = Array.of(); +const DEFAULT_PROJECT_NAME = `excalidraw-${getDateTime()}`; + let skipHistory = false; const stateHistory: string[] = []; function generateHistoryCurrentEntry() { @@ -991,12 +993,6 @@ class App extends React.Component<{}, AppState> { if (savedState) { this.setState(savedState); } - - // set default name - if (!(savedState && savedState.name)) { - const name = `excalidraw-${getDateTime()}`; - this.setState({ name }); - } } public componentWillUnmount() { @@ -1015,7 +1011,7 @@ class App extends React.Component<{}, AppState> { viewBackgroundColor: "#ffffff", scrollX: 0, scrollY: 0, - name: "" + name: DEFAULT_PROJECT_NAME }; private onResize = () => {