Merge branch 'feature/websocket' of https://bitbucket.org/equilibriumito/gabinete-digital into feature/websocket

This commit is contained in:
tiago.kayaya
2022-01-14 15:07:43 +01:00
6 changed files with 51 additions and 30 deletions
@@ -94,7 +94,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.modalController.dismiss();
}
};
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked;
setTimeout(()=>{
this.scrollToBottomClicked()
}, 50)
}
ngOnInit() {
@@ -204,7 +211,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
} catch(err) { }
}
scrollToBottomClicked(): void {
scrollToBottomClicked = () => {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
+6 -1
View File
@@ -109,6 +109,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
};
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory()
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
setTimeout(()=>{
this.scrollToBottomClicked()
}, 50)
}
@@ -283,7 +288,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
} catch (err) { }
}
scrollToBottomClicked(): void {
scrollToBottomClicked = () => {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch (err) { }
+12
View File
@@ -23,6 +23,8 @@ export class RoomService {
private ToastService = ToastsService
scrollDown = () => {}
constructor(
public WsChatService: WsChatService,
private MessageService: MessageService,
@@ -52,6 +54,11 @@ export class RoomService {
this.lastMessage.msg = message.msg
this.calDateDuration(ChatMessage._updatedAt)
this.massages.push(message)
setTimeout(()=>{
this.scrollDown()
}, 100)
}
)
}
@@ -78,6 +85,11 @@ export class RoomService {
})
setTimeout(()=>{
this.scrollDown()
}, 50)
this.hasLoadHistory = true
}
+3 -25
View File
@@ -234,35 +234,13 @@ export class WsChatService {
}
/**
* @param roomId
* @param key
* @param funx
*/
receiveMyMessageConfirmation(roomId, funx: Function) {
this.ws.registerCallback({
type:'Onmessage',
funx:(message)=>{
if(message.msg =='result') {
if(message.result) {
if(message.result.msg) {
if(message.result.rid == roomId) {
funx(message)
}
}
}
}
}
})
}
receiveLiveMessageFromRoom(roomId, funx: Function) {
const key = roomId + funx;
this.ws.registerCallback({
type:'Onmessage',
key: key,
funx:(message)=>{
if(message.msg =='changed' && message.collection == 'stream-room-messages') {
if(message.fields.args[0].rid == roomId) {
@@ -103,6 +103,12 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
//this.scrollToBottom();
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
console.log('MESSAGES'+this.wsChatMethodsService.getGroupRoom(this.roomId).massages);
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
setTimeout(()=>{
this.scrollToBottomClicked()
}, 50)
}
ngOnInit() {
@@ -141,7 +147,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
} catch(err) { }
}
scrollToBottomClicked(): void {
scrollToBottomClicked = () => {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
+15 -2
View File
@@ -20,6 +20,7 @@ import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { WsChatMethodsService} from 'src/app/services/chat/ws-chat-methods.service'
import { WsChatService } from 'src/app/services/chat/ws-chat.service'
@Component({
selector: 'app-messages',
@@ -78,13 +79,24 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
public ThemeService: ThemeService,
private changeDetectorRef: ChangeDetectorRef,
private router: Router,
public wsChatMethodsService: WsChatMethodsService
public wsChatMethodsService: WsChatMethodsService,
public WsChatService: WsChatService
) {
this.loggedUser = authService.ValidatedUserChat['data'];
}
ngOnChanges(changes: SimpleChanges): void {
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory()
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
setTimeout(()=>{
this.scrollToBottomClicked()
}, 50)
}
ngOnInit() {
@@ -142,7 +154,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} catch(err) { }
}
scrollToBottomClicked(): void {
scrollToBottomClicked = () => {
console.log('scroll')
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
//this.scrollingOnce = false;