Skip to content

Commit

Permalink
attempt to fix timer still going after encounter
Browse files Browse the repository at this point in the history
add case save encounter when no phase transition event was emitted
  • Loading branch information
snoww committed Apr 10, 2023
1 parent 712a393 commit 6bc0fef
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn main() {
let meter_window = app.get_window("main").unwrap();
meter_window.set_always_on_top(true)
.expect("failed to set windows always on top");
#[cfg(debug_assertions)] // only include this code on debug builds
#[cfg(debug_assertions)]
{
meter_window.open_devtools();
}
Expand Down Expand Up @@ -103,7 +103,7 @@ fn main() {
.build()
.expect("failed to create log window");
logs_window.set_size(Size::Logical(LogicalSize { width: 800.0, height: 500.0 })).unwrap();
#[cfg(debug_assertions)] // only include this code on debug builds
#[cfg(debug_assertions)]
{
logs_window.open_devtools();
}
Expand Down
19 changes: 16 additions & 3 deletions src-tauri/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ use tokio::task;
pub struct Parser<'a> {
pub window: &'a Window<Wry>,
pub encounter: Encounter,
pub raid_end: bool
pub raid_end: bool,
pub saved: bool
}

impl Parser<'_> {
pub fn new(window: &Window<Wry>) -> Parser {
Parser {
window,
encounter: Encounter::default(),
raid_end: false
raid_end: false,
saved: false
}
}

pub fn parse_line(&mut self, line: String) {
// println!("{}", line);
#[cfg(debug_assertions)]
{
println!("{}", line);
}

if line.is_empty() {
return;
}
Expand Down Expand Up @@ -63,6 +69,7 @@ impl Parser<'_> {
if self.raid_end {
self.raid_end = false;
self.soft_reset();
self.saved = false;
}

match log_type {
Expand Down Expand Up @@ -169,6 +176,11 @@ impl Parser<'_> {
v.name == self.encounter.local_player
|| (v.damage_stats.damage_dealt > 0 && v.max_hp > 0)
});

if !self.saved && !self.encounter.current_boss_name.is_empty() {
self.save_to_db();
}

self.window
.emit("zone-change", Some(self.encounter.clone()))
.expect("failed to emit zone-change");
Expand Down Expand Up @@ -196,6 +208,7 @@ impl Parser<'_> {
{
self.save_to_db();
self.raid_end = true;
self.saved = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "LOA Logs",
"version": "0.4.0"
"version": "0.5.0"
},
"tauri": {
"allowlist": {
Expand Down
6 changes: 2 additions & 4 deletions src/lib/components/DamageMeter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@
});
let phaseTransitionEvent = await listen('phase-transition', (event) => {
console.log("phase transition event: ", event.payload)
// phaseTransitionAlert = true;
// setTimeout(() => {
// phaseTransitionAlert = false;
// }, 3000);
active = false;
});
let raidEndEvent = await listen('raid-end', (event: EncounterEvent) => {
console.log("raid-end, updating encounter")
encounter = event.payload;
active = false;
raidEndAlert = true;
setTimeout(() => {
raidEndAlert = false;
Expand Down

0 comments on commit 6bc0fef

Please sign in to comment.