Ajout de la suppression des conversations
continuous-integration/drone/push Build is passing Details

peristanceBDD
Thomas Chazot 2 years ago
parent 070b2624fc
commit d885b09ed8

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

@ -10,6 +10,7 @@ io.on('connection', (socket) => {
console.log(socket.id)
socket.on('signIn', (id) => {
socket.join("U"+id);
});
socket.on('inConv', (conv) => {

@ -1,4 +1,4 @@
const { io } = require("socket.io-client");
export const socket = io("http://172.27.168.231:3000");
export const socket = io("http://172.20.10.2:3000");

@ -139,8 +139,8 @@ export default function TicTacToe(props: { navigation: any}){
setUser(tmp);
}
}
navigation.goBack();
resetMatch();
navigation.goBack();
}
return(

@ -25,8 +25,10 @@ FC<{conv: Conversation, navigation: any}> =
const user1 = MANAGER_USER.getCurrentUser();
let tmp;
if (user1?.isEqual(conv.getTabUser()[0])) tmp = conv.getTabUser()[1];
if (conv.getTabMessage().length<2){
tmp=conv.getTabUser()[0];
}
else if (user1?.isEqual(conv.getTabUser()[0])) tmp = conv.getTabUser()[1];
else tmp = conv.getTabUser()[0];
const user2 = tmp;

@ -13,6 +13,8 @@ import { useMatchStore } from "../context/matchContext"
import { MANAGER_CONVERSATION, MANAGER_USER } from "../../appManagers"
import { useUserStore } from "../context/userContext"
import { useConversationStore } from "../context/conversationContext"
import { socket } from "../../socketConfig"
import { Conversation } from "../core/conversation"
/*
Images required
@ -20,6 +22,7 @@ import { useConversationStore } from "../context/conversationContext"
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
const cross = require('../../assets/Icons/UnSelected/Cross.png');
const msc = require('../../assets/Icons/FondGris.png');
const door = require('../../assets/Icons/UnSelected/Door.png');
export const TopBar :
/* Parameters:
@ -35,6 +38,27 @@ FC<{nav: any, state?: string}> =
const resetMatch = useMatchStore((state) => state.resetMatch);
const resetCurrentConv = useConversationStore((state) => state.resetCurrentConv);
const setTabConv = useConversationStore((state) => state.setTabConv);
async function quitConv(){
const tmp=MANAGER_USER.getCurrentUser();
const tmpConv=MANAGER_CONVERSATION.getCurrentConv();
if (tmp!==null && tmpConv!==null){
await MANAGER_CONVERSATION.getsaverConversation().deleteUserToConversation(tmpConv, tmp);
const trouveIndex = (element: Conversation) => element.getId()===tmpConv.getId();
const index=MANAGER_CONVERSATION.getTabConv().findIndex(trouveIndex);
MANAGER_CONVERSATION.getTabConv().splice(index);
if (tmpConv.getTabUser().length===1){
await MANAGER_CONVERSATION.getsaverConversation().deleteConversation(tmpConv);
}
MANAGER_CONVERSATION.setCurrentConv(null);
setTabConv(MANAGER_CONVERSATION.getTabConv());
socket.emit("messageSent", tmpConv);
nav.goBack();
}
}
/* The display of this component depends of the screen from where it has been called:
* From the Settings (icon) : Name of the page + cross button
@ -74,8 +98,8 @@ FC<{nav: any, state?: string}> =
<Image source={cross} style={styles.icon}/>
</Pressable>
<Text style={styles.titre}>{useConversationStore().currentConv?.getName()}</Text>
<Pressable>
<Image source={msc} style={styles.icon}/>
<Pressable onPress={ () => quitConv()}>
<Image source={door} style={styles.icon}/>
</Pressable>
</View>
)

@ -21,6 +21,10 @@ export default function AddConversation(props: {navigation:any}){
Alert.alert("Everyone needs a name even a conversation :)");
return;
}
if (name.length>50){
Alert.alert("The conversation name should not exceed 30 character");
return;
}
if (listId.trim().length === 0){
Alert.alert("Specify the id of your friends to chat with them :)");
return;

@ -7,6 +7,7 @@ import { BotBar } from '../components/BotBar';
import { Conversation } from '../core/conversation';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import { useMatchStore } from '../context/matchContext';
import { MANAGER_MATCH } from '../../appManagers';
function LobbySolo(props: { navigation: any; }) {
@ -24,7 +25,7 @@ function LobbySolo(props: { navigation: any; }) {
<View style={stylesScreen.bodyCenter}>
<ButtonGameTypeChoice
title='Lancer la partie'
onPress={() => navigation.navigate(match?.getGame().getName().replace(/\s/g, ''))}
onPress={() => navigation.navigate(MANAGER_MATCH.getCurrentMatch()?.getGame().getName().replace(/\s/g, ''))}
/>
</View>

@ -59,17 +59,26 @@ export class SaverConversationApi implements ISaverConversation{
return message;
}
addUserToConversation(c: Conversation, id: number): Promise<void> {
async addUserToConversation(c: Conversation, id: number): Promise<void> {
throw new Error("Method not implemented.");
}
deleteUserToConversation(c: Conversation, u: User): Promise<void> {
throw new Error("Method not implemented.");
async deleteUserToConversation(c: Conversation, u: User): Promise<void> {
let url='http://localhost:8888/api-rest/index.php/deleteUserFromConversation/' + c.getId() + "/" +u.getId();
await this.axios({
method: 'put',
url: url,
});
}
async deleteConversation(c: Conversation): Promise<void> {
return;
let url='http://localhost:8888/api-rest/index.php/deleteConversation/' + c.getId();
await this.axios({
method: 'delete',
url: url,
});
}
async updateConversation(c: Conversation): Promise<void> {
return;
}

Loading…
Cancel
Save