Compare commits
5 Commits
0.2.1
...
1e6cd34f61
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e6cd34f61 | |||
| 70a4debb40 | |||
| 61000f8a22 | |||
| f98bcfd956 | |||
| 6d1e06dfd6 |
@@ -28,3 +28,13 @@
|
|||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* NCWF-1 401 ([#5](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/issues/5)) ([f8f93ef](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/f8f93efff48f1d7198023fed45b675c2e225df36))
|
* NCWF-1 401 ([#5](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/issues/5)) ([f8f93ef](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/f8f93efff48f1d7198023fed45b675c2e225df36))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/compare/0.2.1...0.0.0) (2026-05-12)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* NCWF-1 401 ([#6](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/issues/6)) ([6d1e06d](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/6d1e06dfd606b93d029e9c9b84eea6f8b3b6294e))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/compare/0.2.2...0.0.0) (2026-05-14)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* added missing challenge routes ([61000f8](https://git.janis-eccarius.de/NowChess/NowChess-Frontend/commit/61000f8a22aff8b524664a756cc933834365f923))
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import { Routes } from '@angular/router';
|
|||||||
import { GameComponent } from './pages/game/game.component';
|
import { GameComponent } from './pages/game/game.component';
|
||||||
import { WelcomeComponent } from './pages/welcome/welcome.component';
|
import { WelcomeComponent } from './pages/welcome/welcome.component';
|
||||||
import { ProfileComponent } from './pages/profile/profile.component';
|
import { ProfileComponent } from './pages/profile/profile.component';
|
||||||
|
import { ChallengesComponent } from './pages/challenges/challenges.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', component: WelcomeComponent },
|
{ path: '', component: WelcomeComponent },
|
||||||
{ path: 'profile', component: ProfileComponent },
|
{ path: 'profile', component: ProfileComponent },
|
||||||
|
{ path: 'challenges', component: ChallengesComponent },
|
||||||
{ path: 'game/:gameId', component: GameComponent },
|
{ path: 'game/:gameId', component: GameComponent },
|
||||||
{ path: '**', redirectTo: '' }
|
{ path: '**', redirectTo: '' }
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input, Output, EventEmitter, inject } from '@angular/core';
|
import { Component, Input, Output, EventEmitter, inject } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import { Challenge } from '../../models/challenge.models';
|
import { Challenge } from '../../models/challenge.models';
|
||||||
import { ChallengeService } from '../../services/challenge.service';
|
import { ChallengeService } from '../../services/challenge.service';
|
||||||
import { finalize } from 'rxjs';
|
import { finalize } from 'rxjs';
|
||||||
@@ -19,6 +20,7 @@ export class ChallengeNotificationComponent {
|
|||||||
@Output() close = new EventEmitter<void>();
|
@Output() close = new EventEmitter<void>();
|
||||||
|
|
||||||
private readonly challengeService = inject(ChallengeService);
|
private readonly challengeService = inject(ChallengeService);
|
||||||
|
private readonly router = inject(Router);
|
||||||
|
|
||||||
acceptingChallenge = false;
|
acceptingChallenge = false;
|
||||||
decliningChallenge = false;
|
decliningChallenge = false;
|
||||||
@@ -35,8 +37,13 @@ export class ChallengeNotificationComponent {
|
|||||||
this.challengeService.acceptChallenge(this.challenge.id)
|
this.challengeService.acceptChallenge(this.challenge.id)
|
||||||
.pipe(finalize(() => (this.acceptingChallenge = false)))
|
.pipe(finalize(() => (this.acceptingChallenge = false)))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: (acceptedChallenge) => {
|
||||||
this.accept.emit(this.challenge);
|
this.accept.emit(acceptedChallenge);
|
||||||
|
if (acceptedChallenge.gameId) {
|
||||||
|
void this.router.navigate(['/game', acceptedChallenge.gameId]);
|
||||||
|
} else {
|
||||||
|
this.errorMessage = 'Challenge accepted, but no game was created.';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
this.errorMessage = getErrorMessage(error, 'Failed to accept challenge');
|
this.errorMessage = getErrorMessage(error, 'Failed to accept challenge');
|
||||||
|
|||||||
@@ -0,0 +1,700 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>NowChess Nav — Logged In</title>
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* ============ TOKENS ============ */
|
||||||
|
:root {
|
||||||
|
--neon: #ff45c8;
|
||||||
|
--neon-soft: rgba(255, 69, 200, 0.55);
|
||||||
|
--neon-glow: 0 0 6px var(--neon);
|
||||||
|
--bg: #06060d;
|
||||||
|
--text: #fff;
|
||||||
|
--text-muted: rgba(255, 255, 255, 0.65);
|
||||||
|
--text-dim: rgba(255, 255, 255, 0.45);
|
||||||
|
--border: rgba(255, 255, 255, 0.08);
|
||||||
|
--surface: rgba(10, 8, 22, 0.95);
|
||||||
|
--warning: #ffb13a;
|
||||||
|
--danger: #ff7a7a;
|
||||||
|
--sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
html, body {
|
||||||
|
margin: 0; padding: 0;
|
||||||
|
background: var(--bg);
|
||||||
|
font-family: var(--sans);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
button { font-family: inherit; }
|
||||||
|
|
||||||
|
/* ============ NAV CONTAINER ============ */
|
||||||
|
.nc-nav {
|
||||||
|
position: fixed;
|
||||||
|
top: 0; left: 0; right: 0;
|
||||||
|
height: 56px;
|
||||||
|
z-index: 100;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 24px;
|
||||||
|
background: linear-gradient(180deg, rgba(8,5,20,0.85) 0%, rgba(8,5,20,0.55) 70%, rgba(8,5,20,0) 100%);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============ LOGO ============ */
|
||||||
|
.nc-logo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
.nc-logo-mark {
|
||||||
|
width: 22px; height: 22px;
|
||||||
|
background: var(--neon);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-weight: 800;
|
||||||
|
color: #1a0014;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.nc-logo-text {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ============ NAV LINKS (center) ============ */
|
||||||
|
.nc-links {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
.nc-link {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
padding: 8px 14px;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
position: relative;
|
||||||
|
transition: color 0.15s;
|
||||||
|
}
|
||||||
|
.nc-link:hover { color: var(--text); }
|
||||||
|
.nc-link::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
bottom: 2px; left: 14px; right: 14px;
|
||||||
|
height: 1px;
|
||||||
|
background: var(--neon);
|
||||||
|
box-shadow: var(--neon-glow);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s;
|
||||||
|
}
|
||||||
|
.nc-link:hover::after { opacity: 1; }
|
||||||
|
|
||||||
|
/* ============ RIGHT CLUSTER ============ */
|
||||||
|
.nc-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bell button */
|
||||||
|
.nc-bell {
|
||||||
|
width: 36px; height: 36px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(255,255,255,0.85);
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
transition: background 0.15s;
|
||||||
|
}
|
||||||
|
.nc-bell:hover,
|
||||||
|
.nc-bell.is-open {
|
||||||
|
background: rgba(255, 69, 200, 0.12);
|
||||||
|
}
|
||||||
|
.nc-badge {
|
||||||
|
position: absolute;
|
||||||
|
top: 6px; right: 6px;
|
||||||
|
min-width: 14px; height: 14px;
|
||||||
|
border-radius: 7px;
|
||||||
|
background: var(--neon);
|
||||||
|
color: #1a0014;
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 700;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0 4px;
|
||||||
|
box-shadow: 0 0 6px rgba(255,69,200,0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Profile button */
|
||||||
|
.nc-profile {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 4px 10px 4px 4px;
|
||||||
|
height: 36px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
color: rgba(255,255,255,0.85);
|
||||||
|
transition: background 0.15s;
|
||||||
|
}
|
||||||
|
.nc-profile:hover,
|
||||||
|
.nc-profile.is-open {
|
||||||
|
background: rgba(255, 69, 200, 0.12);
|
||||||
|
}
|
||||||
|
.nc-profile-name {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
}
|
||||||
|
.nc-profile .nc-chevron { opacity: 0.5; }
|
||||||
|
|
||||||
|
/* Avatar */
|
||||||
|
.nc-avatar {
|
||||||
|
border-radius: 50%;
|
||||||
|
background: linear-gradient(135deg, #ff45c8 0%, #7a2fd6 100%);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.nc-avatar-sm { width: 26px; height: 26px; font-size: 11px; }
|
||||||
|
.nc-avatar-md { width: 40px; height: 40px; font-size: 17px; }
|
||||||
|
|
||||||
|
/* ============ POPOVERS ============ */
|
||||||
|
.nc-popover {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 10px);
|
||||||
|
right: 0;
|
||||||
|
background: var(--surface);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
-webkit-backdrop-filter: blur(20px);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255, 69, 200, 0.15);
|
||||||
|
z-index: 200;
|
||||||
|
overflow: hidden;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.nc-popover.is-open { display: block; }
|
||||||
|
|
||||||
|
.nc-dropdown-wrap { position: relative; }
|
||||||
|
|
||||||
|
/* Notifications popover */
|
||||||
|
.nc-notif { width: 360px; }
|
||||||
|
.nc-notif-header {
|
||||||
|
padding: 14px 18px;
|
||||||
|
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.nc-notif-header-title {
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: 0.22em;
|
||||||
|
color: rgba(255,255,255,0.85);
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.nc-mark-all {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: var(--neon);
|
||||||
|
font-size: 10px;
|
||||||
|
letter-spacing: 0.18em;
|
||||||
|
cursor: pointer;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.nc-notif-list {
|
||||||
|
max-height: 420px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.nc-notif-row {
|
||||||
|
padding: 14px 18px;
|
||||||
|
border-bottom: 1px solid rgba(255,255,255,0.04);
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
.nc-notif-row.is-unread { background: rgba(255, 69, 200, 0.04); }
|
||||||
|
.nc-notif-row.is-unread::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 8px; top: 22px;
|
||||||
|
width: 4px; height: 4px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--neon);
|
||||||
|
box-shadow: 0 0 6px var(--neon);
|
||||||
|
}
|
||||||
|
.nc-notif-row.kind-warning.is-unread::before {
|
||||||
|
background: var(--warning);
|
||||||
|
box-shadow: 0 0 6px var(--warning);
|
||||||
|
}
|
||||||
|
.nc-notif-icon {
|
||||||
|
width: 32px; height: 32px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
border: 1px solid rgba(255, 69, 200, 0.25);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--neon);
|
||||||
|
}
|
||||||
|
.nc-notif-row.kind-warning .nc-notif-icon {
|
||||||
|
border-color: rgba(255, 177, 58, 0.25);
|
||||||
|
color: var(--warning);
|
||||||
|
}
|
||||||
|
.nc-notif-body { flex: 1; min-width: 0; }
|
||||||
|
.nc-notif-text {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #fff;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
.nc-notif-text b { font-weight: 600; }
|
||||||
|
.nc-notif-meta {
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--text-dim);
|
||||||
|
margin-top: 4px;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
.nc-notif-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.nc-btn-accept,
|
||||||
|
.nc-btn-decline,
|
||||||
|
.nc-btn-resume {
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 10px;
|
||||||
|
letter-spacing: 0.18em;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 600;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.nc-btn-accept {
|
||||||
|
background: var(--neon);
|
||||||
|
color: #1a0014;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.nc-btn-decline {
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(255,255,255,0.7);
|
||||||
|
border: 1px solid rgba(255,255,255,0.15);
|
||||||
|
}
|
||||||
|
.nc-btn-resume {
|
||||||
|
background: rgba(255, 177, 58, 0.15);
|
||||||
|
color: var(--warning);
|
||||||
|
border: 1px solid rgba(255, 177, 58, 0.4);
|
||||||
|
}
|
||||||
|
.nc-notif-footer {
|
||||||
|
padding: 10px 18px;
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.06);
|
||||||
|
}
|
||||||
|
.nc-view-all {
|
||||||
|
width: 100%;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: rgba(255,255,255,0.55);
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: 0.2em;
|
||||||
|
cursor: pointer;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Profile menu */
|
||||||
|
.nc-menu { width: 250px; }
|
||||||
|
.nc-menu-header {
|
||||||
|
padding: 16px 16px 14px;
|
||||||
|
border-bottom: 1px solid rgba(255,255,255,0.06);
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.nc-menu-user-name {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.nc-menu-user-sub {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-dim);
|
||||||
|
margin-top: 2px;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
}
|
||||||
|
.nc-menu-group {
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
.nc-menu-group + .nc-menu-group {
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.06);
|
||||||
|
}
|
||||||
|
.nc-menu-item {
|
||||||
|
padding: 9px 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
color: rgba(255,255,255,0.85);
|
||||||
|
font-size: 13px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
transition: background 0.12s, color 0.12s;
|
||||||
|
}
|
||||||
|
.nc-menu-item:hover {
|
||||||
|
background: rgba(255, 69, 200, 0.08);
|
||||||
|
color: var(--neon);
|
||||||
|
}
|
||||||
|
.nc-menu-item.danger { color: var(--danger); }
|
||||||
|
.nc-menu-item .nc-menu-icon { opacity: 0.85; display: inline-flex; }
|
||||||
|
.nc-menu-item .nc-menu-label { flex: 1; }
|
||||||
|
|
||||||
|
/* Dark mode toggle pill */
|
||||||
|
.nc-toggle {
|
||||||
|
width: 28px; height: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255,255,255,0.15);
|
||||||
|
position: relative;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
.nc-toggle.is-on { background: var(--neon); }
|
||||||
|
.nc-toggle::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: 2px; left: 2px;
|
||||||
|
width: 12px; height: 12px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #fff;
|
||||||
|
transition: left 0.2s;
|
||||||
|
}
|
||||||
|
.nc-toggle.is-on::after { left: 14px; }
|
||||||
|
|
||||||
|
/* Scrollbar */
|
||||||
|
::-webkit-scrollbar { width: 8px; height: 8px; }
|
||||||
|
::-webkit-scrollbar-track { background: transparent; }
|
||||||
|
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
|
||||||
|
::-webkit-scrollbar-thumb:hover { background: rgba(255,69,200,0.3); }
|
||||||
|
|
||||||
|
/* Demo background so the transparent nav reads */
|
||||||
|
.demo-bg {
|
||||||
|
position: fixed; inset: 0;
|
||||||
|
background: linear-gradient(180deg, #1a1838 0%, #2e2050 25%, #4a2962 45%, #8b3a6b 65%, #d44d4a 85%, #ff6b3d 100%);
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Demo background (remove when embedding) -->
|
||||||
|
<div class="demo-bg"></div>
|
||||||
|
|
||||||
|
<!-- ============================================================
|
||||||
|
NAV — LOGGED IN
|
||||||
|
============================================================ -->
|
||||||
|
<nav class="nc-nav">
|
||||||
|
|
||||||
|
<!-- Logo -->
|
||||||
|
<div class="nc-logo">
|
||||||
|
<div class="nc-logo-mark">♞</div>
|
||||||
|
<div class="nc-logo-text">NowChess</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Center links -->
|
||||||
|
<div class="nc-links">
|
||||||
|
<button class="nc-link">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
|
||||||
|
<circle cx="12" cy="12" r="3"/>
|
||||||
|
</svg>
|
||||||
|
Watch
|
||||||
|
</button>
|
||||||
|
<button class="nc-link">Leaderboard</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Right cluster -->
|
||||||
|
<div class="nc-right">
|
||||||
|
|
||||||
|
<!-- Notifications -->
|
||||||
|
<div class="nc-dropdown-wrap" data-dropdown="notif">
|
||||||
|
<button class="nc-bell" data-trigger="notif" aria-label="Notifications">
|
||||||
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/>
|
||||||
|
<path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>
|
||||||
|
</svg>
|
||||||
|
<span class="nc-badge" data-unread-count>3</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="nc-popover nc-notif" data-panel="notif">
|
||||||
|
<div class="nc-notif-header">
|
||||||
|
<div class="nc-notif-header-title">Notifications</div>
|
||||||
|
<button class="nc-mark-all" data-action="mark-all">Mark all read</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nc-notif-list">
|
||||||
|
<!-- Challenge -->
|
||||||
|
<div class="nc-notif-row kind-challenge is-unread" data-notif-id="1">
|
||||||
|
<div class="nc-notif-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<line x1="14.5" y1="17.5" x2="3" y2="6"/>
|
||||||
|
<path d="M13 19l6 -6"/><path d="M16 16l4 4"/>
|
||||||
|
<path d="M19 21l2 -2"/><path d="M15 5l4 4"/>
|
||||||
|
<path d="M21 3l-3 1l-4 4"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="nc-notif-body">
|
||||||
|
<div class="nc-notif-text"><b>magnus_42</b> challenged you to a 10|0 rapid game.</div>
|
||||||
|
<div class="nc-notif-meta">1840 · Rapid · 2m</div>
|
||||||
|
<div class="nc-notif-actions">
|
||||||
|
<button class="nc-btn-accept" data-action="accept">
|
||||||
|
<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
|
||||||
|
Accept
|
||||||
|
</button>
|
||||||
|
<button class="nc-btn-decline" data-action="decline">
|
||||||
|
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||||
|
Decline
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Time warning -->
|
||||||
|
<div class="nc-notif-row kind-warning is-unread" data-notif-id="2">
|
||||||
|
<div class="nc-notif-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<circle cx="12" cy="12" r="9"/>
|
||||||
|
<polyline points="12 7 12 12 15 14"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="nc-notif-body">
|
||||||
|
<div class="nc-notif-text"><b>Your turn</b> in game vs. blitz_kai — 38s left on your clock.</div>
|
||||||
|
<div class="nc-notif-meta">Blitz · 3|2 · now</div>
|
||||||
|
<div class="nc-notif-actions">
|
||||||
|
<button class="nc-btn-resume">Resume game →</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Challenge 2 -->
|
||||||
|
<div class="nc-notif-row kind-challenge is-unread" data-notif-id="3">
|
||||||
|
<div class="nc-notif-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<line x1="14.5" y1="17.5" x2="3" y2="6"/>
|
||||||
|
<path d="M13 19l6 -6"/><path d="M16 16l4 4"/>
|
||||||
|
<path d="M19 21l2 -2"/><path d="M15 5l4 4"/>
|
||||||
|
<path d="M21 3l-3 1l-4 4"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="nc-notif-body">
|
||||||
|
<div class="nc-notif-text"><b>rookjumper</b> wants a rematch — 5|3 blitz.</div>
|
||||||
|
<div class="nc-notif-meta">1755 · Blitz · 12m</div>
|
||||||
|
<div class="nc-notif-actions">
|
||||||
|
<button class="nc-btn-accept" data-action="accept">Accept</button>
|
||||||
|
<button class="nc-btn-decline" data-action="decline">Decline</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Read notification -->
|
||||||
|
<div class="nc-notif-row kind-challenge" data-notif-id="4">
|
||||||
|
<div class="nc-notif-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<line x1="14.5" y1="17.5" x2="3" y2="6"/>
|
||||||
|
<path d="M13 19l6 -6"/><path d="M16 16l4 4"/>
|
||||||
|
<path d="M19 21l2 -2"/><path d="M15 5l4 4"/>
|
||||||
|
<path d="M21 3l-3 1l-4 4"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="nc-notif-body">
|
||||||
|
<div class="nc-notif-text"><b>queens_gambit</b> challenged you to a casual game.</div>
|
||||||
|
<div class="nc-notif-meta">Unrated · 1h</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nc-notif-footer">
|
||||||
|
<button class="nc-view-all">View all activity</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Profile -->
|
||||||
|
<div class="nc-dropdown-wrap" data-dropdown="profile">
|
||||||
|
<button class="nc-profile" data-trigger="profile">
|
||||||
|
<div class="nc-avatar nc-avatar-sm">S</div>
|
||||||
|
<span class="nc-profile-name">Sha</span>
|
||||||
|
<svg class="nc-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<polyline points="6 9 12 15 18 9"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="nc-popover nc-menu" data-panel="profile">
|
||||||
|
<div class="nc-menu-header">
|
||||||
|
<div class="nc-avatar nc-avatar-md">S</div>
|
||||||
|
<div>
|
||||||
|
<div class="nc-menu-user-name">Sha</div>
|
||||||
|
<div class="nc-menu-user-sub">1842 · @sha</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nc-menu-group">
|
||||||
|
<button class="nc-menu-item">
|
||||||
|
<span class="nc-menu-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
|
||||||
|
<circle cx="12" cy="7" r="4"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="nc-menu-label">My profile</span>
|
||||||
|
</button>
|
||||||
|
<button class="nc-menu-item">
|
||||||
|
<span class="nc-menu-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<line x1="14.5" y1="17.5" x2="3" y2="6"/>
|
||||||
|
<path d="M13 19l6 -6"/><path d="M16 16l4 4"/>
|
||||||
|
<path d="M19 21l2 -2"/><path d="M15 5l4 4"/>
|
||||||
|
<path d="M21 3l-3 1l-4 4"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="nc-menu-label">Game history</span>
|
||||||
|
</button>
|
||||||
|
<button class="nc-menu-item">
|
||||||
|
<span class="nc-menu-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<circle cx="12" cy="12" r="3"/>
|
||||||
|
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="nc-menu-label">Settings</span>
|
||||||
|
</button>
|
||||||
|
<button class="nc-menu-item" data-action="toggle-dark">
|
||||||
|
<span class="nc-menu-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="nc-menu-label" data-dark-label>Light mode</span>
|
||||||
|
<span class="nc-toggle is-on" data-dark-toggle></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="nc-menu-group">
|
||||||
|
<button class="nc-menu-item danger">
|
||||||
|
<span class="nc-menu-icon">
|
||||||
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
|
||||||
|
<polyline points="16 17 21 12 16 7"/>
|
||||||
|
<line x1="21" y1="12" x2="9" y2="12"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
<span class="nc-menu-label">Log out</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/* ============ DROPDOWN BEHAVIOR ============ */
|
||||||
|
(() => {
|
||||||
|
const wraps = document.querySelectorAll('[data-dropdown]');
|
||||||
|
const triggers = document.querySelectorAll('[data-trigger]');
|
||||||
|
|
||||||
|
const closeAll = () => {
|
||||||
|
document.querySelectorAll('.nc-popover.is-open').forEach(p => p.classList.remove('is-open'));
|
||||||
|
document.querySelectorAll('[data-trigger].is-open').forEach(t => t.classList.remove('is-open'));
|
||||||
|
};
|
||||||
|
|
||||||
|
triggers.forEach(trigger => {
|
||||||
|
trigger.addEventListener('click', e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const name = trigger.dataset.trigger;
|
||||||
|
const panel = document.querySelector(`[data-panel="${name}"]`);
|
||||||
|
const isOpen = panel.classList.contains('is-open');
|
||||||
|
closeAll();
|
||||||
|
if (!isOpen) {
|
||||||
|
panel.classList.add('is-open');
|
||||||
|
trigger.classList.add('is-open');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('click', e => {
|
||||||
|
if (!e.target.closest('[data-dropdown]')) closeAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('keydown', e => {
|
||||||
|
if (e.key === 'Escape') closeAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ============ NOTIFICATION ACTIONS ============ */
|
||||||
|
const updateBadge = () => {
|
||||||
|
const unread = document.querySelectorAll('.nc-notif-row.is-unread').length;
|
||||||
|
const badge = document.querySelector('[data-unread-count]');
|
||||||
|
if (unread === 0) { badge.style.display = 'none'; }
|
||||||
|
else { badge.style.display = ''; badge.textContent = unread; }
|
||||||
|
};
|
||||||
|
|
||||||
|
document.querySelector('[data-action="mark-all"]')?.addEventListener('click', () => {
|
||||||
|
document.querySelectorAll('.nc-notif-row.is-unread').forEach(r => r.classList.remove('is-unread'));
|
||||||
|
updateBadge();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('.nc-notif-row [data-action="accept"], .nc-notif-row [data-action="decline"]').forEach(btn => {
|
||||||
|
btn.addEventListener('click', e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
btn.closest('.nc-notif-row')?.remove();
|
||||||
|
updateBadge();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ============ DARK MODE TOGGLE ============ */
|
||||||
|
document.querySelector('[data-action="toggle-dark"]')?.addEventListener('click', e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const toggle = document.querySelector('[data-dark-toggle]');
|
||||||
|
const label = document.querySelector('[data-dark-label]');
|
||||||
|
const on = toggle.classList.toggle('is-on');
|
||||||
|
label.textContent = on ? 'Light mode' : 'Dark mode';
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -263,6 +263,14 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (showChallengeDialog) {
|
||||||
|
<div class="dialog-overlay" (click)="closeChallengeDialog()">
|
||||||
|
<div class="dialog-card" (click)="$event.stopPropagation()">
|
||||||
|
<app-challenge-create-dialog (closeChallengeDialog)="closeChallengeDialog()"></app-challenge-create-dialog>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
@if (errorMessage) {
|
@if (errorMessage) {
|
||||||
<p class="error-banner">{{ errorMessage }}</p>
|
<p class="error-banner">{{ errorMessage }}</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
|||||||
showOptionsDialog = false;
|
showOptionsDialog = false;
|
||||||
showJoinDialog = false;
|
showJoinDialog = false;
|
||||||
showImportDialog = false;
|
showImportDialog = false;
|
||||||
|
showChallengeDialog = false;
|
||||||
|
|
||||||
gameIdInput = '';
|
gameIdInput = '';
|
||||||
importMode: ImportMode = 'fen';
|
importMode: ImportMode = 'fen';
|
||||||
@@ -223,11 +224,21 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startOneVsOne(): void {
|
startOneVsOne(): void {
|
||||||
if (!this.requireAuth(() => this.performStartOneVsOne())) {
|
if (!this.requireAuth(() => this.openChallengeDialog())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.performStartOneVsOne();
|
this.openChallengeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
openChallengeDialog(): void {
|
||||||
|
this.closeAllDialogs();
|
||||||
|
this.showChallengeDialog = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeChallengeDialog(): void {
|
||||||
|
this.showChallengeDialog = false;
|
||||||
|
this.errorMessage = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
startVsBot(difficulty: Difficulty): void {
|
startVsBot(difficulty: Difficulty): void {
|
||||||
@@ -352,28 +363,6 @@ export class WelcomeComponent implements OnInit, OnDestroy {
|
|||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
|
||||||
private performStartOneVsOne(): void {
|
|
||||||
if (this.creating) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.errorMessage = '';
|
|
||||||
this.creating = true;
|
|
||||||
|
|
||||||
this.gameApi
|
|
||||||
.createGame()
|
|
||||||
.pipe(finalize(() => (this.creating = false)))
|
|
||||||
.subscribe({
|
|
||||||
next: (game) => {
|
|
||||||
void this.router.navigate(['/game', game.gameId], {
|
|
||||||
state: { theme: this.isSunsetMode ? 'light' : 'dark' }
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
this.errorMessage = getErrorMessage(error, 'Unable to create a game.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private performStartVsBot(difficulty: Difficulty): void {
|
private performStartVsBot(difficulty: Difficulty): void {
|
||||||
if (this.creating) {
|
if (this.creating) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export class GameStreamService {
|
|||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private streamSubscription: Subscription | null = null;
|
private streamSubscription: Subscription | null = null;
|
||||||
private pollSubscription: Subscription | null = null;
|
private pollSubscription: Subscription | null = null;
|
||||||
|
private lastGameStateHash: string | null = null;
|
||||||
|
|
||||||
startStreaming(
|
startStreaming(
|
||||||
gameId: string,
|
gameId: string,
|
||||||
@@ -20,7 +21,10 @@ export class GameStreamService {
|
|||||||
.streamGame(gameId)
|
.streamGame(gameId)
|
||||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (event) => onEvent(event),
|
next: (event) => {
|
||||||
|
this.lastGameStateHash = JSON.stringify(event);
|
||||||
|
onEvent(event);
|
||||||
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
onStreamError();
|
onStreamError();
|
||||||
this.startPolling(gameId, onEvent);
|
this.startPolling(gameId, onEvent);
|
||||||
@@ -37,7 +41,7 @@ export class GameStreamService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pollSubscription = interval(1500)
|
this.pollSubscription = interval(5000)
|
||||||
.pipe(
|
.pipe(
|
||||||
startWith(0),
|
startWith(0),
|
||||||
switchMap(() => this.gameApi.getGame(gameId)),
|
switchMap(() => this.gameApi.getGame(gameId)),
|
||||||
@@ -45,11 +49,16 @@ export class GameStreamService {
|
|||||||
)
|
)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (game) => {
|
next: (game) => {
|
||||||
const event: GameStreamEvent = {
|
// Only emit if game state changed to avoid unnecessary updates
|
||||||
type: 'gameFull',
|
const stateHash = JSON.stringify(game.state);
|
||||||
game
|
if (this.lastGameStateHash !== stateHash) {
|
||||||
};
|
this.lastGameStateHash = stateHash;
|
||||||
onEvent(event);
|
const event: GameStreamEvent = {
|
||||||
|
type: 'gameFull',
|
||||||
|
game
|
||||||
|
};
|
||||||
|
onEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -59,5 +68,6 @@ export class GameStreamService {
|
|||||||
this.pollSubscription?.unsubscribe();
|
this.pollSubscription?.unsubscribe();
|
||||||
this.streamSubscription = null;
|
this.streamSubscription = null;
|
||||||
this.pollSubscription = null;
|
this.pollSubscription = null;
|
||||||
|
this.lastGameStateHash = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,19 @@ export class StreamHandlerService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set timeout to fallback if WebSocket doesn't connect quickly
|
||||||
|
const connectionTimeoutId = setTimeout(() => {
|
||||||
|
if (!connected && !fallbackActive) {
|
||||||
|
console.warn(`[StreamHandler] WebSocket timeout for ${gameId}, attempting NDJSON fallback`);
|
||||||
|
ws.close();
|
||||||
|
void startNdjsonFallback();
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
connected = true;
|
connected = true;
|
||||||
|
clearTimeout(connectionTimeoutId);
|
||||||
|
console.log(`[StreamHandler] WebSocket connected for ${gameId}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onmessage = (message) => {
|
ws.onmessage = (message) => {
|
||||||
@@ -97,19 +108,23 @@ export class StreamHandlerService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ws.onerror = (error) => {
|
ws.onerror = (error) => {
|
||||||
console.warn(`[StreamHandler] WebSocket error for ${gameId}, attempting NDJSON fallback:`, error);
|
console.warn(`[StreamHandler] WebSocket error for ${gameId}:`, error);
|
||||||
if (!connected) {
|
clearTimeout(connectionTimeoutId);
|
||||||
|
if (!connected && !fallbackActive) {
|
||||||
void startNdjsonFallback();
|
void startNdjsonFallback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onclose = () => {
|
ws.onclose = () => {
|
||||||
|
clearTimeout(connectionTimeoutId);
|
||||||
console.warn(`[StreamHandler] WebSocket closed for ${gameId}, connected=${connected}`);
|
console.warn(`[StreamHandler] WebSocket closed for ${gameId}, connected=${connected}`);
|
||||||
if (!connected) {
|
if (connected) {
|
||||||
|
// Connection was established but closed, stream is complete
|
||||||
|
observer.complete();
|
||||||
|
} else if (!fallbackActive) {
|
||||||
|
// Connection never established, try fallback
|
||||||
console.log(`[StreamHandler] Starting NDJSON fallback for ${gameId}`);
|
console.log(`[StreamHandler] Starting NDJSON fallback for ${gameId}`);
|
||||||
void startNdjsonFallback();
|
void startNdjsonFallback();
|
||||||
} else {
|
|
||||||
observer.complete();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
MAJOR=0
|
MAJOR=0
|
||||||
MINOR=2
|
MINOR=2
|
||||||
PATCH=1
|
PATCH=3
|
||||||
|
|||||||
Reference in New Issue
Block a user