mirror of
https://github.com/wassname/talk.git
synced 2026-07-09 18:21:30 +08:00
Fix date comparision and change article for asset.
This commit is contained in:
@@ -24,16 +24,17 @@ export const updateConfiguration = newConfig => (dispatch, getState) => {
|
||||
.catch(error => dispatch(updateConfigFailure(error)));
|
||||
};
|
||||
|
||||
export const updateOpenStream = newConfig => (dispatch, getState) => {
|
||||
export const updateOpenStream = closedBody => (dispatch, getState) => {
|
||||
const assetId = getState().items.get('assets')
|
||||
.keySeq()
|
||||
.toArray()[0];
|
||||
|
||||
dispatch(updateConfigRequest());
|
||||
coralApi(`/asset/${assetId}/status`, {method: 'PUT', body: newConfig})
|
||||
|
||||
coralApi(`/asset/${assetId}/status`, {method: 'PUT', body: closedBody})
|
||||
.then(() => {
|
||||
dispatch(addNotification('success', lang.t('successUpdateSettings')));
|
||||
dispatch(updateConfigSuccess(newConfig));
|
||||
dispatch(updateConfigSuccess(closedBody));
|
||||
})
|
||||
.catch(error => dispatch(updateConfigFailure(error)));
|
||||
};
|
||||
@@ -47,6 +48,6 @@ export const updateOpenStatus = status => dispatch => {
|
||||
dispatch(updateOpenStream({closedAt: null}));
|
||||
} else {
|
||||
dispatch(closeStream());
|
||||
dispatch(updateOpenStream({closedAt: Date.now(), closedMessage: ''}));
|
||||
dispatch(updateOpenStream({closedAt: new Date().getTime(), closedMessage: ''}));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ export default (state = initialState, action) => {
|
||||
return state
|
||||
.set('status', 'closed');
|
||||
case actions.ADD_ITEM:
|
||||
return action.item_type === 'assets' ? state.set('status', action.item.status) : state;
|
||||
return action.item_type === 'assets' ? state.set('status', (action.item && action.item.closedAt && new Date(action.item.closedAt).getTime() <= new Date().getTime()) ? 'closed' : 'open') : state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ const AssetSchema = new Schema({
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'article'
|
||||
default: 'assets'
|
||||
},
|
||||
scraped: {
|
||||
type: Date,
|
||||
|
||||
@@ -94,7 +94,7 @@ router.put('/:asset_id/status', (req, res, next) => {
|
||||
const {
|
||||
closedAt = null,
|
||||
closedMessage = null
|
||||
} = req.query;
|
||||
} = req.body;
|
||||
Asset
|
||||
.update(id, {
|
||||
closedAt: closedAt,
|
||||
|
||||
Reference in New Issue
Block a user