Skip to content

Commit 9cf2e4f

Browse files
committed
Remove unneeded selected_credential infrastructure
1 parent ae51f48 commit 9cf2e4f

File tree

3 files changed

+0
-47
lines changed

3 files changed

+0
-47
lines changed

xyz-iinuwa-credential-manager-portal-gtk/src/view_model/gtk/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ mod imp {
3939
#[property(get, set)]
4040
pub selected_device: RefCell<Option<DeviceObject>>,
4141

42-
#[property(get, set)]
43-
pub selected_credential: RefCell<Option<String>>,
44-
4542
#[property(get, set)]
4643
pub usb_pin_entry_visible: RefCell<bool>,
4744

@@ -124,9 +121,6 @@ impl ViewModel {
124121
ViewUpdate::WaitingForDevice(device) => {
125122
view_model.waiting_for_device(&device)
126123
}
127-
ViewUpdate::SelectCredential(cred_id) => {
128-
view_model.select_credential(cred_id)
129-
}
130124
ViewUpdate::UsbNeedsPin { attempts_left } => {
131125
let prompt = match attempts_left {
132126
Some(1) => {
@@ -298,18 +292,12 @@ impl ViewModel {
298292
}
299293
let device_object: DeviceObject = device.into();
300294
self.set_selected_device(device_object);
301-
self.set_selected_credential("");
302295
}
303296

304297
fn selecting_device(&self) {
305298
self.set_prompt("Multiple devices found. Please select with which to proceed.");
306299
}
307300

308-
fn select_credential(&self, cred_id: String) {
309-
// todo: Do we still need this?
310-
self.set_selected_credential(cred_id);
311-
}
312-
313301
pub async fn send_thingy(&self) {
314302
self.send_event(ViewEvent::ButtonClicked).await;
315303
}

xyz-iinuwa-credential-manager-portal-gtk/src/view_model/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ where
2828
// This includes devices like platform authenticator, USB, hybrid
2929
devices: Vec<Device>,
3030
selected_device: Option<Device>,
31-
selected_credential: Option<String>,
3231

3332
providers: Vec<Provider>,
3433

@@ -59,7 +58,6 @@ impl<C: CredentialServiceClient + Send> ViewModel<C> {
5958
title: String::default(),
6059
devices: Vec::new(),
6160
selected_device: None,
62-
selected_credential: None,
6361
providers: Vec::new(),
6462
usb_pin_tx: None,
6563
usb_cred_tx: None,
@@ -154,11 +152,6 @@ impl<C: CredentialServiceClient + Send> ViewModel<C> {
154152
todo!();
155153
}
156154
};
157-
// Remove the attribute below when we implement cancellation for at least one transport.
158-
#[allow(unreachable_code)]
159-
{
160-
self.selected_credential = None;
161-
}
162155
}
163156

164157
// start discovery for newly selected device
@@ -280,18 +273,12 @@ impl<C: CredentialServiceClient + Send> ViewModel<C> {
280273
"Credential selected: {:?}. Current Device: {:?}",
281274
cred_id, self.selected_device
282275
);
283-
// TODO: Do we still need this?
284-
self.selected_credential = Some(cred_id.clone());
285276

286277
if let Some(cred_tx) = self.usb_cred_tx.take() {
287278
if cred_tx.lock().await.send(cred_id.clone()).await.is_err() {
288279
error!("Failed to send selected credential to device");
289280
}
290281
}
291-
self.tx_update
292-
.send(ViewUpdate::SelectCredential(cred_id))
293-
.await
294-
.unwrap();
295282
}
296283

297284
Event::Background(BackgroundEvent::UsbPressed) => {
@@ -400,7 +387,6 @@ pub enum ViewUpdate {
400387
SetDevices(Vec<Device>),
401388
SetCredentials(Vec<Credential>),
402389
WaitingForDevice(Device),
403-
SelectCredential(String),
404390
UsbNeedsPin { attempts_left: Option<u32> },
405391
UsbNeedsUserVerification { attempts_left: Option<u32> },
406392
UsbNeedsUserPresence,

xyz-iinuwa-credential-manager-portal-gtk/src/window.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -183,27 +183,6 @@ impl ExampleApplicationWindow {
183183
}
184184
));
185185

186-
view_model.connect_selected_credential_notify(clone!(
187-
#[weak]
188-
stack,
189-
move |vm| {
190-
let c = vm.selected_credential();
191-
if c.is_none() || c.unwrap().is_empty() {
192-
return;
193-
}
194-
195-
let d = vm.selected_device();
196-
let d = d
197-
.and_downcast_ref::<DeviceObject>()
198-
.expect("selected device to exist at notify");
199-
match d.transport().try_into() {
200-
Ok(Transport::Usb) => stack.set_visible_child_name("usb"),
201-
Ok(Transport::HybridQr) => stack.set_visible_child_name("hybrid_qr"),
202-
_ => {}
203-
};
204-
}
205-
));
206-
207186
view_model.connect_completed_notify(clone!(
208187
#[weak]
209188
stack,

0 commit comments

Comments
 (0)