refactor publish saga

This commit is contained in:
Travis Eden 2018-09-24 15:50:15 -04:00
parent dadb00576e
commit 2b02f06152

View file

@ -36,20 +36,17 @@ function * publishFile (action) {
}
let publishMetadata, publishFormData, publishChannel;
if (isUpdate) {
publishMetadata = createPublishMetadata(asset.name, {type: asset.claimData.contentType}, metadata, publishInChannel, selectedChannel);
publishMetadata['channelName'] = asset.claimData.channelName;
if (thumbnail) {
// add thumbnail to publish metadata
publishMetadata['thumbnail'] = createThumbnailUrl(thumbnailChannel, thumbnailChannelId, claim, host);
}
// create form data for main publish
publishFormData = createPublishFormData(file, thumbnail, publishMetadata);
// make the publish request
publishChannel = yield call(makePublishRequestChannel, publishFormData, true);
} else {
// create metadata
publishMetadata = createPublishMetadata(claim, file, metadata, publishInChannel, selectedChannel);
publishMetadata = createPublishMetadata(
isUpdate ? asset.name : claim,
isUpdate ? {type: asset.claimData.contentType} : file,
metadata,
publishInChannel,
selectedChannel
);
if (isUpdate) {
publishMetadata['channelName'] = asset.claimData.channelName;
}
if (thumbnail) {
// add thumbnail to publish metadata
publishMetadata['thumbnail'] = createThumbnailUrl(thumbnailChannel, thumbnailChannelId, claim, host);
@ -57,8 +54,7 @@ function * publishFile (action) {
// create form data for main publish
publishFormData = createPublishFormData(file, thumbnail, publishMetadata);
// make the publish request
publishChannel = yield call(makePublishRequestChannel, publishFormData);
}
publishChannel = yield call(makePublishRequestChannel, publishFormData, isUpdate);
while (true) {
const {loadStart, progress, load, success, error: publishError} = yield take(publishChannel);