all files / model/ FileProxy.js

9.09% Statements 1/11
100% Branches 0/0
0% Functions 0/6
9.09% Lines 1/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                                             
/*
  A FileProxy represents a proxy from a FileNode to the real resource.
  As real resources may need to be fetched, the FileProxy typically has
  multiple internal states.
*/
class FileProxy {
  constructor(fileNode, context) {
    this.fileNode = fileNode
    this.context = context
    fileNode.setProxy(this)
  }
 
  get id() {
    return this.fileNode.id
  }
 
  /*
    Fires a property update on the file node
  */
  triggerUpdate() {
    let fileId = this.fileNode.id
    this.context.editorSession.transaction((tx) => {
      tx.set([fileId, '__changed__'], '')
    }, { history: false })
  }
 
  getUrl() {
    return ''
  }
 
  sync() {
    return Promise.reject(new Error('sync method not implemented'))
  }
}
 
FileProxy.match = function(fileNode, context) { // eslint-disable-line
  return false
}
 
export default FileProxy