Skip to content

Commit

Permalink
added HIDE_PORTFOLIO_ROW setting
Browse files Browse the repository at this point in the history
  • Loading branch information
djkato committed Jan 29, 2023
1 parent 969abe3 commit 3d1bee8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .drp_config
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ djkato.net

EXCLUDE_CHARACTERS_LIST:{
no_drp
}

HIDE_PORTFOLIO_ROW:{
no
}
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "DRP_Creative"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
author = "https://djkato.net"

Expand All @@ -23,4 +23,4 @@ features = [
]

[target.'cfg(windows)'.build-dependencies]
windres = "0.2.2"
windres = "0.2.2"
21 changes: 20 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub struct Config {
pub exclude_keywords_list: Vec<String>,
pub should_exclude_be_invisible: bool,
pub portfolio_link: String,
pub hide_portfolio_row: bool,
}

impl Config {
Expand Down Expand Up @@ -36,7 +37,7 @@ fn parse_config_file(config_file: &String) -> Config {
let mut exclude_keywords_list: Vec<String> = Vec::new();
let mut should_exclude_be_invisible = false;
let mut portfolio_link = String::new();

let mut hide_portfolio_row = false;
for (i, line) in config_file.lines().enumerate() {
if line.contains("SHOULD_EXCLUDE_BE_ANONYMOUS:") {
match config_file
Expand All @@ -45,6 +46,7 @@ fn parse_config_file(config_file: &String) -> Config {
.expect("index out of bounds")
.to_lowercase()
.as_str()
.trim()
{
"n" => should_exclude_be_invisible = false,
"no" => should_exclude_be_invisible = false,
Expand All @@ -69,11 +71,28 @@ fn parse_config_file(config_file: &String) -> Config {
portfolio_link = arg_line.to_string();
}
}
if line.contains("HIDE_PORTFOLIO_ROW:") {
match config_file
.lines()
.nth(i + 1)
.expect("index out of bounds")
.to_lowercase()
.as_str()
.trim()
{
"n" => hide_portfolio_row = false,
"no" => hide_portfolio_row = false,
"y" => hide_portfolio_row = true,
"yes" => hide_portfolio_row = true,
_ => hide_portfolio_row = false,
}
}
}
Config {
exclude_keywords_list,
should_exclude_be_invisible,
portfolio_link,
hide_portfolio_row,
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ fn main() {
prev_project_name = project_name.clone();
let details = format!("Working on {}", &project_name.clone());
//update activity
let state = format!("Portfolio: {}", &config.portfolio_link);
let activity = activity::Activity::new()
.state(state.as_str())

let mut activity = activity::Activity::new()
.details(&details.as_str())
.assets(
activity::Assets::new().large_image(current_app.drp_client_id.as_str()),
)
.timestamps(activity::Timestamps::new().start(start_time as i64));
let state;
if !config.hide_portfolio_row {
state = format!("Portfolio: {}", &config.portfolio_link);
activity = activity.state(state.as_str());
}
//if discord client exists, update status
if let Some(dc) = discord_client.as_mut() {
match dc.set_activity(activity) {
Expand Down

0 comments on commit 3d1bee8

Please sign in to comment.