mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
pull amde
This commit is contained in:
@@ -16,6 +16,8 @@ export class ActiveTabService {
|
||||
gabineteDetails: false
|
||||
}
|
||||
|
||||
updatePublications = () => {}
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
public HeaderSettingsService: HeaderSettingsService) {
|
||||
@@ -47,6 +49,13 @@ export class ActiveTabService {
|
||||
|
||||
} else if (pathName.startsWith('/home/publications')) {
|
||||
this.pages.publication = true
|
||||
if(pathName.includes("/publications/")) {
|
||||
if(this.updatePublications) {
|
||||
this.updatePublications()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (pathName.startsWith('/home/chat')) {
|
||||
this.pages.chat = true
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ export class ListBoxService {
|
||||
// object[momentG(new Date(e.start), 'MMMM yyyy')].push(e)
|
||||
// }
|
||||
|
||||
// console.log({object})
|
||||
|
||||
// const daysStringNum = Object.keys(object).reverse()
|
||||
|
||||
// const daysObject = {}
|
||||
@@ -77,13 +75,8 @@ export class ListBoxService {
|
||||
// daysObject[day] = object[day]
|
||||
// }
|
||||
|
||||
// console.log({daysObject})
|
||||
|
||||
|
||||
return this.display(newStracture, selectedDate).year
|
||||
|
||||
// console.log({daysObject})
|
||||
|
||||
// const daysStringNum = Object.keys(daysObject)
|
||||
|
||||
// for(const day of daysStringNum) {
|
||||
@@ -105,6 +98,8 @@ export class ListBoxService {
|
||||
}
|
||||
|
||||
display(list: CustomCalendarEvent[], selectedDate) {
|
||||
|
||||
|
||||
let days = {};
|
||||
const year: Year[] = []
|
||||
|
||||
@@ -171,14 +166,14 @@ export class ListBoxService {
|
||||
// last push
|
||||
const EndEvent = this.transForm(cloneEvent, {startMany: false, endMany: true, middle: false})
|
||||
if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) {
|
||||
days[otherDays].push(EndEvent) ; this.push(cloneEvent, year)
|
||||
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
const EndEvent = this.transForm(cloneEvent, {startMany: false,endMany: true, middle: true})
|
||||
if(this.CanPush(cloneEvent, selectedDate) && cloneEvent.start.getTime() >= cloneSelectedDate.getTime()) {
|
||||
days[otherDays].push(EndEvent) ; this.push(cloneEvent, year)
|
||||
days[otherDays].push(EndEvent) ; this.push(EndEvent, year)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ export class AuthService {
|
||||
setTimeout(() => {
|
||||
|
||||
if (SessionStore.user.ChatData?.data) {
|
||||
this.RochetChatConnectorService.logout();
|
||||
this.RochetChatConnectorService.connect();
|
||||
this.RochetChatConnectorService.login().then((message: any) => {
|
||||
console.log('Chat login', message)
|
||||
@@ -190,6 +191,7 @@ export class AuthService {
|
||||
SessionStore.user.RochetChatUserId = message.result.id
|
||||
SessionStore.save()
|
||||
|
||||
this.ChatSystemService.loadChat()
|
||||
this.RochetChatConnectorService.setStatus('online')
|
||||
window['RochetChatConnectorService'] = this.RochetChatConnectorService
|
||||
setTimeout(() => {
|
||||
@@ -199,7 +201,14 @@ export class AuthService {
|
||||
|
||||
|
||||
}).catch((error) => {
|
||||
// console.error(SessionStore.user.ChatData, 'web socket login',error)
|
||||
console.error(SessionStore.user.ChatData, 'web socket login', error)
|
||||
|
||||
if(window.location.pathname.includes('/home/')) {
|
||||
setTimeout(() => {
|
||||
this.loginToChatWs();
|
||||
}, 4000)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -333,7 +342,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
refreshToken() {
|
||||
|
||||
|
||||
return this.http
|
||||
.put<any>(environment.apiURL + "UserAuthentication/RefreshToken", {
|
||||
refreshToken: SessionStore.user.RefreshToken,
|
||||
|
||||
@@ -392,61 +392,6 @@ export class ChatService {
|
||||
|
||||
async refreshtoken() {
|
||||
|
||||
if(this.headers && SessionStore.user.ChatData) {
|
||||
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||
let options = {
|
||||
headers: this.headers
|
||||
};
|
||||
|
||||
try {
|
||||
let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise();
|
||||
|
||||
let data = {
|
||||
status: res['status'],
|
||||
data: {
|
||||
userId: res['data'].userId,
|
||||
authToken: res['data'].authToken
|
||||
}
|
||||
}
|
||||
SessionStore.user.ChatData = data
|
||||
SessionStore.save()
|
||||
this.setheader()
|
||||
this.timerEventTriggerDateLastUpdate = new Date();
|
||||
} catch (error) {
|
||||
|
||||
if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Offline) {
|
||||
this.RochetChatConnectorService.registerCallback({
|
||||
requestId: 'refreshtoken',
|
||||
type: 'reConnect',
|
||||
funx: async () => {
|
||||
|
||||
this.resetTimer();
|
||||
await this.refreshtoken();
|
||||
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
if(SessionStore.user.Authorization != '') {
|
||||
setTimeout(async () => {
|
||||
this.resetTimer();
|
||||
await this.refreshtoken();
|
||||
}, 60000)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if(!SessionStore.user.ChatData) {
|
||||
// do nothing
|
||||
} else if (!this.headers) {
|
||||
this.setheader()
|
||||
this.refreshtoken()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ export class ChatSystemService {
|
||||
loadingUsers = false
|
||||
|
||||
onRoomsLoad = new Subscribe({ execute: false, deleteOnExecute: true })
|
||||
private mainChangeDetector: Function = () => {}
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -66,7 +67,7 @@ export class ChatSystemService {
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService
|
||||
private notificationService: NotificationsService,
|
||||
) {
|
||||
|
||||
|
||||
@@ -148,9 +149,15 @@ export class ChatSystemService {
|
||||
});
|
||||
}
|
||||
} catch(error) {}
|
||||
}
|
||||
|
||||
setMainChangeDetector(x:Function) {
|
||||
this.mainChangeDetector = x
|
||||
}
|
||||
|
||||
|
||||
runMainChangeDetector() {
|
||||
console.log("change")
|
||||
// this.mainChangeDetector()
|
||||
}
|
||||
|
||||
loadChat() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import { ChatSystemService } from './chat-system.service';
|
||||
import { ViewedMessageService } from './viewed-message.service'
|
||||
import * as FIFOProcessQueue from 'fifo-process-queue';
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -84,6 +85,7 @@ export class RoomService {
|
||||
|
||||
sortRoomList = () => { }
|
||||
chatServiceDeleteRoom = (roomId) => { }
|
||||
private changeDetector: Function = () => {}
|
||||
|
||||
constructor(
|
||||
public RochetChatConnectorService: RochetChatConnectorService,
|
||||
@@ -190,6 +192,11 @@ export class RoomService {
|
||||
|
||||
}
|
||||
|
||||
setChangeDetector(x:Function) {
|
||||
console.log("set change detector")
|
||||
this.changeDetector = x
|
||||
}
|
||||
|
||||
get online() {
|
||||
|
||||
if (!this.isGroup) {
|
||||
@@ -372,8 +379,6 @@ export class RoomService {
|
||||
}
|
||||
|
||||
this.messageUnread = true
|
||||
|
||||
// this.sortRoomList()
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 50)
|
||||
@@ -386,6 +391,7 @@ export class RoomService {
|
||||
this.name = ChatMessage.msg
|
||||
}
|
||||
|
||||
// this.changeDetector()
|
||||
setTimeout(() => {
|
||||
done()
|
||||
}, 5)
|
||||
|
||||
@@ -14,9 +14,10 @@ import { notificationObject } from '../models/notifications';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { AngularFireMessaging } from '@angular/fire/messaging';
|
||||
import { NotificationHolderService } from 'src/app/store/notification-holder.service';
|
||||
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { FCM } from '@capacitor-community/fcm';
|
||||
|
||||
import { ChatSystemService } from './chat/chat-system.service';
|
||||
import {ChatController} from 'src/app/controller/chat'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -42,6 +43,8 @@ export class NotificationsService {
|
||||
notificationReceived: EventEmitter<void> = new EventEmitter<void>();
|
||||
token = ''
|
||||
|
||||
ChatController = ChatController
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private storageService: StorageService,
|
||||
@@ -82,7 +85,7 @@ export class NotificationsService {
|
||||
}) .catch((error) => {
|
||||
console.log("Register device error", error)
|
||||
})
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log("Granted permission error", error)
|
||||
}
|
||||
@@ -199,6 +202,7 @@ export class NotificationsService {
|
||||
this.active = true
|
||||
console.log('NOtification Listener', notification)
|
||||
this.storenotification(notification)
|
||||
this.chatNotification(notification)
|
||||
|
||||
|
||||
}
|
||||
@@ -206,11 +210,13 @@ export class NotificationsService {
|
||||
|
||||
} else {
|
||||
this.afMessaging.messages.subscribe((notification) => {
|
||||
console.log(notification)
|
||||
this.storenotification(notification)
|
||||
this.notificationReceived.emit();
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
})
|
||||
this.chatNotification(notification)
|
||||
// Handle the received message, e.g., show a notification
|
||||
});
|
||||
}
|
||||
@@ -393,4 +399,13 @@ export class NotificationsService {
|
||||
// })()
|
||||
}
|
||||
|
||||
|
||||
chatNotification(_notification) {
|
||||
const notification = this.NotificationHolderService.stractureNotificationObject(_notification)
|
||||
|
||||
if (notification?.notification?.data?.Service === "chat" || notification?.Service === "chat") {
|
||||
this.ChatController.ChatSystemService.runMainChangeDetector()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -390,32 +390,32 @@ export class ObjectMergeNotification{
|
||||
watchCount = 0
|
||||
|
||||
constructor() {
|
||||
this.socket.onDisconnectCallback(()=> {
|
||||
console.log("run watch")
|
||||
this.runWatch = true
|
||||
this.watch()
|
||||
})
|
||||
// this.socket.onDisconnectCallback(()=> {
|
||||
// console.log("run watch")
|
||||
// this.runWatch = true
|
||||
// this.watch()
|
||||
// })
|
||||
|
||||
this.socket.onConnectCallback(()=> {
|
||||
// this.socket.onConnectCallback(()=> {
|
||||
|
||||
console.log("open trigger")
|
||||
this.runWatch = false
|
||||
})
|
||||
// console.log("open trigger")
|
||||
// this.runWatch = false
|
||||
// })
|
||||
|
||||
this.socket.subscribe((data: socketResponse) => {
|
||||
if(data.IsCompleted == true) {
|
||||
console.log("==================!!!====================")
|
||||
try {
|
||||
this.callbacks[data.Guid](data)
|
||||
delete this.callbacks[data.Guid]
|
||||
} catch (error) {}
|
||||
} else {
|
||||
console.log("else", data)
|
||||
}
|
||||
})
|
||||
// this.socket.subscribe((data: socketResponse) => {
|
||||
// if(data.IsCompleted == true) {
|
||||
// console.log("==================!!!====================")
|
||||
// try {
|
||||
// this.callbacks[data.Guid](data)
|
||||
// delete this.callbacks[data.Guid]
|
||||
// } catch (error) {}
|
||||
// } else {
|
||||
// console.log("else", data)
|
||||
// }
|
||||
// })
|
||||
|
||||
this.socket.connect();
|
||||
this.watch()
|
||||
// this.socket.connect();
|
||||
// this.watch()
|
||||
}
|
||||
|
||||
connect() {
|
||||
|
||||
Reference in New Issue
Block a user