theia-ide / sprotty

A next-gen web-based graphics framework
Apache License 2.0
138 stars 23 forks source link

Make localStorage optional #122

Closed spoenemann closed 7 years ago

spoenemann commented 7 years ago

The multicore example does not work with the new Brave browser:

smodel-storage.ts:39 Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
    at SModelStorage.isLocalStorageAvailable (http://0.0.0.0:8080/bundle.js:3763:23)
    at SModelStorage.store (http://0.0.0.0:8080/bundle.js:3748:18)
    at WebSocketDiagramServer.DiagramServer.storeNewModel (http://0.0.0.0:8080/bundle.js:7290:30)
    at ActionDispatcher.dispatch (http://0.0.0.0:8080/bundle.js:5729:23)
    at WebSocketDiagramServer.DiagramServer.messageReceived (http://0.0.0.0:8080/bundle.js:7276:39)
    at WebSocket.<anonymous> (http://0.0.0.0:8080/bundle.js:13452:19)
JanKoehnlein commented 7 years ago

Fixed. If you have a better idea than

protected isLocalStorageAvailable(): boolean {
        try {
            return typeof localStorage === 'object' && localStorage !== null
        } catch (e) {
            return false
        }
    }

let me know