Skip to content

Commit

Permalink
Add a refresh button to the library and clear the state on server change
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Jan 11, 2024
1 parent e6a32a4 commit 49d4f45
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions plugins/caspar/app/components/LibraryHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export const LibraryHeader = ({ onChange = () => {} }) => {
onChange={e => handleFilterValue('query', e.target.value)}
/>
</div>
<div className='LibraryHeader-refresh'>
<button className='Button Button--small' onClick={() => handleFilterValue('refresh', Math.floor(Math.random() * 100))}>Refresh</button>
</div>
</header>
)
}
10 changes: 9 additions & 1 deletion plugins/caspar/app/components/LibraryHeader/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
width: 100%;
}

.LibraryHeader-refresh {
margin: 0 5px 5px;
}

@media screen and (min-width: 350px) {
.LibraryHeader {
display: flex;
Expand All @@ -15,6 +19,10 @@
.LibraryHeader-serverSelector {
width: 45%;
}

.LibraryHeader-refresh {
margin: 0 5px 5px 0;
}
}

.LibraryHeader-search {
Expand All @@ -25,4 +33,4 @@

.LibraryHeader-search input {
width: 100%;
}
}
5 changes: 3 additions & 2 deletions plugins/caspar/app/views/Library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export const Library = () => {

React.useEffect(() => {
async function exec () {
setItems([])

if (!filter.serverId) {
setItems([])
return
}

Expand All @@ -53,7 +54,7 @@ export const Library = () => {
setItems(filtered)
}
exec()
}, [filter?.serverId])
}, [filter?.serverId, filter?.refresh])

/**
* An array of all items that matches
Expand Down

0 comments on commit 49d4f45

Please sign in to comment.