Skip to content

Commit

Permalink
[UI/UX] Pre-release Fixes (#1956)
Browse files Browse the repository at this point in the history
* fix: header filters

* fix: action icons grid/list order

* fix: refresh library after login

* other: remove gawk from dependencies

* feat: get game img from bottles steamGrid api

* fix: current download on sidebar after restart

* Fix README.md typo

Co-authored-by: Mathis Dröge <34034631+CommandMC@users.noreply.github.com>

* fix: log not found error

* fix: typo and lint

Co-authored-by: Mathis Dröge <34034631+CommandMC@users.noreply.github.com>
  • Loading branch information
flavioislima and CommandMC committed Oct 29, 2022
1 parent 8bbe559 commit d043008
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ You can alternatively download the file ending in .rpm from the [latest release]

#### Other Distributions (AppImage and TAR.XZ)

Since these two distribution formats don't have a form of dependency management, make sure the `curl` and `gawk` commands are available. You might run into weird issues if they aren't.
Since these two distribution formats don't have a form of dependency management, make sure the `curl` command is available. You might run into weird issues if it's not.

##### AppImage

Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,18 @@
"deb": {
"packageCategory": "games",
"depends": [
"gawk",
"curl"
]
},
"pacman": {
"packageCategory": "games",
"depends": [
"gawk",
"curl"
]
},
"rpm": {
"packageCategory": "games",
"depends": [
"gawk",
"curl"
]
}
Expand Down
12 changes: 8 additions & 4 deletions src/backend/logger/ipc_handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { ipcMain } from 'electron'
import { readFileSync } from 'graceful-fs'
import { existsSync, readFileSync } from 'graceful-fs'
import { showItemInFolder } from '../utils'
import { getLogFile } from './logfile'

ipcMain.handle('getLogContent', async (event, { appName, defaultLast }) => {
return readFileSync(getLogFile({ appName, defaultLast }), {
encoding: 'utf-8'
})
const logPath = getLogFile({ appName, defaultLast })
if (existsSync(logPath)) {
return readFileSync(getLogFile({ appName, defaultLast }), {
encoding: 'utf-8'
})
}
return ''
})

ipcMain.on('showLogFileInFolder', async (e, { appName, defaultLast }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/UI/ActionIcons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function ActionIcons({
>
<FontAwesomeIcon
className="FormControl__segmentedFaIcon"
icon={faBorderAll}
icon={faList}
/>
</button>
) : (
Expand All @@ -86,7 +86,7 @@ export default function ActionIcons({
>
<FontAwesomeIcon
className="FormControl__segmentedFaIcon"
icon={faList}
icon={faBorderAll}
/>
</button>
)}
Expand Down
1 change: 1 addition & 0 deletions src/frontend/components/UI/Header/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
grid-area: filters;
display: flex;
align-self: center;
justify-self: flex-end;
}

.Header__filters .FormControl {
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/components/UI/PlatformFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ export default function PlatformFilter() {

const isMac = platform === 'darwin'
const isLinux = platform === 'linux'
const isWindows = platform === 'win32'
const disabledIcon = isLinux && category === 'legendary'

if (isWindows) {
return null
}

return (
<div className="platformFilters">
<FormControl segmented>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export default function SidebarLinks() {
const location = useLocation() as { pathname: string }
const [, , runner, appName, type] = location.pathname.split('/') as PathSplit

const { epic, gog, platform, activeController } = useContext(ContextProvider)
const { epic, gog, platform, activeController, refreshLibrary } =
useContext(ContextProvider)

const isStore = location.pathname.includes('store')
const isSettings = location.pathname.includes('settings')
Expand Down Expand Up @@ -117,6 +118,9 @@ export default function SidebarLinks() {
classNames('Sidebar__item', { active: isActive })
}
to={'/'}
onClick={async () =>
refreshLibrary({ runInBackground: false, fullRefresh: true })
}
>
<>
<div className="Sidebar__itemIcon">
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/components/UI/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import SidebarLinks from './components/SidebarLinks'
import './index.css'
import HeroicVersion from './components/HeroicVersion'
import { DMQueueElement } from 'common/types'
import { DMQueue } from 'frontend/types'

export default function Sidebar() {
const { t } = useTranslation()
const { sidebarCollapsed, setSideBarCollapsed } = useContext(ContextProvider)
const [currentDMElement, setCurrentDMElement] = useState<DMQueueElement>()

useEffect(() => {
window.api.getDMQueueInformation().then((elements: DMQueueElement[]) => {
window.api.getDMQueueInformation().then(({ elements }: DMQueue) => {
setCurrentDMElement(elements[0])
})

Expand Down
45 changes: 26 additions & 19 deletions src/frontend/components/UI/StoreFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import FormControl from 'frontend/components/UI/FormControl'
import ContextProvider from 'frontend/state/ContextProvider'

export default function StoreFilter() {
const { category, handleCategory } = useContext(ContextProvider)
const { category, handleCategory, gog, epic } = useContext(ContextProvider)
const { t } = useTranslation()

const isGOGLoggedin = gog.username
const isEpicLoggedin = epic.username

return (
<div className="storeFilter">
<FormControl segmented small>
Expand All @@ -20,24 +23,28 @@ export default function StoreFilter() {
>
{t('All').toUpperCase()}
</button>
<button
className={classNames('FormControl__button', {
active: category === 'legendary'
})}
title={`${t('header.store')}: ${t('store')}`}
onClick={() => handleCategory('legendary')}
>
EPIC
</button>
<button
className={classNames('FormControl__button', {
active: category === 'gog'
})}
title={`${t('header.store')}: ${t('GOG')}`}
onClick={() => handleCategory('gog')}
>
GOG
</button>
{isEpicLoggedin && (
<button
className={classNames('FormControl__button', {
active: category === 'legendary'
})}
title={`${t('header.store')}: ${t('store')}`}
onClick={() => handleCategory('legendary')}
>
EPIC
</button>
)}
{isGOGLoggedin && (
<button
className={classNames('FormControl__button', {
active: category === 'gog'
})}
title={`${t('header.store')}: ${t('GOG')}`}
onClick={() => handleCategory('gog')}
>
GOG
</button>
)}
<button
className={classNames('FormControl__button', {
active: category === 'sideload'
Expand Down
6 changes: 1 addition & 5 deletions src/frontend/screens/DownloadManager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ import { UpdateComponent } from 'frontend/components/UI'
import ProgressHeader from './components/ProgressHeader'
import DownloadManagerHeader from './DownloadManagerHeader'
import { downloadManagerStore } from 'frontend/helpers/electronStores'
import { DMQueue } from 'frontend/types'

const DownloadManagerItem = lazy(
async () =>
import('frontend/screens/DownloadManager/components/DownloadManagerItem')
)

type DMQueue = {
elements: DMQueueElement[]
finished: DMQueueElement[]
}

export default function DownloadManager(): JSX.Element | null {
const { t } = useTranslation()
const [refreshing, setRefreshing] = useState(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ export default function SideloadDialog({
setWine()
}, [title])

useEffect(() => {
setTimeout(async () => {
try {
const res = await fetch(
`https://steamgrid.usebottles.com/api/search/${title}`
)
if (res.status === 200) {
const steamGridImage = (await res.json()) as string
setImageUrl(steamGridImage)
}
} catch (error) {
console.log('Error when getting image from SteamGridDB')
}
}, 2000)
}, [title])

async function handleInstall(): Promise<void> {
window.api.addNewApp({
runner: 'sideload',
Expand Down
19 changes: 12 additions & 7 deletions src/frontend/screens/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const epicLoginPath = '/loginweb/legendary'
export const gogLoginPath = '/loginweb/gog'

export default function NewLogin() {
const { epic, gog } = useContext(ContextProvider)
const { epic, gog, refreshLibrary } = useContext(ContextProvider)
const { t } = useTranslation()
const navigate = useNavigate()
const [loading, setLoading] = useState(true)
Expand All @@ -39,6 +39,11 @@ export default function NewLogin() {
setIsGogLoggedIn(Boolean(gog.username))
}, [epic.username, gog.username, t])

async function handleLibraryClick() {
await refreshLibrary({ fullRefresh: true, runInBackground: false })
navigate('/')
}

return (
<div className="loginPage">
{loading && (
Expand Down Expand Up @@ -96,12 +101,12 @@ export default function NewLogin() {
/>
</div>
</div>

{(epic.username || gog.username) && (
<button onClick={() => navigate('/')} className="goToLibrary">
{t('button.go_to_library', 'Go to Library')}
</button>
)}
<button
onClick={async () => handleLibraryClick()}
className="goToLibrary"
>
{t('button.go_to_library', 'Go to Library')}
</button>
</div>
</div>
)
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/screens/Settings/components/LogSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ export default function LogSettings() {
defaultLast
})
.then((content: string) => {
if (!content) {
setLogFileContent(t('setting.log.no-file', 'No log file found.'))
setLogFileExist(false)
return setRefreshing(false)
}
setLogFileContent(content)
setLogFileExist(true)
setRefreshing(false)
})
.catch(() => {
setLogFileContent(t('setting.log.no-file', 'No log file found.'))
setLogFileExist(false)
setRefreshing(false)
})
}

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/screens/WebView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function WebView() {

setTimeout(() => {
webview.findInPage('authorizationCode')
}, 500)
}, 50)
webview.addEventListener('found-in-page', async () => {
webview.focus()
webview.selectAll()
Expand All @@ -125,7 +125,7 @@ export default function WebView() {
console.error(error)
window.api.logError(String(error))
}
}, 500)
}, 200)
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/state/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class GlobalState extends PureComponent<Props> {
}

handleSuccessfulLogin = (runner: Runner) => {
this.handleCategory(runner)
this.handleCategory('all')
this.refreshLibrary({
fullRefresh: true,
runInBackground: false,
Expand Down
8 changes: 7 additions & 1 deletion src/frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
ConnectivityStatus,
DialogType,
ButtonOptions,
LibraryTopSectionOptions
LibraryTopSectionOptions,
DMQueueElement
} from 'common/types'

export type Category = 'all' | 'legendary' | 'gog' | 'sideload'
Expand Down Expand Up @@ -230,3 +231,8 @@ export interface LocationState {
isLinuxNative: boolean
isMacNative: boolean
}

export type DMQueue = {
elements: DMQueueElement[]
finished: DMQueueElement[]
}

0 comments on commit d043008

Please sign in to comment.