diff --git a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts index 21ab56df1..fe2ba54e0 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts @@ -33,7 +33,6 @@ import { DataService } from 'src/app/services/data.service'; import { RouteService } from 'src/app/services/route.service'; import { Storage } from '@ionic/storage'; import { LoginUserRespose } from 'src/app/models/user.model'; -import { AuthService } from 'src/app/services/auth.service'; import { SessionStore } from 'src/app/store/session.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { TaskService } from 'src/app/services/task.service'; @@ -71,9 +70,6 @@ export class ExpedienteDetailPage implements OnInit { constructor( private processes: ProcessesService, - private iab: InAppBrowser, - //private attachments: AttachmentsService, - private events: EventsService, private router: Router, private modalController: ModalController, public popoverController: PopoverController, @@ -84,12 +80,9 @@ export class ExpedienteDetailPage implements OnInit { public p: PermissionService, private expedienteService: ExpedienteService, public platform: Platform, - private sqliteservice: SqliteService, private backgroundservice: BackgroundService, public ThemeService: ThemeService, private dataService: DataService, - private storage: Storage, - private userAuth: AuthService, private httpErroHandle: HttpErrorHandle, private eventTriger: EventTrigger, public TaskService: TaskService diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts index cf54bc41f..30a3ea8fe 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts @@ -421,7 +421,7 @@ export class PedidoPage implements OnInit { } } - async newGroup(){ + async newGroup() { const modal = await this.modalController.create({ component: NewGroupPage, cssClass: 'modal modal-desktop', diff --git a/src/app/services/chat/chat-system.service.ts b/src/app/services/chat/chat-system.service.ts index 376962f09..8f95bb69c 100644 --- a/src/app/services/chat/chat-system.service.ts +++ b/src/app/services/chat/chat-system.service.ts @@ -20,6 +20,7 @@ import { AttachmentsService } from 'src/app/services/attachments.service'; import { NetworkServiceService} from 'src/app/services/network-service.service'; import { ViewedMessageService } from './viewed-message.service' import { NotificationsService } from '../notifications.service'; +import { Subscribe } from '../subcribe'; @Injectable({ providedIn: 'root' }) @@ -41,6 +42,9 @@ export class ChatSystemService { sessionStore = SessionStore delete = [] loadingUsers = false + + onRoomsLoad = new Subscribe({execute : false, deleteOnExecute: true}) + constructor( private RochetChatConnectorService: RochetChatConnectorService, @@ -299,7 +303,6 @@ export class ChatSystemService { this.loadingWholeList = false await this.storage.set('Rooms', rooms); - console.log('this._group', this._group) this.sortRoomList() @@ -311,6 +314,7 @@ export class ChatSystemService { this.sortRoomList() }, 10000) + this.onRoomsLoad.executor() } /** @@ -687,4 +691,46 @@ export class ChatSystemService { return this.RochetChatConnectorService.getUserOfRoom(roomId); } + + async createGroup(name) { + const res: any = await this.createPrivateRoom(name, SessionStore.user.UserName, {}); + console.log('room is created', res) + if(res?.result?.rid) { + try { + await this.getAllRooms(); + } catch (e) {} + console.log('room is loaded') + return res + } else { + return res + } + } + + getGroupByName(name ) { + return this._group.find( e=> e.name == name) + } + + async waitRoomToCreate(rid): Promise { + return new Promise(async (resolve, reject) => { + let sub; + + sub = this.onRoomsLoad.subscribe(() => { + const room = this.getRoomById(rid) + if (room) { + resolve(room) + sub.unSubscribe() + } + }) + + try { + await this.getAllRooms(); + } catch (e) {} + + }) + } + + searchContact(name, username) { + return this.users.find( e=> e.name == name || e.username == username) + } + } diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index d08b17c0c..808e3cc2f 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -943,4 +943,14 @@ export class RoomService { this.messageUnread = false } + addContacts(userId:any) { + + let body = { + "roomId": this.id, + "userId": userId, + } + + return this.chatService.addUserToGroup(body).toPromise(); + } + } diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts index 9d7e271dc..b82041ded 100644 --- a/src/app/services/events.service.ts +++ b/src/app/services/events.service.ts @@ -254,6 +254,24 @@ export class EventsService { } + for (let OwnerCalendar of SessionStore.user.OwnerCalendars) { + this.hasAnyCalendar = true + + this.calendarNames[OwnerCalendar.CalendarId] = 'Meu calendario' + + if(!this.calendarNamesAry.includes('Meu calendario')) { + this.calendarNamesAry.push('Meu calendario') + this.calendarNamesAryNoPr.push('Meu calendario') + this.calendarNamesType['Meu calendario'] = {} + } + + this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName] = true + this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName+'Id'] = OwnerCalendar.CalendarId + this.calendarNamesType['Meu calendario']['RoleId'] = OwnerCalendar.CalendarRoleId + this.calendarNamesType['Meu calendario']['OwnerId'] = OwnerCalendar.OwnerUserId || SessionStore.user.UserId + } + + for (let sharedCalendar of SessionStore.user.SharedCalendars) { this.hasAnyCalendar = true if(sharedCalendar?.OwnerUserId) { @@ -291,23 +309,6 @@ export class EventsService { } - for (let OwnerCalendar of SessionStore.user.OwnerCalendars) { - this.hasAnyCalendar = true - - this.calendarNames[OwnerCalendar.CalendarId] = 'Meu calendario' - - if(!this.calendarNamesAry.includes('Meu calendario')) { - this.calendarNamesAry.push('Meu calendario') - this.calendarNamesAryNoPr.push('Meu calendario') - this.calendarNamesType['Meu calendario'] = {} - } - - this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName] = true - this.calendarNamesType['Meu calendario'][OwnerCalendar.CalendarName+'Id'] = OwnerCalendar.CalendarId - this.calendarNamesType['Meu calendario']['RoleId'] = OwnerCalendar.CalendarRoleId - this.calendarNamesType['Meu calendario']['OwnerId'] = OwnerCalendar.OwnerUserId || SessionStore.user.UserId - } - if(SessionStore.user.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) { this.hasAnyCalendar = false diff --git a/src/app/shared/agenda/view-event/view-event.page.html b/src/app/shared/agenda/view-event/view-event.page.html index 9aecb93c1..dafddc1e8 100644 --- a/src/app/shared/agenda/view-event/view-event.page.html +++ b/src/app/shared/agenda/view-event/view-event.page.html @@ -14,14 +14,26 @@