use the right index while adding clips to an edit

This commit is contained in:
j 2014-02-03 12:50:17 +00:00
parent e02f1eb6df
commit 1702b37877
2 changed files with 17 additions and 2 deletions

View file

@ -232,7 +232,12 @@ pandora.ui.editPanel = function() {
var clips = pandora.clipboard.paste();
pandora.doHistory('paste', clips, ui.edit, function(result) {
Ox.Request.clearCache('getEdit');
updateClips(edit.clips.concat(result.data.clips));
updateClips(edit.clips.map(function(clip) {
if (clip.index >= result.data.clips[0].index) {
clip.index += result.data.clips.length
}
return clip;
}).concat(result.data.clips));
});
},
playing: function(data) {

View file

@ -413,7 +413,17 @@ pandora.createLinks = function($element) {
}
});
} else {
pandora.api.addClips({clips: getClipData(items), edit: target, index: 0}, function(result) {
pandora.api.addClips({
clips: getClipData(items),
edit: target,
index: pandora.user.ui.edits[pandora.user.ui.edit].selection.length
? Ox.getObjectById(
pandora.$ui.editPanel.options('clips'),
pandora.user.ui.edits[pandora.user.ui.edit].selection[0]
).index
: void 0
}, function(result) {
// adding clips creates new ids, so mutate items in history
items.splice.apply(items, [0, items.length].concat(getClipItems(result.data.clips)));
callback(result, items);