Merge pull request #550 from filecoin-project/@akuokojnr/upload-to-slate

fix: broken file upload to slate on slate page
This commit is contained in:
CAKE 2021-02-19 00:23:13 -08:00 committed by GitHub
commit 8c67e06706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import * as Strings from "~/common/strings";
// NOTE(jim):
// Recursion for nested entities (any number).
export const getCurrentById = (targetId) => {
export const getCurrent = ({ id, data }) => {
let target = null;
let activeIds = {};
@ -11,6 +11,10 @@ export const getCurrentById = (targetId) => {
if (state[i].id === id) {
target = state[i];
activeIds[state[i].id] = true;
if (target.id === "NAV_SLATE") {
target.slateId = data && data.id;
}
}
// if (!target && state[i].children) {
@ -24,7 +28,7 @@ export const getCurrentById = (targetId) => {
}
};
findById(navigation, targetId);
findById(navigation, id);
return { target, activeIds };
};

View File

@ -167,7 +167,7 @@ export default class ApplicationPage extends React.Component {
if (!page || !page.id) {
page = { id: "NAV_DATA", scrollTop: 0, data: null };
}
const current = NavigationData.getCurrentById(page.id);
const current = NavigationData.getCurrent(page);
let slate = null;
if (
@ -303,7 +303,7 @@ export default class ApplicationPage extends React.Component {
if (!page || !page.id) {
page = { id: "NAV_DATA", scrollTop: 0, data: null };
}
const current = NavigationData.getCurrentById(page.id);
const current = NavigationData.getCurrent(page);
let slate = null;
if (
@ -372,6 +372,7 @@ export default class ApplicationPage extends React.Component {
return res.status === "fulfilled" && res.value && !res.value.error;
})
.map((res) => res.value);
if (slate && slate.id) {
await FileUtilities.uploadToSlate({ responses: succeeded, slate });
}
@ -644,7 +645,7 @@ export default class ApplicationPage extends React.Component {
if (!page || !page.id) {
page = { id: "NAV_DATA", scrollTop: 0, data: null };
}
const current = NavigationData.getCurrentById(page.id);
const current = NavigationData.getCurrent(page);
// NOTE(jim): Only happens during a bad query parameter.
if (!current.target) {