This commit is contained in:
Benjamin Sherriff
2023-12-10 11:28:43 -05:00
parent c825c73eb4
commit b474866e7e
11 changed files with 186 additions and 129 deletions

View File

@@ -94,7 +94,7 @@ pub async fn play_track(manager: Arc<Songbird>, guild_id: GuildId, track_url: St
call_handler.queue().is_empty() call_handler.queue().is_empty()
}; };
let guild = QueryGuild::get(guild_id.0 as i64)?; let guild = QueryGuild::get(guild_id.0 as i64)?;
match add_song(handler_lock.clone(), &track_url, is_queue_empty, Some(guild.volume as f32)).await { match add_song(handler_lock.clone(), &track_url, is_queue_empty, Some(guild.volume as f32 / 100.0)).await {
Ok(added_song) => { Ok(added_song) => {
let track_title = added_song.title.unwrap(); let track_title = added_song.title.unwrap();
debug!("Added track: {}", track_title); debug!("Added track: {}", track_title);

View File

View File

View File

@@ -98,16 +98,16 @@ async fn main() -> std::io::Result<()> {
let shard_manager = Arc::clone(&client.shard_manager); let shard_manager = Arc::clone(&client.shard_manager);
// tokio::spawn(async move { tokio::spawn(async move {
// tokio::signal::ctrl_c().await.expect("Could not register ctrl+c handler"); tokio::signal::ctrl_c().await.expect("Could not register ctrl+c handler");
// shard_manager.lock().await.shutdown_all().await; shard_manager.lock().await.shutdown_all().await;
// }); });
// tokio::spawn(async move { tokio::spawn(async move {
// if let Err(why) = client.start_autosharded().await { if let Err(why) = client.start_autosharded().await {
// error!("An error occurred while running the client: {:?}", why); error!("An error occurred while running the client: {:?}", why);
// } }
// }); });
let host = env::var("SERVICE_HOST").unwrap_or("localhost".to_string()); let host = env::var("SERVICE_HOST").unwrap_or("localhost".to_string());
let port = env::var("SERVICE_PORT").unwrap_or("5000".to_string()); let port = env::var("SERVICE_PORT").unwrap_or("5000".to_string());

156
ui/package-lock.json generated
View File

@@ -8,18 +8,18 @@
"name": "siren-ui", "name": "siren-ui",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@mantine/core": "^7.1.5", "@mantine/core": "^7.2.2",
"@mantine/form": "^7.1.5", "@mantine/form": "^7.2.2",
"@mantine/hooks": "^7.1.5", "@mantine/hooks": "^7.2.2",
"@mantine/modals": "^7.1.5", "@mantine/modals": "^7.2.2",
"@mantine/notifications": "^7.1.5", "@mantine/notifications": "^7.2.2",
"@pixi/react": "^7.1.1", "@pixi/react": "^7.1.1",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"next": "^13.5.6", "next": "^14.0.3",
"pixi.js": "^7.3.2", "pixi.js": "^7.3.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-icons": "^4.11.0", "react-icons": "^4.12.0",
"recoil": "^0.7.7" "recoil": "^0.7.7"
}, },
"devDependencies": { "devDependencies": {
@@ -199,9 +199,9 @@
"dev": true "dev": true
}, },
"node_modules/@mantine/core": { "node_modules/@mantine/core": {
"version": "7.1.5", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/@mantine/core/-/core-7.1.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/core/-/core-7.2.2.tgz",
"integrity": "sha512-4jBuy26V4Wdrt7r2dT6d3SKSyU9Gfzxp0ycVTBd2FUb6PvsI/xyZIn8T/aHsJFQ1L5p7IHPcJCIThbmBpVvVtA==", "integrity": "sha512-cVGmLjYyKIzjn0LRwamj71O4HT43qCxPGAzMZqkMYGOako7xwBLYQNe7HjL/J0FXJDyfX8OdMylVhgsePWYbng==",
"dependencies": { "dependencies": {
"@floating-ui/react": "^0.24.8", "@floating-ui/react": "^0.24.8",
"clsx": "2.0.0", "clsx": "2.0.0",
@@ -211,7 +211,7 @@
"type-fest": "^3.13.1" "type-fest": "^3.13.1"
}, },
"peerDependencies": { "peerDependencies": {
"@mantine/hooks": "7.1.5", "@mantine/hooks": "7.2.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
} }
@@ -228,9 +228,9 @@
} }
}, },
"node_modules/@mantine/form": { "node_modules/@mantine/form": {
"version": "7.1.5", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/@mantine/form/-/form-7.1.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/form/-/form-7.2.2.tgz",
"integrity": "sha512-icBVvmkYdbD1Nea63GyPv0dF7Dq7kJUfIelFpG+BFLhCh/ctiCN+zL6PRGaXYtB9RDTN+/cyaHyvyRlCbtWQPg==", "integrity": "sha512-Tzux6WbUliK6id1I7lV8tmu6je0WFrJLPDg+0xVyW7Qk/zmju837kj7SSfvNcJa51dKAtYxf3FgqTRy6ap9QEA==",
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.3", "fast-deep-equal": "^3.1.3",
"klona": "^2.0.5" "klona": "^2.0.5"
@@ -240,35 +240,35 @@
} }
}, },
"node_modules/@mantine/hooks": { "node_modules/@mantine/hooks": {
"version": "7.1.5", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-7.1.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-7.2.2.tgz",
"integrity": "sha512-LuKlJ5VDLYBMcleyKcL6nvcJZQaeJF4mIU5ryEiucy7IleZoD+lqWwNC1VAAN1fsjBRQfhFtFoRihUdIy/vDCA==", "integrity": "sha512-7CFSVP2aQHrBwLLAVf0q5dgj+6QTZmhLTNcuc3pE1du+HLFUdyVS6vvQC6kieZXxOd6UzwFGBlN4G+aDx95XeA==",
"peerDependencies": { "peerDependencies": {
"react": "^18.2.0" "react": "^18.2.0"
} }
}, },
"node_modules/@mantine/modals": { "node_modules/@mantine/modals": {
"version": "7.1.5", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/@mantine/modals/-/modals-7.1.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/modals/-/modals-7.2.2.tgz",
"integrity": "sha512-VI3stQ2bqPQEhsqQdeBEhwK/Mi2iKlio+Y5TX1jaiYVbrB0WHdC2tGh2oY9W4ehsAkkX7OYbu8+L7hn9IGO3pw==", "integrity": "sha512-J65xJ5ZULUG8fvNU+UnHboqEs3ueNDTMITUiVucqw4lupt93JHfamuR/PIV2mrXMYqSaKd4NBnxvkmcpjs0uRg==",
"peerDependencies": { "peerDependencies": {
"@mantine/core": "7.1.5", "@mantine/core": "7.2.2",
"@mantine/hooks": "7.1.5", "@mantine/hooks": "7.2.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
} }
}, },
"node_modules/@mantine/notifications": { "node_modules/@mantine/notifications": {
"version": "7.1.5", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/@mantine/notifications/-/notifications-7.1.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/notifications/-/notifications-7.2.2.tgz",
"integrity": "sha512-/WRxNNgPvRr4munHjCTZaMVjSIpz8ydheccpPGrqOgAN/zfPNWYYcv7kaqXdlb+ag9ZMFsixQB97svvhCRxPCA==", "integrity": "sha512-2MQ0jJi9HOspJOAq0sfE5QvacZytYoLB8k0GwnubnFilSACbpDYeoQXZWmKX0joYhHtKR15muTnF+P1s9kmr3Q==",
"dependencies": { "dependencies": {
"@mantine/store": "7.1.5", "@mantine/store": "7.2.2",
"react-transition-group": "4.4.5" "react-transition-group": "4.4.5"
}, },
"peerDependencies": { "peerDependencies": {
"@mantine/core": "7.1.5", "@mantine/core": "7.2.2",
"@mantine/hooks": "7.1.5", "@mantine/hooks": "7.2.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
} }
@@ -298,17 +298,17 @@
} }
}, },
"node_modules/@mantine/store": { "node_modules/@mantine/store": {
"version": "7.1.5", "version": "7.2.2",
"resolved": "https://registry.npmjs.org/@mantine/store/-/store-7.1.5.tgz", "resolved": "https://registry.npmjs.org/@mantine/store/-/store-7.2.2.tgz",
"integrity": "sha512-iPAt8auWyUs5TyUr31MziCILlLCYCfw6fSqPvLxOwUYpSf9BvtCAoE9JmrRrVi2q5+xO0KPSyK+OHWyBwsAqcQ==", "integrity": "sha512-j8vR8whB332pGI8OXkM2/3rdh4LJxELJQTG+rTsCCd3VQuEJiRTQDKVaOvp9ONja3GU5b1Tk3zhKOrkpgxTJBA==",
"peerDependencies": { "peerDependencies": {
"react": "^18.2.0" "react": "^18.2.0"
} }
}, },
"node_modules/@next/env": { "node_modules/@next/env": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.3.tgz",
"integrity": "sha512-Yac/bV5sBGkkEXmAX5FWPS9Mmo2rthrOPRQQNfycJPkjUAUclomCPH7QFVCDQ4Mp2k2K1SSM6m0zrxYrOwtFQw==" "integrity": "sha512-7xRqh9nMvP5xrW4/+L0jgRRX+HoNRGnfJpD+5Wq6/13j3dsdzxO3BCXn7D3hMqsDb+vjZnJq+vI7+EtgrYZTeA=="
}, },
"node_modules/@next/eslint-plugin-next": { "node_modules/@next/eslint-plugin-next": {
"version": "13.5.6", "version": "13.5.6",
@@ -320,9 +320,9 @@
} }
}, },
"node_modules/@next/swc-darwin-arm64": { "node_modules/@next/swc-darwin-arm64": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.3.tgz",
"integrity": "sha512-5nvXMzKtZfvcu4BhtV0KH1oGv4XEW+B+jOfmBdpFI3C7FrB/MfujRpWYSBBO64+qbW8pkZiSyQv9eiwnn5VIQA==", "integrity": "sha512-64JbSvi3nbbcEtyitNn2LEDS/hcleAFpHdykpcnrstITFlzFgB/bW0ER5/SJJwUPj+ZPY+z3e+1jAfcczRLVGw==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -335,9 +335,9 @@
} }
}, },
"node_modules/@next/swc-darwin-x64": { "node_modules/@next/swc-darwin-x64": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.0.3.tgz",
"integrity": "sha512-6cgBfxg98oOCSr4BckWjLLgiVwlL3vlLj8hXg2b+nDgm4bC/qVXXLfpLB9FHdoDu4057hzywbxKvmYGmi7yUzA==", "integrity": "sha512-RkTf+KbAD0SgYdVn1XzqE/+sIxYGB7NLMZRn9I4Z24afrhUpVJx6L8hsRnIwxz3ERE2NFURNliPjJ2QNfnWicQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -350,9 +350,9 @@
} }
}, },
"node_modules/@next/swc-linux-arm64-gnu": { "node_modules/@next/swc-linux-arm64-gnu": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.0.3.tgz",
"integrity": "sha512-txagBbj1e1w47YQjcKgSU4rRVQ7uF29YpnlHV5xuVUsgCUf2FmyfJ3CPjZUvpIeXCJAoMCFAoGnbtX86BK7+sg==", "integrity": "sha512-3tBWGgz7M9RKLO6sPWC6c4pAw4geujSwQ7q7Si4d6bo0l6cLs4tmO+lnSwFp1Tm3lxwfMk0SgkJT7EdwYSJvcg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -365,9 +365,9 @@
} }
}, },
"node_modules/@next/swc-linux-arm64-musl": { "node_modules/@next/swc-linux-arm64-musl": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.0.3.tgz",
"integrity": "sha512-cGd+H8amifT86ZldVJtAKDxUqeFyLWW+v2NlBULnLAdWsiuuN8TuhVBt8ZNpCqcAuoruoSWynvMWixTFcroq+Q==", "integrity": "sha512-v0v8Kb8j8T23jvVUWZeA2D8+izWspeyeDGNaT2/mTHWp7+37fiNfL8bmBWiOmeumXkacM/AB0XOUQvEbncSnHA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -380,9 +380,9 @@
} }
}, },
"node_modules/@next/swc-linux-x64-gnu": { "node_modules/@next/swc-linux-x64-gnu": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.3.tgz",
"integrity": "sha512-Mc2b4xiIWKXIhBy2NBTwOxGD3nHLmq4keFk+d4/WL5fMsB8XdJRdtUlL87SqVCTSaf1BRuQQf1HvXZcy+rq3Nw==", "integrity": "sha512-VM1aE1tJKLBwMGtyBR21yy+STfl0MapMQnNrXkxeyLs0GFv/kZqXS5Jw/TQ3TSUnbv0QPDf/X8sDXuMtSgG6eg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -395,9 +395,9 @@
} }
}, },
"node_modules/@next/swc-linux-x64-musl": { "node_modules/@next/swc-linux-x64-musl": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.3.tgz",
"integrity": "sha512-CFHvP9Qz98NruJiUnCe61O6GveKKHpJLloXbDSWRhqhkJdZD2zU5hG+gtVJR//tyW897izuHpM6Gtf6+sNgJPQ==", "integrity": "sha512-64EnmKy18MYFL5CzLaSuUn561hbO1Gk16jM/KHznYP3iCIfF9e3yULtHaMy0D8zbHfxset9LTOv6cuYKJgcOxg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -410,9 +410,9 @@
} }
}, },
"node_modules/@next/swc-win32-arm64-msvc": { "node_modules/@next/swc-win32-arm64-msvc": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.0.3.tgz",
"integrity": "sha512-aFv1ejfkbS7PUa1qVPwzDHjQWQtknzAZWGTKYIAaS4NMtBlk3VyA6AYn593pqNanlicewqyl2jUhQAaFV/qXsg==", "integrity": "sha512-WRDp8QrmsL1bbGtsh5GqQ/KWulmrnMBgbnb+59qNTW1kVi1nG/2ndZLkcbs2GX7NpFLlToLRMWSQXmPzQm4tog==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -425,9 +425,9 @@
} }
}, },
"node_modules/@next/swc-win32-ia32-msvc": { "node_modules/@next/swc-win32-ia32-msvc": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.0.3.tgz",
"integrity": "sha512-XqqpHgEIlBHvzwG8sp/JXMFkLAfGLqkbVsyN+/Ih1mR8INb6YCc2x/Mbwi6hsAgUnqQztz8cvEbHJUbSl7RHDg==", "integrity": "sha512-EKffQeqCrj+t6qFFhIFTRoqb2QwX1mU7iTOvMyLbYw3QtqTw9sMwjykyiMlZlrfm2a4fA84+/aeW+PMg1MjuTg==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -440,9 +440,9 @@
} }
}, },
"node_modules/@next/swc-win32-x64-msvc": { "node_modules/@next/swc-win32-x64-msvc": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.6.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.0.3.tgz",
"integrity": "sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==", "integrity": "sha512-ERhKPSJ1vQrPiwrs15Pjz/rvDHZmkmvbf/BjPN/UCOI++ODftT0GtasDPi0j+y6PPJi5HsXw+dpRaXUaw4vjuQ==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -3689,11 +3689,11 @@
"dev": true "dev": true
}, },
"node_modules/next": { "node_modules/next": {
"version": "13.5.6", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/next/-/next-13.5.6.tgz", "resolved": "https://registry.npmjs.org/next/-/next-14.0.3.tgz",
"integrity": "sha512-Y2wTcTbO4WwEsVb4A8VSnOsG1I9ok+h74q0ZdxkwM3EODqrs4pasq7O0iUxbcS9VtWMicG7f3+HAj0r1+NtKSw==", "integrity": "sha512-AbYdRNfImBr3XGtvnwOxq8ekVCwbFTv/UJoLwmaX89nk9i051AEY4/HAWzU0YpaTDw8IofUpmuIlvzWF13jxIw==",
"dependencies": { "dependencies": {
"@next/env": "13.5.6", "@next/env": "14.0.3",
"@swc/helpers": "0.5.2", "@swc/helpers": "0.5.2",
"busboy": "1.6.0", "busboy": "1.6.0",
"caniuse-lite": "^1.0.30001406", "caniuse-lite": "^1.0.30001406",
@@ -3705,18 +3705,18 @@
"next": "dist/bin/next" "next": "dist/bin/next"
}, },
"engines": { "engines": {
"node": ">=16.14.0" "node": ">=18.17.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"@next/swc-darwin-arm64": "13.5.6", "@next/swc-darwin-arm64": "14.0.3",
"@next/swc-darwin-x64": "13.5.6", "@next/swc-darwin-x64": "14.0.3",
"@next/swc-linux-arm64-gnu": "13.5.6", "@next/swc-linux-arm64-gnu": "14.0.3",
"@next/swc-linux-arm64-musl": "13.5.6", "@next/swc-linux-arm64-musl": "14.0.3",
"@next/swc-linux-x64-gnu": "13.5.6", "@next/swc-linux-x64-gnu": "14.0.3",
"@next/swc-linux-x64-musl": "13.5.6", "@next/swc-linux-x64-musl": "14.0.3",
"@next/swc-win32-arm64-msvc": "13.5.6", "@next/swc-win32-arm64-msvc": "14.0.3",
"@next/swc-win32-ia32-msvc": "13.5.6", "@next/swc-win32-ia32-msvc": "14.0.3",
"@next/swc-win32-x64-msvc": "13.5.6" "@next/swc-win32-x64-msvc": "14.0.3"
}, },
"peerDependencies": { "peerDependencies": {
"@opentelemetry/api": "^1.1.0", "@opentelemetry/api": "^1.1.0",
@@ -4371,9 +4371,9 @@
} }
}, },
"node_modules/react-icons": { "node_modules/react-icons": {
"version": "4.11.0", "version": "4.12.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.11.0.tgz", "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.12.0.tgz",
"integrity": "sha512-V+4khzYcE5EBk/BvcuYRq6V/osf11ODUM2J8hg2FDSswRrGvqiYUYPRy4OdrWaQOBj4NcpJfmHZLNaD+VH0TyA==", "integrity": "sha512-IBaDuHiShdZqmfc/TwHu6+d6k2ltNCf3AszxNmjJc1KUfXdEeRJOKyNvLmAHaarhzGmTSVygNdyu8/opXv2gaw==",
"peerDependencies": { "peerDependencies": {
"react": "*" "react": "*"
} }

View File

@@ -9,18 +9,18 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@mantine/core": "^7.1.5", "@mantine/core": "^7.2.2",
"@mantine/form": "^7.1.5", "@mantine/form": "^7.2.2",
"@mantine/hooks": "^7.1.5", "@mantine/hooks": "^7.2.2",
"@mantine/modals": "^7.1.5", "@mantine/modals": "^7.2.2",
"@mantine/notifications": "^7.1.5", "@mantine/notifications": "^7.2.2",
"@pixi/react": "^7.1.1", "@pixi/react": "^7.1.1",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"next": "^13.5.6", "next": "^14.0.3",
"pixi.js": "^7.3.2", "pixi.js": "^7.3.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-icons": "^4.11.0", "react-icons": "^4.12.0",
"recoil": "^0.7.7" "recoil": "^0.7.7"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -1,5 +1,29 @@
import React from 'react'; 'use client';
import { ActionIcon, Tooltip } from '@mantine/core';
import { FaPlus } from "react-icons/fa";
import React, { useEffect } from 'react';
import { getCampigns } from '@/api/campaigns';
import { Campaign } from '@/api/campaigns.types';
export default function Page() { export default function Page() {
return <></>; const [campaigns, setCampaigns] = React.useState<Campaign[]>([]);
useEffect(() => {
getCampigns().then((data) => setCampaigns(data));
}, []);
return (
<div>
<h1>Campaigns</h1>
<Tooltip label="Create a new campaign">
<ActionIcon variant="outline" color="blue">
<FaPlus />
</ActionIcon>
</Tooltip>
{campaigns && campaigns.map((campaign) => (
<div key={campaign.id}>{campaign.name}</div>
))}
</div>
);
} }

View File

@@ -8,6 +8,7 @@ import { Notifications } from '@mantine/notifications';
import 'styles/globals.css'; import 'styles/globals.css';
import '@mantine/core/styles.css'; import '@mantine/core/styles.css';
import '@mantine/notifications/styles.css'; import '@mantine/notifications/styles.css';
import Loading from '@/components/Loading';
export const metadata = { export const metadata = {
title: 'Siren', title: 'Siren',
@@ -27,8 +28,10 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<MantineProvider> <MantineProvider>
<Notifications /> <Notifications />
<ModalsProvider> <ModalsProvider>
<Loading>
<Header /> <Header />
<Box>{children}</Box> <Box>{children}</Box>
</Loading>
</ModalsProvider> </ModalsProvider>
</MantineProvider> </MantineProvider>
</RecoilRootWrapper> </RecoilRootWrapper>

View File

@@ -26,17 +26,8 @@ export default function Header() {
const router = useRouter(); const router = useRouter();
useEffect(() => { useEffect(() => {
if (!user) { if (user) {
hasSession().then((response) => { updateUser(user);
if (response) {
refresh().then((response) => {
if (response) {
setUser(response.user);
updateUser(response.user);
}
});
}
});
} }
}, [user]); }, [user]);

View File

@@ -0,0 +1,39 @@
'use client';
import { hasSession, refresh } from "@/api/auth";
import { userState } from "@/state/auth";
import { Skeleton } from "@mantine/core";
import { useEffect, useState } from "react";
import { useRecoilState } from "recoil";
export default function Loading({ children }: { children: React.ReactNode }) {
const [loading, setLoading] = useState(true);
const [user, setUser] = useRecoilState(userState);
useEffect(() => {
if (!user) {
hasSession().then((response) => {
if (response) {
refresh().then((response) => {
if (response) {
setUser(response.user);
setLoading(false);
} else {
setLoading(false);
}
});
} else {
setLoading(false);
}
});
} else {
setLoading(false);
}
}, []);
if (loading) {
return <Skeleton height={'100%'} />;
} else {
return <>{children}</>;
}
}

View File

@@ -40,6 +40,13 @@ export default function TileGrid() {
e.preventDefault() e.preventDefault()
} }
document.addEventListener('wheel', handleScroll, { passive: false }) document.addEventListener('wheel', handleScroll, { passive: false })
// Prevent space from scrolling page
function handleSpace(e: any) {
if (e.key === ' ') {
e.preventDefault()
}
}
document.addEventListener('keydown', handleSpace, { passive: false })
return function cleanup() { return function cleanup() {
document.removeEventListener('contextmenu', handleContextmenu) document.removeEventListener('contextmenu', handleContextmenu)
document.removeEventListener('wheel', handleScroll) document.removeEventListener('wheel', handleScroll)
@@ -49,34 +56,28 @@ export default function TileGrid() {
const drawGrid = useCallback( const drawGrid = useCallback(
(g: PixiGraphics) => { (g: PixiGraphics) => {
g.clear(); g.clear();
// Draw edits
edits.forEach((edit) => {
g.beginFill(parseInt(edit.color.replace('#', ''), 16));
g.drawRect(edit.x * 32 * zoom, edit.y * 32 * zoom, 32 * zoom, 32 * zoom);
g.endFill();
});
// Draw dot in the corner of each tile // Draw dot in the corner of each tile
for (let x = 0; x < gridSize.width; x += 32 * zoom) { for (let x = 0; x < gridSize.width; x += (32 * zoom)) {
for (let y = 0; y < gridSize.height; y += 32 * zoom) { for (let y = 0; y < gridSize.height; y += (32 * zoom)) {
g.beginFill(0xffffff, 0.5); g.beginFill(0xffffff, 0.5);
g.drawCircle(x, y, 1); g.drawCircle(x, y, 1);
g.endFill(); g.endFill();
} }
} }
}, },
[gridSize, zoom] [gridSize, edits, zoom]
);
const drawGridEdits = useCallback(
(g: PixiGraphics) => {
g.clear();
edits.forEach((edit) => {
g.beginFill(parseInt(edit.color.replace('#', ''), 16));
g.drawRect(edit.x * 32 * zoom, edit.y * 32 * zoom, 32 * zoom, 32 * zoom);
g.endFill();
});
},
[edits, zoom]
); );
function drawSquare(button: number, clientX: number, clientY: number) { function drawSquare(button: number, clientX: number, clientY: number) {
// TODO: When zoomed in, the position is offset from above, when zoomed out, the position is offset from below
const x = Math.floor((clientX - position.x) / (32 * zoom)); const x = Math.floor((clientX - position.x) / (32 * zoom));
// TODO: Fix y offset, currently appears to be 2 tiles down from mouse const y = Math.floor((clientY - position.y) / (32 * zoom));
const y = Math.floor((clientY - position.y) / (32 * zoom)) - 2;
if (button === 1) { if (button === 1) {
// Add new edit if left mouse button is pressed // Add new edit if left mouse button is pressed
setEdits([...edits, { x, y, color: colors[selectedColor] }]); setEdits([...edits, { x, y, color: colors[selectedColor] }]);
@@ -162,7 +163,6 @@ export default function TileGrid() {
onWheel={(e) => zoomEvent(e)} onWheel={(e) => zoomEvent(e)}
> >
<Graphics x={position.x} y={position.y} draw={drawGrid} /> <Graphics x={position.x} y={position.y} draw={drawGrid} />
<Graphics x={position.x} y={position.y} draw={drawGridEdits} />
</Stage> </Stage>
<TileControls <TileControls
tool={tool} tool={tool}