Skip to content

Commit cf33c37

Browse files
committed
Improve handling of stopped matches:
- Enable to change game server of matches which are not live (to get them running again) - Add possibility to stop dangling matches (matches which are not live but have not been stopped properly) - UI: Add filter to match list for dangling matches - UI: Show error messages at various places when the request to the backend fails (chat, rcon and others)
1 parent 5e32da4 commit cf33c37

File tree

12 files changed

+669
-525
lines changed

12 files changed

+669
-525
lines changed

backend/src/matchService.ts

+10
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ export const remove = async (id: string) => {
163163
}
164164
};
165165

166+
export const removeStopped = async (id: string) => {
167+
const matchFromStorage = await getFromStorage(id);
168+
if (!matchFromStorage) {
169+
return false;
170+
}
171+
matchFromStorage.isStopped = true;
172+
await save(matchFromStorage);
173+
return true;
174+
};
175+
166176
export const revive = async (id: string) => {
167177
const match = matches.get(id);
168178
if (match) {

backend/src/matchesController.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ export class MatchesController extends Controller {
175175
const match = MatchService.get(id);
176176
if (match) {
177177
await Match.update(match, requestBody);
178+
} else if (requestBody.gameServer) {
179+
// for offline matches only allow to update game server to get match running again
180+
const offlineMatch = await MatchService.getFromStorage(id);
181+
if (offlineMatch) {
182+
offlineMatch.gameServer = requestBody.gameServer;
183+
await MatchService.save(offlineMatch);
184+
}
178185
} else {
179186
this.setStatus(404);
180187
}
@@ -209,7 +216,9 @@ export class MatchesController extends Controller {
209216
@Delete('{id}')
210217
async deleteMatch(id: string, @Request() req: ExpressRequest<IAuthResponse>): Promise<void> {
211218
if (!(await MatchService.remove(id))) {
212-
this.setStatus(404);
219+
if (!(await MatchService.removeStopped(id))) {
220+
this.setStatus(404);
221+
}
213222
}
214223
}
215224

backend/swagger.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,8 @@
11671167
"description": "Match mode (single: stops when match is finished, loop: starts again after match is finished)"
11681168
},
11691169
"isLive": {
1170-
"type": "boolean"
1170+
"type": "boolean",
1171+
"description": "Match is currently supervised."
11711172
}
11721173
},
11731174
"required": [

common/types/match.ts

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export interface IMatch {
115115
}
116116

117117
export interface IMatchResponse extends IMatch {
118+
/** Match is currently supervised. */
118119
isLive: boolean;
119120
}
120121

frontend/src/components/Chat.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import { Component } from 'solid-js';
1+
import { Component, createSignal } from 'solid-js';
22
import { ChatEvent } from '../../../common';
33
import { t } from '../utils/locale';
44
import { onEnter } from '../utils/onEnter';
55
import { Card } from './Card';
6-
import { ScrollArea } from './ScrollArea';
6+
import { ErrorComponent } from './ErrorComponent';
77
import { TextInput } from './Inputs';
8+
import { ScrollArea } from './ScrollArea';
89

910
export const Chat: Component<{
1011
messages: ChatEvent[];
11-
sendMessage: (msg: string) => void;
12+
sendMessage: (msg: string) => Promise<any>;
1213
}> = (props) => {
14+
const [errorMessage, setErrorMessage] = createSignal('');
1315
return (
1416
<Card class="text-center">
1517
<h2 class="text-lg font-bold">{t('Chat')}</h2>
@@ -18,14 +20,21 @@ export const Chat: Component<{
1820
<TextInput
1921
type="text"
2022
onKeyDown={onEnter((e) => {
21-
const msg = e.currentTarget.value.trim();
23+
const input = e.currentTarget;
24+
const msg = input.value.trim();
2225
if (msg) {
23-
props.sendMessage(msg);
24-
e.currentTarget.value = '';
26+
props
27+
.sendMessage(msg)
28+
.then(() => {
29+
input.value = '';
30+
setErrorMessage('');
31+
})
32+
.catch((err) => setErrorMessage(err + ''));
2533
}
2634
})}
2735
placeholder={t('Send chat message...')}
2836
/>
37+
<ErrorComponent errorMessage={errorMessage()} />
2938
</Card>
3039
);
3140
};

0 commit comments

Comments
 (0)