mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Make stateStore.isConnected a method
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
module.exports =
|
||||
class StateStore {
|
||||
constructor (databaseName, version) {
|
||||
this.connected = false
|
||||
this.dbPromise = new Promise((resolve) => {
|
||||
let dbOpenRequest = indexedDB.open(databaseName, version)
|
||||
dbOpenRequest.onupgradeneeded = (event) => {
|
||||
@@ -10,17 +11,21 @@ class StateStore {
|
||||
db.createObjectStore('states')
|
||||
}
|
||||
dbOpenRequest.onsuccess = () => {
|
||||
this.isConnected = true
|
||||
this.connected = true
|
||||
resolve(dbOpenRequest.result)
|
||||
}
|
||||
dbOpenRequest.onerror = (error) => {
|
||||
console.error('Could not connect to indexedDB', error)
|
||||
this.isConnected = false
|
||||
this.connected = false
|
||||
resolve(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
isConnected () {
|
||||
return this.connected
|
||||
}
|
||||
|
||||
connect () {
|
||||
return this.dbPromise.then((db) => !!db)
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ class TextEditor extends Model
|
||||
# Determine whether the user should be prompted to save before closing
|
||||
# this editor.
|
||||
shouldPromptToSave: ({windowCloseRequested, projectHasPaths}={}) ->
|
||||
if windowCloseRequested and projectHasPaths and atom.stateStore.isConnected
|
||||
if windowCloseRequested and projectHasPaths and atom.stateStore.isConnected()
|
||||
false
|
||||
else
|
||||
@isModified() and not @buffer.hasMultipleEditors()
|
||||
|
||||
Reference in New Issue
Block a user