• Sean Hammond's avatar
    Fix a bug when changing the privacy of an annotation · bd337f28
    Sean Hammond authored
    A bug had crept in where if you changed the privacy of an annotation
    that you were creating or editing (by changing the selection in the
    _Post_ dropdown) then the privacy would not change and your text and tags edits
    would be deleted.
    
    This was happening because when you change the selection in the Post
    dropdown then onSetPrivacy() makes a change to the domain model which
    triggers onDomainModelChange() which copies the domainModel over
    vm.annotation, overwriting your changes.
    
    To fix this get rid of onDomainModelChange(). These sorts of functions
    (ones that are triggered by events or changes) create confusion by
    making it difficult to predict or trace the flow of execution, and I
    can't see why onDomainModelChange() needs to exist.
    
    This does deliberately remove one feature:
    
    If you had saved edits for an annotation in the drafts service (for
    example if you edited an annotation, made some changes, then changed the
    focus to a different group without saving the annotation) and _then_
    someone using a different instance of the client (e.g. yourself on a
    different device, I guess) saved a change to that same annotation to the
    server, then this change would be communicated from the server to the
    first client (via the WebSocket I guess) and the first client would
    *delete your saved edits from the drafts service*.
    
    This behaviour was deliberate but I'm not sure why it was considered a
    good idea, and removing it simplifies things.
    bd337f28
Name
Last commit
Last update
h Loading commit data...
scripts Loading commit data...
.hound.yml Loading commit data...
.jscsrc Loading commit data...
.jshintignore Loading commit data...
.jshintrc Loading commit data...
package.json Loading commit data...