                         log "ERROR: #{error.error} (Status: #{error.status})"
                         history.pushState(null, null, "#BLANK")
             else
-                loadDropboxPath(path)
+                promise = loadDropboxPath(path)
+                promise.then (data) ->
+                    doc.setValue(data.text)
+                    dropboxView = new DropboxView(syncMaster, path)
+                    dropboxView.data = data.text
+                    dropboxView.rev = data.rev
+
+                    spy.dropboxView = dropboxView
+                promise.catch (error) ->
+                    slog 'ERROR'
 
 
 

        onDataUpdated: (source, version, data) =>
            if super(source, version, data)
                @outline.reloadSerialization(@data)

    panel = new DockPanel()
    panel.id = 'main'

            window.location = makeAuthenticationUrl('CHOOSE')

    loadDropboxPath = (path) ->
        promise = new Promise (resolve, reject) ->

            options =
                path: path
            dropboxApiReady = not dropboxAccessDenied
            if dropboxApiReady
                p1 = dbx.filesGetMetadata options
                p1.then (metaData) =>
                    # source: http://stackoverflow.com/questions/190852
                    fileExtension = (fname) ->
                        fname.substr((~-fname.lastIndexOf(".") >>> 0) + 1)

                    if metaData['.tag'] is 'folder'
                        log "ERROR: #{path} is a folder. (Not supported)"
                        history.pushState(null, null, "#BLANK")
                        dropboxApiReady = false

                    extension = fileExtension(metaData.name).toLowerCase()
                    if extension not in textExtensions
                        log "ERROR: File #{path} is not a text file (based on file extension)."
                        history.pushState(null, null, "#BLANK")
                        dropboxApiReady = false
                        spy.name = metaData.name

                    if dropboxApiReady
                        p2 = dbx.filesDownload options

                        p2.then (fileData) =>
                            reader = new FileReader()

                            reader.addEventListener 'loadend', () ->
                                # reader.result contains the contents of blob as a typed array
                                stringResult = new TextDecoder('utf8').decode(reader.result)

                                data =
                                    text: stringResult
                                    rev: metaData.rev

                                resolve(data)

                            reader.readAsArrayBuffer(fileData.fileBlob)

                p1.catch (error) =>
                    slog error
                    spy.error = error
                    switch error.status
                        when 409  # Path not found
                            log "ERROR: File #{path} not found on Dropbox."
                            history.pushState(null, null, "#BLANK")
                        else
                            ensureDropboxToken(path).then () ->
                                log "ERROR: #{error.error} (Status: #{error.status})"
                                history.pushState(null, null, "#BLANK")

    if path is '/' or path is ''
        path = 'WELCOME'
