try/catch localStorage access (#1932)
This commit is contained in:
parent
494b7d08c5
commit
c1488fa353
@ -417,9 +417,14 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||||||
if (!roomMatch) {
|
if (!roomMatch) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const collabForceLoadFlag = localStorage.getItem(
|
|
||||||
LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG,
|
let collabForceLoadFlag;
|
||||||
);
|
try {
|
||||||
|
collabForceLoadFlag = localStorage?.getItem(
|
||||||
|
LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG,
|
||||||
|
);
|
||||||
|
} catch {}
|
||||||
|
|
||||||
if (collabForceLoadFlag) {
|
if (collabForceLoadFlag) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@ -619,13 +624,15 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||||||
|
|
||||||
private beforeUnload = withBatchedUpdates((event: BeforeUnloadEvent) => {
|
private beforeUnload = withBatchedUpdates((event: BeforeUnloadEvent) => {
|
||||||
if (this.state.isCollaborating && this.portal.roomID) {
|
if (this.state.isCollaborating && this.portal.roomID) {
|
||||||
localStorage.setItem(
|
try {
|
||||||
LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG,
|
localStorage?.setItem(
|
||||||
JSON.stringify({
|
LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG,
|
||||||
timestamp: Date.now(),
|
JSON.stringify({
|
||||||
room: this.portal.roomID,
|
timestamp: Date.now(),
|
||||||
}),
|
room: this.portal.roomID,
|
||||||
);
|
}),
|
||||||
|
);
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.state.isCollaborating &&
|
this.state.isCollaborating &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user