Skip to content

Commit

Permalink
refactor(core)!: rename plugin::PermissionState::Unknown to plugin::P…
Browse files Browse the repository at this point in the history
…ermissionState::Prompt (#10978)

* fix(core): plugin::PermissionState::Unknown wrong display impl

* prompt

* rename variant

* fix
  • Loading branch information
lucasfernog authored Sep 13, 2024
1 parent be18ed5 commit fe5ff12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-permission-state-unknown-display.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": patch:breaking
---

Rename `PermissionState::Unknown` to `PermissionState::Prompt`.
10 changes: 5 additions & 5 deletions crates/tauri/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,20 +910,20 @@ pub enum PermissionState {
Granted,
/// Permission access has been denied.
Denied,
/// Permission must be requested.
#[default]
Prompt,
/// Permission must be requested, but you must explain to the user why your app needs that permission. **Android only**.
PromptWithRationale,
/// Unknown state. Must request permission.
#[default]
Unknown,
}

impl std::fmt::Display for PermissionState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Granted => write!(f, "granted"),
Self::Denied => write!(f, "denied"),
Self::Prompt => write!(f, "prompt"),
Self::PromptWithRationale => write!(f, "prompt-with-rationale"),
Self::Unknown => write!(f, "Unknown"),
}
}
}
Expand All @@ -946,8 +946,8 @@ impl<'de> Deserialize<'de> for PermissionState {
match s.to_lowercase().as_str() {
"granted" => Ok(Self::Granted),
"denied" => Ok(Self::Denied),
"prompt" => Ok(Self::Prompt),
"prompt-with-rationale" => Ok(Self::PromptWithRationale),
"prompt" => Ok(Self::Unknown),
_ => Err(DeError::custom(format!("unknown permission state '{s}'"))),
}
}
Expand Down

0 comments on commit fe5ff12

Please sign in to comment.