2 Replies Latest reply on Apr 17, 2014 12:27 AM by Ruben Ruben

    Rho.ORM.haveLocalChanges() always true?

    Ruben Ruben

      Hi,

       

      Sorry for flooding the message board, but it seems i'm hitting all dead ends today:

       

      I'm trying to give the user some feedback about the database sync status by showing a "refresh" button when the database is out of sync (allowing the user to manually trigger a sync). Problem is that it always shows, since haveLocalChanges() seems to be always true, even when called after a database reset.

       

      Under what circumstances will it return false?

       

      Thanks again.

        • Re: Rho.ORM.haveLocalChanges() always true?

          What version of RhoElements are you using? I have looked at our specs for the method haveLocalChanges() and they are all passing without error so I am not sure what it is that you are doing that is making this always return true. It is a possible bug but to be sure, could you please paste in here the code you are using wherein you reference haveLocalChanges()?

            • Re: Rho.ORM.haveLocalChanges() always true?
              Ruben Ruben

              Hi Michael, thanks for you answer:

               

              I'm using the Javascript API, version 4.1. The code itself is pretty simple, i'm using AngularJS as my framework of choice, and what I do, is basically expose Rho.ORM.haveLocalChanges() to my view through the scope:

               

              header.js, HeaderCtrl:

                  ....

                  $scope.isDBChanged = function () {

                      return Rho.ORM.haveLocalChanges();

                  };

                  ....

              header.html partial;

                  <button ng-if="isDBChanged()" ng-click="doSync()" type="button" class="navbar-toggle pull-right" >

                      <i class="glyphicon glyphicon-refresh white"></i>

                  </button>

               

              Also, my data comes is though a factory that queries the ORM API. I build (as suggested in the docs) my own hash with the data I get from it, so I can manage it from within AngularJS. The only thing is that I modify that hash, adding another attribute that doesn't come from the the ORM, but i'd expect that the ORM would not care, since I never push those changes to the ORM models (correct me if i'm wrong).

               

              So, to be sure: the only times that I should get TRUE out of haveLocalChanges() would be when i've called obj.updateAttributes(attrs), obj.destroy(), model.create(val), model.deleteAll()?

               

              Or could there be anything else that I'm doing that sets the local DB status to 'changed'?

               

              Thanks.