Set mediaProxy objects as uploaded @ implementation
This commit is contained in:
parent
483fdb2643
commit
9f220181b3
@ -84,12 +84,12 @@ function entryPersisting(collection, entry) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function entryPersisted(persistedEntry, persistedMediaFiles) {
|
function entryPersisted(collection, entry) {
|
||||||
return {
|
return {
|
||||||
type: ENTRY_PERSIST_SUCCESS,
|
type: ENTRY_PERSIST_SUCCESS,
|
||||||
payload: {
|
payload: {
|
||||||
persistedEntry: persistedEntry,
|
collection: collection,
|
||||||
persistedMediaFiles: persistedMediaFiles
|
entry: entry
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -161,8 +161,8 @@ export function persistEntry(collection, entry) {
|
|||||||
|
|
||||||
dispatch(entryPersisting(collection, entry));
|
dispatch(entryPersisting(collection, entry));
|
||||||
backend.persistEntry(collection, entry, MediaProxies.toJS()).then(
|
backend.persistEntry(collection, entry, MediaProxies.toJS()).then(
|
||||||
({ persistedEntry, persistedMediaFiles }) => {
|
() => {
|
||||||
dispatch(entryPersisted(persistedEntry, persistedMediaFiles));
|
dispatch(entryPersisted(collection, entry));
|
||||||
},
|
},
|
||||||
(error) => dispatch(entryPersistFail(collection, entry, error))
|
(error) => dispatch(entryPersistFail(collection, entry, error))
|
||||||
);
|
);
|
||||||
|
@ -79,13 +79,7 @@ class Backend {
|
|||||||
collection.get('label') + ' “' +
|
collection.get('label') + ' “' +
|
||||||
entryDraft.getIn(['entry', 'data', 'title']) + '”';
|
entryDraft.getIn(['entry', 'data', 'title']) + '”';
|
||||||
|
|
||||||
return this.implementation.persistEntry(collection, entryObj, MediaFiles, { commitMessage })
|
return this.implementation.persistEntry(collection, entryObj, MediaFiles, { commitMessage });
|
||||||
.then(
|
|
||||||
(response) => ({
|
|
||||||
persistedEntry: this.entryWithFormat(collection)(response.persistedEntry),
|
|
||||||
persistedMediaFiles:response.persistedMediaFiles
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entryToRaw(collection, entry) {
|
entryToRaw(collection, entry) {
|
||||||
|
@ -52,6 +52,7 @@ export default class TestRepo {
|
|||||||
const folder = entry.path.substring(0, entry.path.lastIndexOf('/'));
|
const folder = entry.path.substring(0, entry.path.lastIndexOf('/'));
|
||||||
const fileName = entry.path.substring(entry.path.lastIndexOf('/') + 1);
|
const fileName = entry.path.substring(entry.path.lastIndexOf('/') + 1);
|
||||||
window.repoFiles[folder][fileName]['content'] = entry.raw;
|
window.repoFiles[folder][fileName]['content'] = entry.raw;
|
||||||
return Promise.resolve({ persistedEntry:entry, persistedMediaFiles:[] });
|
mediaFiles.forEach(media => media.uploaded = true);
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Map } from 'immutable';
|
import { Map } from 'immutable';
|
||||||
import { ADD_MEDIA, REMOVE_MEDIA } from '../actions/media';
|
import { ADD_MEDIA, REMOVE_MEDIA } from '../actions/media';
|
||||||
import { ENTRY_PERSIST_SUCCESS } from '../actions/entries';
|
|
||||||
import MediaProxy from '../valueObjects/MediaProxy';
|
import MediaProxy from '../valueObjects/MediaProxy';
|
||||||
|
|
||||||
const medias = (state = Map(), action) => {
|
const medias = (state = Map(), action) => {
|
||||||
@ -9,11 +8,6 @@ const medias = (state = Map(), action) => {
|
|||||||
return state.set(action.payload.path, action.payload);
|
return state.set(action.payload.path, action.payload);
|
||||||
case REMOVE_MEDIA:
|
case REMOVE_MEDIA:
|
||||||
return state.delete(action.payload);
|
return state.delete(action.payload);
|
||||||
case ENTRY_PERSIST_SUCCESS:
|
|
||||||
return state.map((media, path) => {
|
|
||||||
if (action.payload.persistedMediaFiles.indexOf(path) > -1) media.uploaded = true;
|
|
||||||
return media;
|
|
||||||
});
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user