Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant Model ID Results in Duplicate Local Storage Values #152

Open
ohnnyj opened this issue Sep 26, 2014 · 0 comments
Open

Constant Model ID Results in Duplicate Local Storage Values #152

ohnnyj opened this issue Sep 26, 2014 · 0 comments
Labels

Comments

@ohnnyj
Copy link

ohnnyj commented Sep 26, 2014

I've read in other comments to another issue that this library wasn't necessary intended to work with single models which might be why I am seeing this issue.

I have a model with a static / constant id, 'settings'.

Each time I make a change to the attributes of my settings object I do a model.save. Each save appends a new 'settings' value to the current local storage value.

example:

first save creates two local storage entries:

settings -> settings
settings-settings -> json object

next save:

settings -> settings,settings
settings-settings -> json object

next save:

settings -> settings,settings,settings
settings-settings -> json object

etc.

I've changed the save method to look at the value before setting which seemed to work but not sure if this will break something else:

  save: function() {
    var records = this.records.join(',');
    var value = this.localStorage().getItem(this.name);
    if(!value || records.indexOf(value) === -1) {
      this.localStorage().setItem(this.name, records);
    }
  },
@scott-w scott-w added the bug label Mar 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants