fix(web client): websocket url detection on invite screen
This commit is contained in:
parent
a23147556b
commit
2f40a0a507
5 changed files with 32 additions and 59 deletions
|
|
@ -130,14 +130,12 @@
|
||||||
"copy_link": "Copier le lien",
|
"copy_link": "Copier le lien",
|
||||||
"link_copied": "Copié !",
|
"link_copied": "Copié !",
|
||||||
"scan_qr": "ou scannez le QR code",
|
"scan_qr": "ou scannez le QR code",
|
||||||
"join_code_label": "Rejoindre avec un code",
|
|
||||||
"join_code_placeholder": "Code de la salle",
|
|
||||||
"share_btn": "Partager",
|
"share_btn": "Partager",
|
||||||
"nickname_modal_title": "Choisissez votre pseudo",
|
"nickname_modal_title": "Choisissez votre pseudo",
|
||||||
"nickname_modal_hint": "Vous jouerez sous le nom de :",
|
"nickname_modal_hint": "Vous jouerez sous le nom de :",
|
||||||
"nickname_modal_play": "Jouer",
|
"nickname_modal_play": "Jouer",
|
||||||
"nickname_modal_or": "ou",
|
"nickname_modal_or": "ou",
|
||||||
"nickname_modal_sign_in": "Se connecter",
|
"nickname_modal_sign_in": "connectez-vous",
|
||||||
"nickname_modal_register": "Créer un compte",
|
"nickname_modal_register": "Créer un compte",
|
||||||
"new_game": "Nouvelle partie",
|
"new_game": "Nouvelle partie",
|
||||||
"language": "Langue"
|
"language": "Langue"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,22 @@ use trictrac_store::CheckerMove;
|
||||||
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
const RELAY_URL: &str = "ws://localhost:8080/ws";
|
fn relay_url() -> String {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
"ws://localhost:8080/ws".to_string()
|
||||||
|
}
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
{
|
||||||
|
let location = web_sys::window()
|
||||||
|
.and_then(|w| Some(w.location()))
|
||||||
|
.unwrap();
|
||||||
|
let protocol = location.protocol().unwrap_or_default();
|
||||||
|
let host = location.host().unwrap_or_default();
|
||||||
|
let ws_protocol = if protocol == "https:" { "wss" } else { "ws" };
|
||||||
|
format!("{ws_protocol}://{host}/ws")
|
||||||
|
}
|
||||||
|
}
|
||||||
const GAME_ID: &str = "trictrac";
|
const GAME_ID: &str = "trictrac";
|
||||||
const STORAGE_KEY: &str = "trictrac_session";
|
const STORAGE_KEY: &str = "trictrac_session";
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
@ -205,7 +220,7 @@ pub fn App() -> impl IntoView {
|
||||||
Some(NetCommand::CreateRoom { room }) => {
|
Some(NetCommand::CreateRoom { room }) => {
|
||||||
break Some((
|
break Some((
|
||||||
RoomConfig {
|
RoomConfig {
|
||||||
relay_url: RELAY_URL.to_string(),
|
relay_url: relay_url(),
|
||||||
game_id: GAME_ID.to_string(),
|
game_id: GAME_ID.to_string(),
|
||||||
room_id: room,
|
room_id: room,
|
||||||
rule_variation: 0,
|
rule_variation: 0,
|
||||||
|
|
@ -219,7 +234,7 @@ pub fn App() -> impl IntoView {
|
||||||
Some(NetCommand::JoinRoom { room }) => {
|
Some(NetCommand::JoinRoom { room }) => {
|
||||||
break Some((
|
break Some((
|
||||||
RoomConfig {
|
RoomConfig {
|
||||||
relay_url: RELAY_URL.to_string(),
|
relay_url: relay_url(),
|
||||||
game_id: GAME_ID.to_string(),
|
game_id: GAME_ID.to_string(),
|
||||||
room_id: room,
|
room_id: room,
|
||||||
rule_variation: 0,
|
rule_variation: 0,
|
||||||
|
|
@ -304,7 +319,7 @@ pub fn App() -> impl IntoView {
|
||||||
|
|
||||||
if !session.is_host {
|
if !session.is_host {
|
||||||
save_session(&StoredSession {
|
save_session(&StoredSession {
|
||||||
relay_url: RELAY_URL.to_string(),
|
relay_url: relay_url(),
|
||||||
game_id: GAME_ID.to_string(),
|
game_id: GAME_ID.to_string(),
|
||||||
room_id: room_id_for_storage.clone(),
|
room_id: room_id_for_storage.clone(),
|
||||||
token: session.reconnect_token,
|
token: session.reconnect_token,
|
||||||
|
|
@ -358,7 +373,7 @@ pub fn App() -> impl IntoView {
|
||||||
|
|
||||||
if is_host {
|
if is_host {
|
||||||
save_session(&StoredSession {
|
save_session(&StoredSession {
|
||||||
relay_url: RELAY_URL.to_string(),
|
relay_url: relay_url(),
|
||||||
game_id: GAME_ID.to_string(),
|
game_id: GAME_ID.to_string(),
|
||||||
room_id: room_id_for_storage.clone(),
|
room_id: room_id_for_storage.clone(),
|
||||||
token: reconnect_token,
|
token: reconnect_token,
|
||||||
|
|
|
||||||
|
|
@ -195,12 +195,9 @@ fn IdleCard(
|
||||||
pending_action: RwSignal<Option<PendingLobbyAction>>,
|
pending_action: RwSignal<Option<PendingLobbyAction>>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let i18n = use_i18n();
|
let i18n = use_i18n();
|
||||||
let join_open = RwSignal::new(false);
|
|
||||||
let join_code = RwSignal::new(String::new());
|
|
||||||
|
|
||||||
let cmd_bot = cmd_tx.clone();
|
let cmd_bot = cmd_tx.clone();
|
||||||
let cmd_create = cmd_tx.clone();
|
let cmd_create = cmd_tx.clone();
|
||||||
let cmd_join = cmd_tx;
|
|
||||||
|
|
||||||
let on_create = move |_: leptos::ev::MouseEvent| {
|
let on_create = move |_: leptos::ev::MouseEvent| {
|
||||||
let code = generate_room_code();
|
let code = generate_room_code();
|
||||||
|
|
@ -232,48 +229,6 @@ fn IdleCard(
|
||||||
{t!(i18n, create_room)}
|
{t!(i18n, create_room)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
// Hidden "join by code" fallback
|
|
||||||
<div style="margin-top:1.25rem;text-align:center">
|
|
||||||
<button
|
|
||||||
class="portal-page-btn"
|
|
||||||
style="font-size:0.75rem;opacity:0.7"
|
|
||||||
on:click=move |_| join_open.update(|v| *v = !*v)
|
|
||||||
>
|
|
||||||
{move || if join_open.get() { "▲ " } else { "▼ " }}
|
|
||||||
{t!(i18n, join_code_label)}
|
|
||||||
</button>
|
|
||||||
{move || {
|
|
||||||
let cmd = cmd_join.clone();
|
|
||||||
join_open.get().then(|| view! {
|
|
||||||
<div style="margin-top:0.75rem;display:flex;gap:0.5rem">
|
|
||||||
<input
|
|
||||||
class="login-input"
|
|
||||||
style="margin:0"
|
|
||||||
type="text"
|
|
||||||
placeholder=move || t_string!(i18n, join_code_placeholder)
|
|
||||||
prop:value=move || join_code.get()
|
|
||||||
on:input=move |ev| join_code.set(event_target_value(&ev))
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
class="login-btn login-btn-secondary"
|
|
||||||
style="margin:0;padding:0 1rem"
|
|
||||||
disabled=move || join_code.get().is_empty()
|
|
||||||
on:click=move |_| {
|
|
||||||
let code = join_code.get();
|
|
||||||
if auth_username.get_untracked().is_some() {
|
|
||||||
cmd.unbounded_send(NetCommand::JoinRoom { room: code }).ok();
|
|
||||||
} else {
|
|
||||||
pending_action.set(Some(PendingLobbyAction::Join { code }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t!(i18n, join_room)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,8 +293,6 @@ fn NicknameModal(
|
||||||
{t!(i18n, nickname_modal_or)}
|
{t!(i18n, nickname_modal_or)}
|
||||||
" "
|
" "
|
||||||
<A href="/account">{t!(i18n, nickname_modal_sign_in)}</A>
|
<A href="/account">{t!(i18n, nickname_modal_sign_in)}</A>
|
||||||
" · "
|
|
||||||
<A href="/account">{t!(i18n, nickname_modal_register)}</A>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
11
devenv.lock
11
devenv.lock
|
|
@ -3,10 +3,11 @@
|
||||||
"devenv": {
|
"devenv": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "src/modules",
|
"dir": "src/modules",
|
||||||
"lastModified": 1776863933,
|
"lastModified": 1779486363,
|
||||||
|
"narHash": "sha256-6rNmvwTngbmz/j3DGsEYkyakrHHY8N5wgRD9k35HyuM=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "devenv",
|
"repo": "devenv",
|
||||||
"rev": "863b4204725efaeeb73811e376f928232b720646",
|
"rev": "90692720b2ad7a7811204155900bf6bea3a3b420",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -18,10 +19,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1776734388,
|
"lastModified": 1779102034,
|
||||||
|
"narHash": "sha256-vZJZjLo513IeI8hjzHFc6TDezUd4uCE2Eq4SNO3DNNg=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "10e7ad5bbcb421fe07e3a4ad53a634b0cd57ffac",
|
"rev": "687f05a9184cad4eaf905c48b63649e3a86f5433",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -34,6 +36,7 @@
|
||||||
"nixpkgs-cmake3": {
|
"nixpkgs-cmake3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1758213207,
|
"lastModified": 1758213207,
|
||||||
|
"narHash": "sha256-rqoqF0LEi+6ZT59tr+hTQlxVwrzQsET01U4uUdmqRtM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "f4b140d5b253f5e2a1ff4e5506edbf8267724bde",
|
"rev": "f4b140d5b253f5e2a1ff4e5506edbf8267724bde",
|
||||||
|
|
|
||||||
4
justfile
4
justfile
|
|
@ -55,6 +55,10 @@ build-relay:
|
||||||
cp target/release/relay-server deploy
|
cp target/release/relay-server deploy
|
||||||
cp -u server/relay-server/GameConfig.json deploy/
|
cp -u server/relay-server/GameConfig.json deploy/
|
||||||
|
|
||||||
|
# generate web stats report from the current nginx logs
|
||||||
|
stats:
|
||||||
|
ssh -t raspberry sudo goaccess /var/log/nginx/trictrac_access.log --log-format=COMBINED -o html > var/stats/report.html
|
||||||
|
|
||||||
# start a trictrac container with nixos-container
|
# start a trictrac container with nixos-container
|
||||||
# `boot.enableContainers = true` must be set on local nixos system
|
# `boot.enableContainers = true` must be set on local nixos system
|
||||||
local:
|
local:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue