This commit is contained in:
Peter Maquiran
2024-03-03 18:14:33 +01:00
parent eb17b9d310
commit 588b59b3ab
5 changed files with 67 additions and 41 deletions
+58 -31
View File
@@ -6,6 +6,7 @@ import { ThemeService } from 'src/app/services/theme.service';
import { ChatSystemService } from 'src/app/services/chat/chat-system.service';
import { SessionStore } from 'src/app/store/session.service';
import { ToastService } from 'src/app/services/toast.service';
import { catchError } from 'rxjs/operators';
@Component({
selector: 'app-new-group',
@@ -66,46 +67,72 @@ export class NewGroupPage implements OnInit {
let customFields = {}
let res: any;
if (this.thedate) {
let customFields = {
"countDownDate": this.thedate
}
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
}
else {
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
if(!SessionStore.user?.ChatData?.data) {
this.toastService._successMessage("Chat temporariamente indisponível")
}
this.isGroupCreated = true;
this.addContacts(res.result);
this.ChatSystemService.getRoom([res.result]);
try {
setTimeout(() => {
this.ChatSystemService.subscribeToRoomUpdate(res.result.rid, res.result);
}, 10)
if (res?.result?.rid) {
this.ChatSystemService.getAllRooms(() => {
if (!this.ChatSystemService.getGroupRoom(res.result.rid)) {
this.createGroupWithAttachmentsCath(res)
} else {
setTimeout(() => {
this.createGroupWithAttachments(res)
}, 500)
if (this.thedate) {
let customFields = {
"countDownDate": this.thedate
}
}, res.result.rid);
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
}
else {
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
}
try {
this.isGroupCreated = true;
this.addContacts(res.result);
this.ChatSystemService.getRoom([res.result]);
setTimeout(() => {
this.ChatSystemService.subscribeToRoomUpdate(res.result.rid, res.result);
}, 10)
} catch (error) {
await this.ChatSystemService.getUser();
await this.ChatSystemService.getAllRooms();
await this.ChatSystemService.subscribeToRoom();
this.isGroupCreated = true;
this.addContacts(res.result);
this.ChatSystemService.getRoom([res.result]);
setTimeout(() => {
this.ChatSystemService.subscribeToRoomUpdate(res.result.rid, res.result);
}, 10)
}
} else {
if (res?.result?.rid) {
this.toastService._badRequest('Existe um grupo com este nome!');
this.ChatSystemService.getAllRooms(() => {
if (!this.ChatSystemService.getGroupRoom(res.result.rid)) {
this.createGroupWithAttachmentsCath(res)
} else {
setTimeout(() => {
this.createGroupWithAttachments(res)
}, 500)
}
}, res.result.rid);
} else {
this.toastService._badRequest('Existe um grupo com este nome!');
}
} catch(error) {
this.toastService._successMessage("Chat temporariamente indisponível")
}
}