Skip to content
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

[Linux] Added checkbox to uninstall-modal to remove prefix aswell #940

Merged
merged 8 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
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
24 changes: 19 additions & 5 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,15 @@ ipcMain.handle('getGameInfo', async (event, game) => {
}
})

ipcMain.handle('getGameSettings', async (event, game) => {
try {
const settings = await Game.get(game).getSettings()
return settings
} catch (error) {
logError(`${error}`, LogPrefix.Backend)
}
})

ipcMain.handle('getInstallInfo', async (event, game) => {
const online = await isOnline()
if (!online) {
Expand Down Expand Up @@ -818,8 +827,8 @@ ipcMain.on('showItemInFolder', async (e, item) => {
})

const openMessageBox = async (args: Electron.MessageBoxOptions) => {
const { response } = await showMessageBox({ ...args })
return { response }
const { response, checkboxChecked } = await showMessageBox({ ...args })
return { response, checkboxChecked }
}

ipcMain.handle(
Expand Down Expand Up @@ -900,12 +909,17 @@ ipcMain.handle('install', async (event, params) => {
})
})

ipcMain.handle('uninstall', async (event, game) => {
const title = (await Game.get(game).getGameInfo()).title
ipcMain.handle('uninstall', async (event, args) => {
const title = (await Game.get(args[0]).getGameInfo()).title
const winePrefix = (await Game.get(args[0]).getSettings()).winePrefix

return Game.get(game)
return Game.get(args[0])
.uninstall()
.then(() => {
if (args[1]) {
logInfo(`Removing prefix ${winePrefix}`)
rmSync(winePrefix, { recursive: true }) // remove prefix
}
notify({ title, body: i18next.t('notify.uninstalled') })
logInfo('finished uninstalling', LogPrefix.Backend)
})
Expand Down
2 changes: 2 additions & 0 deletions public/locales/bg/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Спиране на инсталацията"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Искате ли да деинсталирате тази игра?",
"title": "Деинсталиране"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ca/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Atura la descarrega"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Vols desinstal·lar aquest joc?",
"title": "Desinstal·lar"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/cs/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Zastavit instalaci"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Chcete odinstalovat tuto hru?",
"title": "Odinstalovat"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/de/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Installation abbrechen"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Möchten Sie dieses Spiel deinstallieren?",
"title": "Deinstallieren"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/el/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Διακοπή εγκατάστασης"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Θέλετε να απεγκαταστήσετε αυτό το παιχνίδι;",
"title": "Απεγκατάσταση"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/en/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Stop Installation"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Do you want to uninstall this game?",
"title": "Uninstall"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/es/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Detener la instalación"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "¿Quieres desinstalar este juego?",
"title": "Desinstalar"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/et/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Peata paigaldamine"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Kas soovite selle mängu eemaldada?",
"title": "Eemalda"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/fa/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "توقف نصب"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "آیا میخواهید این بازی را حذف کنید؟",
"title": "حذف"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/fi/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Pysäytä asennus"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Haluatko poistaa pelin?",
"title": "Poista"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/fr/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Arrêter l'installation"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Voulez-vous désinstaller ce jeu?",
"title": "Désinstaller"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/gl/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Deter a instalación"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Desexas desinstalar o xogo?",
"title": "Desinstalar"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/hr/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Zaustavi instalaciju"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Želite li deinstalirati igricu?",
"title": "Deinstaliraj"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/hu/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Telepítés megállítása"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "El akarod távolítani ezt a játékot?",
"title": "Eltávolítás"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/id/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Hentikan Instalasi"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Apakah Anda ingin mencopot instalasi gim ini?",
"title": "Copot instalasi"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/it/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Ferma l'installazione"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Vuoi disinstallare questo gioco?",
"title": "Disinstalla"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ja/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "インストールを停止する"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "このゲームをアンインストールしたいですか?",
"title": "アンインストール"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ko/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "설치 중지"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "이 게임을 제거하시겠습니까?",
"title": "설치 제거"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ml/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "നടീല് നിര്ത്തൂ"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "ഇാ കളി എടുത്തുനീക്കട്ടെ?",
"title": "എടുത്തു നീക്കൂ"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/nl/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Installatie stoppen"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Wilt u dit spel verwijderen?",
"title": "Verwijderen"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/pl/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Zatrzymaj instalację"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Czy chcesz odinstalować tę grę?",
"title": "Odinstaluj"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/pt/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Cancelar Instalação"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Você deseja desinstalar esse jogo?",
"title": "Desinstalar"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/pt_BR/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Parar a Instalação"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Deseja desinstalar este jogo?",
"title": "Desinstalar"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ru/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Прекращение установки"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Вы хотите удалить эту игру?",
"title": "Удалить"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/sv/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Avbryt installationen"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Vill du avinstallera spelet?",
"title": "Avinstallera"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/ta/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "நிறுவலை நிறுத்து"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "இந்த விளையாட்டை நிறுவல்-நீக்க விரும்புகிறீர்களா?",
"title": "நிறுவல் நீக்கு"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/tr/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "Kurulumu Durdur"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "Oyunu kaldırmak istiyor musunuz?",
"title": "Kaldır"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh_Hans/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "停止安装"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "你希望卸载这个游戏吗?",
"title": "卸载"
},
Expand Down
2 changes: 2 additions & 0 deletions public/locales/zh_Hant/gamepage.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"title": "停止安裝"
},
"uninstall": {
"checkbox": "Would you like to remove the prefix aswell? This can't be undone.",
"checkbox_prefix": "Prefix",
"message": "你希望將這個遊戲解除安裝嗎?",
"title": "解除安裝"
},
Expand Down
13 changes: 12 additions & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { AppSettings, GameInfo, InstallInfo, InstallProgress } from 'src/types'
import {
AppSettings,
GameInfo,
InstallInfo,
InstallProgress,
GameSettings
} from 'src/types'
import { IpcRenderer } from 'electron'
import { install, launch, repair, updateGame } from './library'
const { ipcRenderer } = window.require('electron') as {
Expand Down Expand Up @@ -97,6 +103,10 @@ const getGameInfo = async (appName: string): Promise<GameInfo> => {
return await ipcRenderer.invoke('getGameInfo', appName)
}

const getGameSettings = async (appName: string): Promise<GameSettings> => {
return await ipcRenderer.invoke('getGameSettings', appName)
}

const getInstallInfo = async (appName: string): Promise<InstallInfo> => {
return await ipcRenderer.invoke('getInstallInfo', appName)
}
Expand Down Expand Up @@ -224,6 +234,7 @@ export {
fixSaveFolder,
formatStoreUrl,
getGameInfo,
getGameSettings,
getInstallInfo,
getLegendaryConfig,
getPlatform,
Expand Down
28 changes: 25 additions & 3 deletions src/helpers/library.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppSettings, GameInfo, GameStatus, InstallProgress } from 'src/types'
import { IpcRenderer } from 'electron'
import { TFunction } from 'react-i18next'
import { getGameInfo, sendKill } from './index'
import { getGameInfo, getPlatform, sendKill, getGameSettings } from './index'
import ElectronStore from 'electron-store'

const { ipcRenderer } = window.require('electron') as {
Expand Down Expand Up @@ -146,11 +146,33 @@ async function uninstall({ appName, handleGameStatus, t }: UninstallArgs) {
type: 'warning'
}

const { response } = await ipcRenderer.invoke('openMessageBox', args)
let linuxArgs
if ((await getPlatform()) === 'linux') {
const wineprefix = (await getGameSettings(appName)).winePrefix

linuxArgs = {
checkboxLabel: [
t(
'gamepage:box.uninstall.checkbox',
"Would you like to remove the prefix aswell? This can't be undone."
),
`${t(
'gamepage:box.uninstall.checkbox_prefix',
'Prefix'
)}: ${wineprefix}`
].join('\n'),
checkboxChecked: false
}
}

const { response, checkboxChecked } = await ipcRenderer.invoke(
'openMessageBox',
{ ...args, ...linuxArgs }
)

if (response === 0) {
await handleGameStatus({ appName, status: 'uninstalling' })
await ipcRenderer.invoke('uninstall', appName)
await ipcRenderer.invoke('uninstall', [appName, checkboxChecked])
storage.removeItem(appName)
return await handleGameStatus({ appName, status: 'done' })
}
Expand Down
Loading