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) console.log(socket.id)
socket.on('signIn', (id) => { socket.on('signIn', (id) => {
socket.join("U"+id);
}); });
socket.on('inConv', (conv) => { socket.on('inConv', (conv) => {

@ -1,4 +1,4 @@
const { io } = require("socket.io-client"); 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); setUser(tmp);
} }
} }
navigation.goBack();
resetMatch(); resetMatch();
navigation.goBack();
} }
return( return(

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

@ -13,6 +13,8 @@ import { useMatchStore } from "../context/matchContext"
import { MANAGER_CONVERSATION, MANAGER_USER } from "../../appManagers" import { MANAGER_CONVERSATION, MANAGER_USER } from "../../appManagers"
import { useUserStore } from "../context/userContext" import { useUserStore } from "../context/userContext"
import { useConversationStore } from "../context/conversationContext" import { useConversationStore } from "../context/conversationContext"
import { socket } from "../../socketConfig"
import { Conversation } from "../core/conversation"
/* /*
Images required Images required
@ -20,6 +22,7 @@ import { useConversationStore } from "../context/conversationContext"
const engrenage = require('../../assets/Icons/UnSelected/Cogs.png'); const engrenage = require('../../assets/Icons/UnSelected/Cogs.png');
const cross = require('../../assets/Icons/UnSelected/Cross.png'); const cross = require('../../assets/Icons/UnSelected/Cross.png');
const msc = require('../../assets/Icons/FondGris.png'); const msc = require('../../assets/Icons/FondGris.png');
const door = require('../../assets/Icons/UnSelected/Door.png');
export const TopBar : export const TopBar :
/* Parameters: /* Parameters:
@ -35,6 +38,27 @@ FC<{nav: any, state?: string}> =
const resetMatch = useMatchStore((state) => state.resetMatch); const resetMatch = useMatchStore((state) => state.resetMatch);
const resetCurrentConv = useConversationStore((state) => state.resetCurrentConv); 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: /* 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 * 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}/> <Image source={cross} style={styles.icon}/>
</Pressable> </Pressable>
<Text style={styles.titre}>{useConversationStore().currentConv?.getName()}</Text> <Text style={styles.titre}>{useConversationStore().currentConv?.getName()}</Text>
<Pressable> <Pressable onPress={ () => quitConv()}>
<Image source={msc} style={styles.icon}/> <Image source={door} style={styles.icon}/>
</Pressable> </Pressable>
</View> </View>
) )

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

@ -7,6 +7,7 @@ import { BotBar } from '../components/BotBar';
import { Conversation } from '../core/conversation'; import { Conversation } from '../core/conversation';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import { useMatchStore } from '../context/matchContext'; import { useMatchStore } from '../context/matchContext';
import { MANAGER_MATCH } from '../../appManagers';
function LobbySolo(props: { navigation: any; }) { function LobbySolo(props: { navigation: any; }) {
@ -24,7 +25,7 @@ function LobbySolo(props: { navigation: any; }) {
<View style={stylesScreen.bodyCenter}> <View style={stylesScreen.bodyCenter}>
<ButtonGameTypeChoice <ButtonGameTypeChoice
title='Lancer la partie' 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> </View>

@ -59,17 +59,26 @@ export class SaverConversationApi implements ISaverConversation{
return message; return message;
} }
addUserToConversation(c: Conversation, id: number): Promise<void> { async addUserToConversation(c: Conversation, id: number): Promise<void> {
throw new Error("Method not implemented."); throw new Error("Method not implemented.");
} }
deleteUserToConversation(c: Conversation, u: User): Promise<void> { async deleteUserToConversation(c: Conversation, u: User): Promise<void> {
throw new Error("Method not implemented."); 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> { 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> { async updateConversation(c: Conversation): Promise<void> {
return; return;
} }

Loading…
Cancel
Save