can invite to play a game in chat
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { lastView, navigateTo } from '../../index.js';
|
||||
import Search from '../../views/Search.js';
|
||||
|
||||
export default class Ask {
|
||||
constructor(client) {
|
||||
@ -10,16 +12,19 @@ export default class Ask {
|
||||
});
|
||||
}
|
||||
|
||||
async ask_game_canceled() {
|
||||
|
||||
}
|
||||
|
||||
async ask_game_accepted(asker) {
|
||||
let response = await this.client._post(`/api/chat/ask/accept`, {
|
||||
let response = await this.client._post(`/api/chat/ask/accept/`, {
|
||||
asker:asker,
|
||||
});
|
||||
|
||||
console.log(response.status);
|
||||
const statu = response.status;
|
||||
if (statu == 404 || statu == 204)
|
||||
return
|
||||
if (lastView instanceof Search)
|
||||
lastView.display_invite();
|
||||
|
||||
const data = await response.json();
|
||||
await navigateTo(`/games/pong/${data.id_game}`);
|
||||
}
|
||||
|
||||
async ask_game_refused(asker) {
|
||||
@ -27,14 +32,17 @@ export default class Ask {
|
||||
asker:asker,
|
||||
});
|
||||
|
||||
console.log(response.status);
|
||||
const statu = response.status;
|
||||
if (statu == 404 || statu == 204)
|
||||
return
|
||||
if (lastView instanceof Search)
|
||||
lastView.display_invite();
|
||||
}
|
||||
|
||||
async is_asked(asked) {
|
||||
let response = await this.client._get(`/api/chat/ask/${asked}`);
|
||||
|
||||
const statu = response.status;
|
||||
console.log(statu);
|
||||
if (statu == 404 || statu == 204)
|
||||
return false;
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user