Skip to content

[UX] Update order in library when an install starts #3523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions src/frontend/screens/Library/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import Fuse from 'fuse.js'
import ContextProvider from 'frontend/state/ContextProvider'

import GamesList from './components/GamesList'
import {
FavouriteGame,
GameInfo,
GameStatus,
HiddenGame,
Runner
} from 'common/types'
import { FavouriteGame, GameInfo, HiddenGame, Runner } from 'common/types'
import ErrorComponent from 'frontend/components/UI/ErrorComponent'
import LibraryHeader from './components/LibraryHeader'
import {
Expand Down Expand Up @@ -242,15 +236,13 @@ export default React.memo(function Library(): JSX.Element {
}

// cache list of games being installed
const [installing, setInstalling] = useState<string[]>([])

useEffect(() => {
const newInstalling = libraryStatus
.filter((st: GameStatus) => st.status === 'installing')
.map((st: GameStatus) => st.appName)

setInstalling(newInstalling)
}, [libraryStatus])
const installing = useMemo(
() =>
libraryStatus
.filter((st) => st.status === 'installing')
.map((st) => st.appName),
[libraryStatus]
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced useState with useMemo to make it simpler

also removed the type since it's already inferred anyway, removes one import


const filterByPlatform = (library: GameInfo[]) => {
if (!library) {
Expand Down Expand Up @@ -521,6 +513,7 @@ export default React.memo(function Library(): JSX.Element {
gog.library,
amazon.library,
filterText,
installing,
sortDescending,
sortInstalled,
showHidden,
Expand Down