Skip to content

Commit

Permalink
Add method to check if store has registration data (whisperfish#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
gferon committed Apr 11, 2023
1 parent 9753964 commit 550f2d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions presage-store-sled/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ impl Store for SledStore {
Ok(())
}

fn is_registered(&self) -> bool {
self.load_state().unwrap_or_default().is_some()
}

fn clear_registration(&mut self) -> Result<(), SledStoreError> {
self.db.remove(SLED_KEY_REGISTRATION)?;

Expand Down
3 changes: 3 additions & 0 deletions presage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ pub trait Store:
/// Save registered (or linked) state
fn save_state(&mut self, state: &Registered) -> Result<(), Self::Error>;

/// Returns whether this store contains registration data or not
fn is_registered(&self) -> bool;

/// Clear registration data (including keys), but keep received messages, groups and contacts.
fn clear_registration(&mut self) -> Result<(), Self::Error>;

Expand Down

0 comments on commit 550f2d1

Please sign in to comment.