From 8cfa485f510eea1f0fea308b61138eb730b5f563 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Thu, 24 Sep 2020 14:00:58 -0400 Subject: [PATCH] [MM-28973] Prevent destructuring of undefined (#4832) (#4838) * Prevent destructuring of undefined * Do the same for thread drafts (cherry picked from commit 8a5c58b39a662bb895d270cf2821b47b7564da1f) Co-authored-by: Miguel Alatzar --- 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, ];