mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
On first run, start on Getting Started page
This commit is contained in:
parent
1df81e8db8
commit
b6ff669fd6
@ -29,6 +29,7 @@ use crate::error::Error;
|
||||
use crate::globals::GLOBALS;
|
||||
use rusqlite::Connection;
|
||||
use std::fs;
|
||||
use std::sync::atomic::Ordering;
|
||||
use tokio::task;
|
||||
|
||||
// This sets up the database
|
||||
@ -77,8 +78,15 @@ fn check_and_upgrade() -> Result<(), Error> {
|
||||
["version"],
|
||||
|row| row.get::<usize, String>(0),
|
||||
) {
|
||||
Ok(v) => upgrade(db, v.parse::<u16>().unwrap()),
|
||||
Ok(v) => {
|
||||
let version = v.parse::<u16>().unwrap();
|
||||
if version < 2 {
|
||||
GLOBALS.first_run.store(true, Ordering::Relaxed);
|
||||
}
|
||||
upgrade(db, version)
|
||||
}
|
||||
Err(_e) => {
|
||||
GLOBALS.first_run.store(true, Ordering::Relaxed);
|
||||
// Check the error first!
|
||||
upgrade(db, 0)
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ use tokio::sync::{broadcast, mpsc, Mutex, RwLock};
|
||||
/// Only one of these is ever created, via lazy_static!, and represents
|
||||
/// global state for the rust application
|
||||
pub struct Globals {
|
||||
/// Is this the first run?
|
||||
pub first_run: AtomicBool,
|
||||
|
||||
/// This is our connection to SQLite. Only one thread at a time.
|
||||
pub db: Mutex<Option<Connection>>,
|
||||
|
||||
@ -89,6 +92,7 @@ lazy_static! {
|
||||
let (to_overlord, tmp_overlord_receiver) = mpsc::unbounded_channel();
|
||||
|
||||
Globals {
|
||||
first_run: AtomicBool::new(false),
|
||||
db: Mutex::new(None),
|
||||
to_minions,
|
||||
to_overlord,
|
||||
|
@ -212,6 +212,12 @@ impl GossipUi {
|
||||
None => (false, current_dpi),
|
||||
};
|
||||
|
||||
let start_page = if GLOBALS.first_run.load(Ordering::Relaxed) {
|
||||
Page::HelpHelp
|
||||
} else {
|
||||
Page::Feed(FeedKind::General)
|
||||
};
|
||||
|
||||
GossipUi {
|
||||
next_frame: Instant::now(),
|
||||
override_dpi,
|
||||
@ -221,7 +227,7 @@ impl GossipUi {
|
||||
render_qr: None,
|
||||
person_qr: None,
|
||||
setting_active_person: false,
|
||||
page: Page::Feed(FeedKind::General),
|
||||
page: start_page,
|
||||
history: vec![],
|
||||
about: crate::about::about(),
|
||||
icon: icon_texture_handle,
|
||||
@ -316,7 +322,7 @@ impl eframe::App for GossipUi {
|
||||
|
||||
if GLOBALS
|
||||
.shutting_down
|
||||
.load(std::sync::atomic::Ordering::Relaxed)
|
||||
.load(Ordering::Relaxed)
|
||||
{
|
||||
frame.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user