This commit is contained in:
Peter Maquiran
2024-03-26 12:03:30 +01:00
parent 0b876e516b
commit ca0b968abe
32 changed files with 1016 additions and 794 deletions
@@ -151,15 +151,6 @@ export class ChatSystemService {
} catch(error) {}
}
setMainChangeDetector(x:Function) {
this.mainChangeDetector = x
}
runMainChangeDetector() {
console.log("change")
// this.mainChangeDetector()
}
loadChat() {
if (SessionStore.user?.ChatData?.data) {
this.ReLoadChat()
-7
View File
@@ -25,7 +25,6 @@ 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'
@@ -85,7 +84,6 @@ export class RoomService {
sortRoomList = () => { }
chatServiceDeleteRoom = (roomId) => { }
private changeDetector: Function = () => {}
constructor(
public RochetChatConnectorService: RochetChatConnectorService,
@@ -192,11 +190,6 @@ export class RoomService {
}
setChangeDetector(x:Function) {
console.log("set change detector")
this.changeDetector = x
}
get online() {
if (!this.isGroup) {
-12
View File
@@ -202,9 +202,6 @@ export class NotificationsService {
this.active = true
console.log('NOtification Listener', notification)
this.storenotification(notification)
this.chatNotification(notification)
}
);
@@ -216,7 +213,6 @@ export class NotificationsService {
this.eventtrigger.publishSomeData({
notification: "recive"
})
this.chatNotification(notification)
// Handle the received message, e.g., show a notification
});
}
@@ -400,12 +396,4 @@ export class NotificationsService {
}
chatNotification(_notification) {
const notification = this.NotificationHolderService.stractureNotificationObject(_notification)
if (notification?.notification?.data?.Service === "chat" || notification?.Service === "chat") {
this.ChatController.ChatSystemService.runMainChangeDetector()
}
}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { HolderService } from './holder.service';
describe('HolderService', () => {
let service: HolderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(HolderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class HolderService {
constructor() { }
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PublicationHolderService } from './publication-holder.service';
describe('PublicationHolderService', () => {
let service: PublicationHolderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PublicationHolderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,98 @@
import { Injectable } from '@angular/core';
import { PublicationFormMV } from 'src/app/shared/publication/upload/upload-streaming.service';
@Injectable({
providedIn: 'root'
})
export class PublicationHolderService {
count = 0
PublicationFormMV: {
id: string,
percentage: number,
retry: boolean,
retryFunction: Function
}[] = []
constructor() {
window['upload-header-set-percentage'] = (id: string, percentage: number) => {
this.PublicationFormMV = this.PublicationFormMV.map((e)=> {
if(e.id == id) {
console.log("percentage", percentage)
e.percentage = percentage
}
return e
})
this.uploadPercentage()
}
window['upload-header-set-add'] = (id: string, percentage: number, save: Function) => {
this.PublicationFormMV.push({id, percentage, retry: false, retryFunction: save})
this.uploadPercentage()
}
window['upload-header-set-remove'] = (id: string) => {
this.remove(id)
}
window['upload-header-set-retry'] = (id: string) => {
this.PublicationFormMV = this.PublicationFormMV.map((e)=> {
if(e.id == id) {
e.retry = true
}
return e
})
this.uploadPercentage()
}
window['upload-header-remove-retry'] = (id: string) => {
this.uploadPercentage()
this.PublicationFormMV = this.PublicationFormMV.map((e)=> {
if(e.id == id) {
e.retry = false
}
return e
})
this.uploadPercentage()
}
}
remove(id: string) {
this.PublicationFormMV = this.PublicationFormMV.filter((e)=> e.id != id)
this.uploadPercentage()
}
hasPublication() {
return this.PublicationFormMV.length >= 1
}
uploadPercentage = () => {
const percentageArray = this.PublicationFormMV.map((e) => e.percentage)
// Check if the array is not empty
if (percentageArray.length === 0) {
this.count = 0
} else {
let sum = percentageArray.reduce((acc, percentage) => acc + percentage, 0);
// Calculate the average percentage
let averagePercentage = sum / percentageArray.length;
this.count = Math.ceil(averagePercentage)
}
}
}
@@ -147,21 +147,29 @@ class ReconnectingWebSocketSignalR {
}
commit(path): Promise<Result<true, false>> {
console.log('committing')
return new Promise((resolve, reject) => {
try {
console.log('this.connection.invoke', this.connection)
this.connection.invoke("CommitUpload", path).then((e) => {
console.log("commit message", e)
resolve(ok(true))
}).catch(err => {
console.error('upload catch commit error')
if(this.isOpen) {
try {
console.log('this.connection.invoke', this.connection)
this.connection.invoke("CommitUpload", path).then((e) => {
console.log("commit message", e)
resolve(ok(true))
}).catch(err => {
console.error('upload catch commit error')
resolve(Err(false))
console.error(err.toString())
});
} catch(error) {
resolve(Err(false))
console.error(err.toString())
});
} catch(error) {
resolve(Err(false))
console.error('upload commit error')
console.error(error)
console.error('upload commit error')
console.error(error)
}
} else {
this.onConnect.push(()=> {
resolve(this.commit(path))
})
}
})
}
@@ -410,61 +418,60 @@ export class ObjectMergeNotification{
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()
}
connect() {
// this.socket.connect();
this.socket.connect();
}
close() {
// this.socket.disconnect();
// this.watchCount = 0;
// this.runWatch = false
this.socket.disconnect();
this.watchCount = 0;
this.runWatch = false
}
async watch() {
// this.watchCount = 0;
this.watchCount = 0;
// if(this.runWatch) {
// setTimeout(async () => {
// for(const [key, funx] of Object.entries(this.callbacks)) {
if(this.runWatch) {
setTimeout(async () => {
for(const [key, funx] of Object.entries(this.callbacks)) {
// const request = await this.CMAPIService.getVideoHeader(key)
const request = await this.CMAPIService.getVideoHeader(key)
// if(request.isOk()) {
// funx()
// delete this.callbacks[key]
// }
// }
if(request.isOk()) {
funx()
delete this.callbacks[key]
}
}
// this.watchCount++
// if(this.watchCount <= 15) {
// this.watch()
// } else {
// this.runWatch = false
// }
this.watchCount++
if(this.watchCount <= 15) {
this.watch()
} else {
this.runWatch = false
}
// }, 1000)
}, 1000)
// } else {
// console.log("end loop============================")
// }
} else {
console.log("end loop============================")
}
}
subscribe(GUID, callback:Function) {