React router #343
|
@ -1,7 +1,7 @@
|
||||||
I had a misunderstanding of how the I had a misunderstanding of how the `this` context works and when I needed to pass this in to a function manually. I was able to remove it from the app in multiple places where it isn't necessary.
Why do you do Why do you do `const that = this`?
I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same `<AssetDisplay />` it will make these requests again, even if you just made them a second ago
I had a misunderstanding of how the I had a misunderstanding of how the `this` context works and when I needed to pass this in to a function manually. I was able to remove it from the app in multiple places where it isn't necessary.
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
import { fileRequested } from 'actions/show';
|
import { fileRequested } from 'actions/show';
|
||||||
import selectAsset from 'selectors/asset';
|
import { selectAsset } from 'selectors/show';
|
||||||
Why do you do Why do you do `const that = this`?
I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same `<AssetDisplay />` it will make these requests again, even if you just made them a second ago
I had a misunderstanding of how the I had a misunderstanding of how the `this` context works and when I needed to pass this in to a function manually. I was able to remove it from the app in multiple places where it isn't necessary.
Why do you do Why do you do `const that = this`?
I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same `<AssetDisplay />` it will make these requests again, even if you just made them a second ago
I had a misunderstanding of how the I had a misunderstanding of how the `this` context works and when I needed to pass this in to a function manually. I was able to remove it from the app in multiple places where it isn't necessary.
|
|||||||
|
|
||||||
const mapStateToProps = ({ show }) => {
|
const mapStateToProps = ({ show }) => {
|
||||||
// select error and status
|
// select error and status
|
||||||
|
|
||||||
Why do you do Why do you do `const that = this`?
I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same `<AssetDisplay />` it will make these requests again, even if you just made them a second ago
I had a misunderstanding of how the I had a misunderstanding of how the `this` context works and when I needed to pass this in to a function manually. I was able to remove it from the app in multiple places where it isn't necessary.
Why do you do Why do you do `const that = this`?
I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same `<AssetDisplay />` it will make these requests again, even if you just made them a second ago
I had a misunderstanding of how the I had a misunderstanding of how the `this` context works and when I needed to pass this in to a function manually. I was able to remove it from the app in multiple places where it isn't necessary.
|
|
@ -1,6 +1,6 @@
|
||||||
This should be a This should be a `button` if it isn't linking anywhere.
This should be a This should be a `button` if it isn't linking anywhere.
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
import selectAsset from 'selectors/asset';
|
import { selectAsset } from 'selectors/show';
|
||||||
This should be a This should be a `button` if it isn't linking anywhere.
This should be a This should be a `button` if it isn't linking anywhere.
|
|||||||
|
|
||||||
const mapStateToProps = ({ show }) => {
|
const mapStateToProps = ({ show }) => {
|
||||||
// select asset
|
// select asset
|
||||||
|
|
||||||
This should be a This should be a `button` if it isn't linking anywhere.
This should be a This should be a `button` if it isn't linking anywhere.
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
import selectAsset from 'selectors/asset';
|
import { selectAsset } from 'selectors/show';
|
||||||
|
|
||||||
const mapStateToProps = ({ show }) => {
|
const mapStateToProps = ({ show }) => {
|
||||||
// select title
|
// select title
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
import { call, put, takeLatest } from 'redux-saga/effects';
|
import { call, put, select, takeLatest } from 'redux-saga/effects';
|
||||||
import * as actions from 'constants/show_action_types';
|
import * as actions from 'constants/show_action_types';
|
||||||
import { addRequestToRequestList, onRequestError, addAssetToAssetList } from 'actions/show';
|
import { addRequestToRequestList, onRequestError, addAssetToAssetList } from 'actions/show';
|
||||||
import { getLongClaimId, getShortId, getClaimData } from 'api/assetApi';
|
import { getLongClaimId, getShortId, getClaimData } from 'api/assetApi';
|
||||||
|
import { selectShowState } from 'selectors/show';
|
||||||
|
|
||||||
function* newAssetRequest (action) {
|
function* newAssetRequest (action) {
|
||||||
const { requestId, name, modifier } = action.data;
|
const { requestId, name, modifier } = action.data;
|
||||||
// get long id
|
const state = yield select(selectShowState);
|
||||||
|
// is this an existing request?
|
||||||
|
// If this uri is in the request list, it's already been fetched
|
||||||
|
if (state.requestList[requestId]) {
|
||||||
|
console.log('that request already exists in the request list!');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// get long id && add request to request list
|
||||||
console.log(`getting asset long id ${name}`);
|
console.log(`getting asset long id ${name}`);
|
||||||
let longId;
|
let longId;
|
||||||
try {
|
try {
|
||||||
|
@ -14,9 +22,14 @@ function* newAssetRequest (action) {
|
||||||
console.log('error:', error);
|
console.log('error:', error);
|
||||||
return yield put(onRequestError(error.message));
|
return yield put(onRequestError(error.message));
|
||||||
}
|
}
|
||||||
// put action to add request to asset request list
|
|
||||||
const assetKey = `a#${name}#${longId}`;
|
const assetKey = `a#${name}#${longId}`;
|
||||||
yield put(addRequestToRequestList(requestId, null, assetKey));
|
yield put(addRequestToRequestList(requestId, null, assetKey));
|
||||||
|
// is this an existing asset?
|
||||||
|
// If this asset is in the asset list, it's already been fetched
|
||||||
|
if (state.assetList[assetKey]) {
|
||||||
|
console.log('that asset already exists in the asset list!');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// get short Id
|
// get short Id
|
||||||
console.log(`getting asset short id ${name} ${longId}`);
|
console.log(`getting asset short id ${name} ${longId}`);
|
||||||
let shortId;
|
let shortId;
|
||||||
|
@ -33,7 +46,7 @@ function* newAssetRequest (action) {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return yield put(onRequestError(error.message));
|
return yield put(onRequestError(error.message));
|
||||||
}
|
}
|
||||||
// put action to add asset to asset list
|
// add asset to asset list
|
||||||
yield put(addAssetToAssetList(assetKey, null, name, longId, shortId, claimData));
|
yield put(addAssetToAssetList(assetKey, null, name, longId, shortId, claimData));
|
||||||
// clear any errors in request error
|
// clear any errors in request error
|
||||||
yield put(onRequestError(null));
|
yield put(onRequestError(null));
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
const selectAsset = (show) => {
|
export const selectAsset = (show) => {
|
||||||
const request = show.requestList[show.request.id];
|
const request = show.requestList[show.request.id];
|
||||||
const assetKey = request.key;
|
const assetKey = request.key;
|
||||||
return show.assetList[assetKey];
|
return show.assetList[assetKey];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default selectAsset;
|
export const selectShowState = (state) => {
|
||||||
|
return state.show;
|
||||||
|
};
|
Why do you do
const that = this
?I think this is another piece you can move entirely into redux. Currently if this component is rendered, then a user navigates away and comes back to the same
<AssetDisplay />
it will make these requests again, even if you just made them a second ago