Skip to content

Commit

Permalink
Merge pull request #459 from NordicSemiconductor/fix/remove-file-warn…
Browse files Browse the repository at this point in the history
…ings

fix: remove file warning when no file is added
  • Loading branch information
boundlesscalm authored Mar 12, 2024
2 parents 93cdcea + b6d998d commit 324652d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Show the device family in the Memory layout title for MCUboot devices.
- Windows and Linux: Dragging and dropping a file into the file memory layout
opened the file in an editor.
- File related warnings were not always removed when removing file regions.

### Removed

Expand Down
10 changes: 8 additions & 2 deletions src/components/FileMemoryBoxView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
*/

import React from 'react';
import React, { useEffect } from 'react';
import Card from 'react-bootstrap/Card';
import { useSelector } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';

import { getLoaded, getZipFilePath } from '../reducers/fileReducer';
import { fileWarningRemove } from '../reducers/warningReducer';
import FileMemoryView from './FileMemoryView';

const hasFileContent = (loaded: Record<string, unknown>) =>
Expand All @@ -21,6 +22,11 @@ export default () => {
const loaded = useSelector(getLoaded);
const zipFilePath = useSelector(getZipFilePath);
const isHolder = !hasFileContent(loaded) && !zipFilePath;
const dispatch = useDispatch();

useEffect(() => {
if (isHolder) dispatch(fileWarningRemove());
}, [isHolder, dispatch]);

return (
<Card className="memory-layout">
Expand Down

0 comments on commit 324652d

Please sign in to comment.