From 8a5c58b39a662bb895d270cf2821b47b7564da1f Mon Sep 17 00:00:00 2001 From: Miguel Alatzar Date: Thu, 24 Sep 2020 10:50:42 -0700 Subject: [PATCH] [MM-28973] Prevent destructuring of undefined (#4832) * Prevent destructuring of undefined * Do the same for thread drafts --- app/reducers/views/channel.js | 2 +- app/reducers/views/thread.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/reducers/views/channel.js b/app/reducers/views/channel.js index 14430b7b8..b4edd8e4f 100644 --- a/app/reducers/views/channel.js +++ b/app/reducers/views/channel.js @@ -62,7 +62,7 @@ function handleSetTempUploadFileForPostDraft(state, action) { const tempFiles = action.clientIds.map((temp) => ({...temp, loading: true})); const files = [ - ...state[action.channelId].files, + ...state[action.channelId]?.files || [], ...tempFiles, ]; diff --git a/app/reducers/views/thread.js b/app/reducers/views/thread.js index 952c72171..6e51c4d3e 100644 --- a/app/reducers/views/thread.js +++ b/app/reducers/views/thread.js @@ -73,7 +73,7 @@ function handleSetTempUploadFilesForPostDraft(state, action) { const tempFiles = action.clientIds.map((temp) => ({...temp, loading: true})); const files = [ - ...state[action.rootId].files, + ...state[action.rootId]?.files || [], ...tempFiles, ];