adobe-photoshop / spaces-design

Adobe Photoshop Design Space
http://adobe-photoshop.github.io/
Other
851 stars 74 forks source link

Init document history on first-time selectDocument #3695

Closed mcilroyc closed 8 years ago

mcilroyc commented 8 years ago

This fixes the more annoying portion of the issue reported in #3694. When opening multiple documents at the same time with the Open... menu, the opened-but-inactive documents can not have their history state initialized (PS limitation). When the document is later selected, various actions will cause a warning that indicates history was trying to be amended, but the history store is not initialized. This seems to be safe to ignore, but the fix in this PR seemed like the right thing to do.

[History] Could not amend history, document history not found

In the case of large documents this would happen immediately, but in smaller documents it can still happen after selecting a new layer for the first time (in the newly selected document).

This PR updates the document.selectDocument action to check for the initialization status of the document in the history store, and explicitly queries PS for the information if it is not there.

What this PR does not do. For large documents, there is still a race in selectDocument between the selectPromise and the initializedPromise. Specifically, the transfer to resetLinkedLayers may cause both bounds and guides to be updated, both of which will try to amend history, before it is initialized. These warnings should be safe to ignore. Squashing them seemed more disruptive than necessary, at least before I got a second opinion.

cc: @volfied & @iwehrman since we discussed this general issue a few weeks ago when barkin changed this to a warning instead of an error.

baaygun commented 8 years ago

Looks good to me, passing to @iwehrman to merge.

iwehrman commented 8 years ago

Looks correct to me.