mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
Setting to login at startup; If not a migration, allows skipping.
This commit is contained in:
parent
784b4a796d
commit
1da3257af8
@ -1871,20 +1871,26 @@ fn force_login(app: &mut GossipUi, ctx: &Context) {
|
||||
ui.heading("Passphrase Needed");
|
||||
you::offer_unlock_priv_key(app, ui);
|
||||
|
||||
ui.add_space(10.0);
|
||||
ui.label("We need to rebuild some data which may require decrypting DMs and Giftwraps to rebuild properly. For this reason, you need to login before the data migration runs.");
|
||||
let data_migration = GLOBALS.wait_for_data_migration.load(Ordering::Relaxed);
|
||||
|
||||
// If there is a data migration, explain
|
||||
if data_migration {
|
||||
ui.add_space(10.0);
|
||||
ui.label("We need to rebuild some data which may require decrypting DMs and Giftwraps to rebuild properly. For this reason, you need to login before the data migration runs.");
|
||||
}
|
||||
|
||||
ui.add_space(15.0);
|
||||
|
||||
/*
|
||||
if ui.button("Skip").clicked() {
|
||||
// Stop waiting for login
|
||||
GLOBALS
|
||||
.wait_for_login
|
||||
.store(false, std::sync::atomic::Ordering::Relaxed);
|
||||
GLOBALS.wait_for_login_notify.notify_one();
|
||||
// If there is not a data migration, allow them to skip login
|
||||
if ! data_migration {
|
||||
if ui.button("Skip").clicked() {
|
||||
// Stop waiting for login
|
||||
GLOBALS
|
||||
.wait_for_login
|
||||
.store(false, std::sync::atomic::Ordering::Relaxed);
|
||||
GLOBALS.wait_for_login_notify.notify_one();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
ui.add_space(60.0);
|
||||
ui.separator();
|
||||
|
@ -30,5 +30,10 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
ui.label("(NOTE: changing this will not re-encrypt any existing encrypted private key)");
|
||||
ui.add(Slider::new(&mut app.settings.log_n, 18..=22).text("logN iteratons"));
|
||||
|
||||
// Login at startup
|
||||
ui.add_space(20.0);
|
||||
ui.checkbox(&mut app.settings.login_at_startup, "Login at startup")
|
||||
.on_hover_text("If set, you will be prompted for your password before gossip starts up.");
|
||||
|
||||
ui.add_space(20.0);
|
||||
}
|
||||
|
@ -155,11 +155,17 @@ pub fn init() -> Result<(), Error> {
|
||||
// Load delegation tag
|
||||
GLOBALS.delegation.load()?;
|
||||
|
||||
// If we need to rebuild relationships
|
||||
if GLOBALS.storage.get_flag_rebuild_relationships_needed() {
|
||||
// And we have a key but have not unlocked it
|
||||
if GLOBALS.signer.is_loaded() && !GLOBALS.signer.is_ready() {
|
||||
// Indicate to the overlord and UI to wait for login before continuing
|
||||
// If we have a key but have not unlocked it
|
||||
if GLOBALS.signer.is_loaded() && !GLOBALS.signer.is_ready() {
|
||||
// If we need to rebuild relationships
|
||||
if GLOBALS.storage.get_flag_rebuild_relationships_needed() {
|
||||
GLOBALS
|
||||
.wait_for_login
|
||||
.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
GLOBALS
|
||||
.wait_for_data_migration
|
||||
.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
} else if GLOBALS.storage.read_setting_login_at_startup() {
|
||||
GLOBALS
|
||||
.wait_for_login
|
||||
.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
|
@ -165,9 +165,6 @@ impl Overlord {
|
||||
|
||||
// If we need to rebuild relationships, do so now
|
||||
if GLOBALS.storage.get_flag_rebuild_relationships_needed() {
|
||||
GLOBALS
|
||||
.wait_for_data_migration
|
||||
.store(true, Ordering::Relaxed);
|
||||
GLOBALS.storage.rebuild_relationships(None)?;
|
||||
GLOBALS
|
||||
.wait_for_data_migration
|
||||
|
@ -41,6 +41,7 @@ pub struct Settings {
|
||||
// ID settings
|
||||
pub public_key: Option<PublicKey>,
|
||||
pub log_n: u8,
|
||||
pub login_at_startup: bool,
|
||||
|
||||
// Network settings
|
||||
pub offline: bool,
|
||||
@ -132,6 +133,7 @@ impl Default for Settings {
|
||||
Settings {
|
||||
public_key: default_setting!(public_key),
|
||||
log_n: default_setting!(log_n),
|
||||
login_at_startup: default_setting!(login_at_startup),
|
||||
offline: default_setting!(offline),
|
||||
load_avatars: default_setting!(load_avatars),
|
||||
load_media: default_setting!(load_media),
|
||||
@ -213,6 +215,7 @@ impl Settings {
|
||||
Settings {
|
||||
public_key: load_setting!(public_key),
|
||||
log_n: load_setting!(log_n),
|
||||
login_at_startup: load_setting!(login_at_startup),
|
||||
offline: load_setting!(offline),
|
||||
load_avatars: load_setting!(load_avatars),
|
||||
load_media: load_setting!(load_media),
|
||||
@ -290,6 +293,7 @@ impl Settings {
|
||||
let mut txn = GLOBALS.storage.get_write_txn()?;
|
||||
save_setting!(public_key, self, txn);
|
||||
save_setting!(log_n, self, txn);
|
||||
save_setting!(login_at_startup, self, txn);
|
||||
save_setting!(offline, self, txn);
|
||||
save_setting!(load_avatars, self, txn);
|
||||
save_setting!(load_media, self, txn);
|
||||
|
@ -663,6 +663,7 @@ impl Storage {
|
||||
// setting value
|
||||
def_setting!(public_key, b"public_key", Option::<PublicKey>, None);
|
||||
def_setting!(log_n, b"log_n", u8, 18);
|
||||
def_setting!(login_at_startup, b"login_at_startup", bool, true);
|
||||
def_setting!(offline, b"offline", bool, false);
|
||||
def_setting!(load_avatars, b"load_avatars", bool, true);
|
||||
def_setting!(load_media, b"load_media", bool, true);
|
||||
|
Loading…
Reference in New Issue
Block a user