story: Update layout state file location on release mode.
This commit is contained in:
parent
0d1c40a56a
commit
393e7e8f85
1 changed files with 7 additions and 3 deletions
|
|
@ -29,6 +29,11 @@ const MAIN_DOCK_AREA: DockAreaTab = DockAreaTab {
|
||||||
version: 5,
|
version: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
const STATE_FILE: &str = "target/layout.json";
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
const STATE_FILE: &str = "layout.json";
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]);
|
cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]);
|
||||||
|
|
||||||
|
|
@ -201,7 +206,7 @@ impl StoryWorkspace {
|
||||||
fn save_state(state: &DockAreaState) -> Result<()> {
|
fn save_state(state: &DockAreaState) -> Result<()> {
|
||||||
println!("Save layout...");
|
println!("Save layout...");
|
||||||
let json = serde_json::to_string_pretty(state)?;
|
let json = serde_json::to_string_pretty(state)?;
|
||||||
std::fs::write("target/layout.json", json)?;
|
std::fs::write(STATE_FILE, json)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,8 +215,7 @@ impl StoryWorkspace {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let fname = "target/layout.json";
|
let json = std::fs::read_to_string(STATE_FILE)?;
|
||||||
let json = std::fs::read_to_string(fname)?;
|
|
||||||
let state = serde_json::from_str::<DockAreaState>(&json)?;
|
let state = serde_json::from_str::<DockAreaState>(&json)?;
|
||||||
|
|
||||||
// Check if the saved layout version is different from the current version
|
// Check if the saved layout version is different from the current version
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue