Skip to content

Commit

Permalink
Merge pull request #37 from ChristianPayne/main
Browse files Browse the repository at this point in the history
v1.4.3
  • Loading branch information
ChristianPayne authored Feb 4, 2025
2 parents 27f33ef + b4c3339 commit 5462915
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ennesults-rs",
"private": true,
"version": "1.4.2",
"version": "1.4.3",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ennesults-rs"
version = "1.4.2"
version = "1.4.3"
description = "A Twitch bot created for Ennegineer to kindly insult her chat."
authors = ["Christian Payne"]
license = ""
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/src/bot/bot_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ impl BotData {
announcements: Mutex::new(announcements),
}
}

pub fn get_users(&self) -> Users {
let users_guard = self.users.lock().expect("Failed to get lock for users.");

users_guard.clone()
}
}

impl Default for BotData {
Expand Down
9 changes: 1 addition & 8 deletions src-tauri/src/bot/insults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,7 @@ pub fn format_insult(

let mut users: Users = {
match user_pool {
None => {
let users_state = state
.bot_data
.users
.lock()
.expect("Failed to get lock for users.");
users_state.clone()
}
None => state.bot_data.get_users(),
Some(users) => Users::from(users),
}
};
Expand Down
7 changes: 6 additions & 1 deletion src-tauri/src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ pub struct ChangelogVersionNotes {
notes: &'static str,
}

const CHANGELOG: [ChangelogVersionNotes; 10] = [
const CHANGELOG: [ChangelogVersionNotes; 11] = [
ChangelogVersionNotes {
version: "v1.4.3",
title: None,
notes: r"- Fixed a deadlock issue for consent and unconsent getting users.",
},
ChangelogVersionNotes {
version: "v1.4.2",
title: None,
Expand Down
8 changes: 2 additions & 6 deletions src-tauri/src/commands/consent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ impl Command for ConsentCommand {
msg: &PrivmsgMessage,
app_handle: AppHandle,
) -> Option<String> {
let bot_data = app_handle.state::<Bot>();
let mut users = bot_data
.bot_data
.users
.lock()
.expect("Failed to get lock for bot data.");
let state = app_handle.state::<Bot>();
let mut users = state.bot_data.get_users();

let consent_target = match args.len() {
0 => Some(msg.sender.name.clone()),
Expand Down
6 changes: 1 addition & 5 deletions src-tauri/src/commands/unconsent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ impl Command for UnconsentCommand {
app_handle: AppHandle,
) -> Option<String> {
let state = app_handle.state::<Bot>();
let mut users = state
.bot_data
.users
.lock()
.expect("Failed to get lock for bot data.");
let mut users = state.bot_data.get_users();

let consent_target = match args.len() {
0 => Some(msg.sender.name.clone()),
Expand Down

0 comments on commit 5462915

Please sign in to comment.