mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-21 10:11:57 +00:00
fix: don't store torrentPath on UI
This commit is contained in:
parent
17498e8e69
commit
36fa2e3313
6 changed files with 28 additions and 22 deletions
|
|
@ -37,6 +37,7 @@ export default class TorrentClient extends WebTorrent {
|
||||||
player = ''
|
player = ''
|
||||||
/** @type {ReturnType<spawn>} */
|
/** @type {ReturnType<spawn>} */
|
||||||
playerProcess = null
|
playerProcess = null
|
||||||
|
torrentPath = ''
|
||||||
|
|
||||||
constructor (ipc, storageQuota, serverMode, settingOverrides = {}, controller) {
|
constructor (ipc, storageQuota, serverMode, settingOverrides = {}, controller) {
|
||||||
const settings = { ...defaults, ...storedSettings, ...settingOverrides }
|
const settings = { ...defaults, ...storedSettings, ...settingOverrides }
|
||||||
|
|
@ -63,6 +64,9 @@ export default class TorrentClient extends WebTorrent {
|
||||||
ipc.on('player', (event, data) => {
|
ipc.on('player', (event, data) => {
|
||||||
this.player = data
|
this.player = data
|
||||||
})
|
})
|
||||||
|
ipc.on('torrentPath', (event, data) => {
|
||||||
|
this.torrentPath = data
|
||||||
|
})
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
|
|
||||||
this.serverMode = serverMode
|
this.serverMode = serverMode
|
||||||
|
|
@ -212,7 +216,7 @@ export default class TorrentClient extends WebTorrent {
|
||||||
if (this.torrents.length) await this.remove(this.torrents[0])
|
if (this.torrents.length) await this.remove(this.torrents[0])
|
||||||
const torrent = await this.add(data, {
|
const torrent = await this.add(data, {
|
||||||
private: this.settings.torrentPeX,
|
private: this.settings.torrentPeX,
|
||||||
path: this.settings.torrentPath,
|
path: this.torrentPath,
|
||||||
destroyStoreOnDestroy: !this.settings.torrentPersist,
|
destroyStoreOnDestroy: !this.settings.torrentPersist,
|
||||||
skipVerify,
|
skipVerify,
|
||||||
announce
|
announce
|
||||||
|
|
@ -247,7 +251,6 @@ export default class TorrentClient extends WebTorrent {
|
||||||
this.playerProcess.once('close', () => {
|
this.playerProcess.once('close', () => {
|
||||||
this.playerProcess = null
|
this.playerProcess = null
|
||||||
const seconds = (Date.now() - startTime) / 1000
|
const seconds = (Date.now() - startTime) / 1000
|
||||||
console.log(seconds)
|
|
||||||
this.dispatch('externalWatched', seconds)
|
this.dispatch('externalWatched', seconds)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@
|
||||||
<div class='input-group-prepend'>
|
<div class='input-group-prepend'>
|
||||||
<button type='button' use:click={handleFolder} class='btn btn-primary input-group-append'>Select Folder</button>
|
<button type='button' use:click={handleFolder} class='btn btn-primary input-group-append'>Select Folder</button>
|
||||||
</div>
|
</div>
|
||||||
<input type='url' class='form-control bg-dark' bind:value={settings.torrentPath} placeholder='/tmp' />
|
<input type='url' class='form-control bg-dark' readonly value={settings.torrentPath} placeholder='/tmp' />
|
||||||
</div>
|
</div>
|
||||||
</SettingCard>
|
</SettingCard>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,25 @@ export default class Dialog {
|
||||||
sender.send('player', basename(path, extname(path)))
|
sender.send('player', basename(path, extname(path)))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
ipcMain.on('dialog', async ({ sender }) => {
|
||||||
|
const { filePaths, canceled } = await dialog.showOpenDialog({
|
||||||
|
title: 'Select torrent download location',
|
||||||
|
properties: ['openDirectory']
|
||||||
|
})
|
||||||
|
if (canceled) return
|
||||||
|
if (filePaths.length) {
|
||||||
|
let path = filePaths[0]
|
||||||
|
if (!(path.endsWith('\\') || path.endsWith('/'))) {
|
||||||
|
if (path.indexOf('\\') !== -1) {
|
||||||
|
path += '\\'
|
||||||
|
} else if (path.indexOf('/') !== -1) {
|
||||||
|
path += '/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
store.set('torrentPath', path)
|
||||||
|
torrentWindow.webContents.send('torrentPath', path)
|
||||||
|
sender.send('path', path)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ function createWindow () {
|
||||||
await torrentLoad
|
await torrentLoad
|
||||||
webtorrentWindow.webContents.postMessage('port', null, [port1])
|
webtorrentWindow.webContents.postMessage('port', null, [port1])
|
||||||
webtorrentWindow.webContents.postMessage('player', store.get('player'))
|
webtorrentWindow.webContents.postMessage('player', store.get('player'))
|
||||||
|
webtorrentWindow.webContents.postMessage('torrentPath', store.get('torrentPath'))
|
||||||
sender.postMessage('port', null, [port2])
|
sender.postMessage('port', null, [port2])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,4 @@ function parseDataFile (filePath, defaults) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Store('settings', { angle: 'default', player: '' })
|
export default new Store('settings', { angle: 'default', player: '', torrentPath: '' })
|
||||||
|
|
|
||||||
|
|
@ -48,24 +48,6 @@ ipcMain.on('close', () => {
|
||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('dialog', async ({ sender }) => {
|
|
||||||
const { filePaths, canceled } = await dialog.showOpenDialog({
|
|
||||||
properties: ['openDirectory']
|
|
||||||
})
|
|
||||||
if (canceled) return
|
|
||||||
if (filePaths.length) {
|
|
||||||
let path = filePaths[0]
|
|
||||||
if (!(path.endsWith('\\') || path.endsWith('/'))) {
|
|
||||||
if (path.indexOf('\\') !== -1) {
|
|
||||||
path += '\\'
|
|
||||||
} else if (path.indexOf('/') !== -1) {
|
|
||||||
path += '/'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sender.send('path', path)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('version', ({ sender }) => {
|
ipcMain.on('version', ({ sender }) => {
|
||||||
sender.send('version', app.getVersion()) // fucking stupid
|
sender.send('version', app.getVersion()) // fucking stupid
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue