Skip to content

Commit 50ec6bc

Browse files
committed
Fix can not select the device correctly
1 parent 036153f commit 50ec6bc

File tree

5 files changed

+3
-14
lines changed

5 files changed

+3
-14
lines changed

Diff for: src/main/kotlin/moe/sekiu/minilpa/lpa/LPABackend.kt

-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ import moe.sekiu.minilpa.model.Profile
88

99
interface LPABackend<D : Device>
1010
{
11-
var selectedDevice : D?
12-
13-
fun set(d : D?)
14-
{
15-
selectedDevice = d
16-
}
17-
1811
suspend fun getChipInfo() : ChipInfo
1912

2013
suspend fun getProfileList() : List<Profile>

Diff for: src/main/kotlin/moe/sekiu/minilpa/lpa/LPACExecutor.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class LPACExecutor() : LPABackend<Driver>
2727
{
2828
private val log = logger()
2929

30-
override var selectedDevice : Driver? = null
31-
3230
suspend fun getDeviceList() : List<Driver> = decode(execute("driver", "apdu", "list").data)
3331

3432
override suspend fun getChipInfo() : ChipInfo = decode(execute("chip", "info").data)
@@ -79,7 +77,7 @@ class LPACExecutor() : LPABackend<Driver>
7977
val env = mutableMapOf<String, String>()
8078
if (setting.debug.libeuicc.apdu) env["LIBEUICC_DEBUG_APDU"] = "true"
8179
if (setting.debug.libeuicc.http) env["LIBEUICC_DEBUG_HTTP"] = "true"
82-
selectedDevice?.run { env["DRIVER_IFID"] = cast<Driver>().env }
80+
LocalProfileAssistant.devices.selectedItem?.run { env["DRIVER_IFID"] = cast<Driver>().env }
8381
var lpacout : LPACIO? = null
8482
process(
8583
*(arrayOf(lpacFile.canonicalPath) + commands),

Diff for: src/main/kotlin/moe/sekiu/minilpa/lpa/LocalProfileAssistant.kt

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ object LocalProfileAssistant
4444
devices.addAll(backend.cast<LPACExecutor>().getDeviceList())
4545
val device = devices.getElementAt(0)
4646
devices.selectedItem = device
47-
backend.cast<LPABackend<Device>>().selectedDevice = device
4847
}
4948
}
5049
}

Diff for: src/main/kotlin/moe/sekiu/minilpa/lpa/MiniRemoteLPA.kt

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ suspend fun main()
3535

3636
class MiniRemoteLPA : LPABackend<RemoteCard>
3737
{
38-
override var selectedDevice : RemoteCard? = null
39-
4038
lateinit var wsSession : WebSocketSession
4139
val waiting = mutableMapOf<UUID, CompletableDeferred<LPACIO>>()
4240

Diff for: src/main/kotlin/moe/sekiu/minilpa/ui/MainFrame.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import moe.sekiu.minilpa.exception.OperationFailureException
2727
import moe.sekiu.minilpa.freeze
2828
import moe.sekiu.minilpa.language
2929
import moe.sekiu.minilpa.logger
30+
import moe.sekiu.minilpa.lpa.LocalProfileAssistant
3031
import moe.sekiu.minilpa.setup
3132
import moe.sekiu.minilpa.setupFontSize
3233
import moe.sekiu.minilpa.ui.component.MiniProgressDialog
@@ -148,7 +149,7 @@ class MainFrame : JFrame()
148149
block : suspend () -> T
149150
) : T?
150151
{
151-
if (requireDevice && backend.selectedDevice == null)
152+
if (requireDevice && LocalProfileAssistant.devices.selectedItem == null)
152153
{
153154
JOptionPane.showMessageDialog(
154155
this@MainFrame,

0 commit comments

Comments
 (0)