Nano-SQL: eventData.changedRows returning last obj in history on undo rather than history point

Question: Shouldn’t eventData.changedRows[0] return the new state of any changed rows via the changed history point when undo/redo is triggered?

I have an on("change") function set up that listens for changes to a table. I have an undoing and a redoing variable, the values of which are tied to undo and redo buttons.

Note the 2 console.log’s in my on("change") function. You can see that eventData.changedRows[0] always returns the latest point in history rather than the current history point after undo/redo.

I’m getting around that right now by running a query to retrieve the changed row which does return the current history point so I’m able to get it to work. Just wondered if that was your intention for this.

Below is a screenshot of the console.log’s highlighted.

(NOTE: Just as a FYI, .settings.activeSelectors.options[0] is the field I’m changing in order to test to keep my log’s a little more simplified. In the first history point I assigned “testing one” as the value and in the next assigned “testing one two” )

nSQL("aniblocks").on('change',function(eventData) {

  getHistory();

  switch(eventData.changeType) {
    case 'modified':
      if(eventData.changedRows.length > 0) {

        // eventData.changedRows[0] contains data from the latest history point
        console.log('row: ',eventData.changedRows[0].settings.activeSelectors.options[0]);

        if( undoing || redoing ) {
          db.query('select').where(['id','=', eventData.changedRows[0].id]).exec()
          .then(function(result,db){

            // result contains data from the current history point after an undo/redo
            console.log(result[0].settings.activeSelectors.options[0]);
           
            // doing stuff with it here
            animationsMgr.animateFromDB(result[0]);
            resetDoingVars();
          })
        }
      } else {
        // console.log('nothing changed');
      }
    break;
    case 'deleted':
      console.log('deleted');
    break;
    case 'inserted':
      console.log('inserted');
    break;
  }
});
screen shot 2017-05-10 at 7 06 53 am

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

It works! Thanks so much, Scott. Sorry for the delay replying. Been knee deep in FFMPEG hell.