mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -42,7 +42,7 @@ export class MessageService {
|
||||
if (this.file) {
|
||||
if (this.file.guid) {
|
||||
this.storage.get(this.file.guid).then((image) => {
|
||||
console.log('IMAGE FROM STORAGE', image)
|
||||
// console.log('IMAGE FROM STORAGE', image)
|
||||
this.file.image_url = image
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import { NativeNotificationService } from 'src/app/services/native-notification.
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { capitalizeTxt } from 'src/plugin/text'
|
||||
import { SortService } from '../functions/sort.service';
|
||||
import { chatUser } from 'src/app/models/chatMethod';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -40,6 +42,9 @@ export class RoomService {
|
||||
mgsArray = [];
|
||||
|
||||
scrollDown = () => { }
|
||||
getAllUsers = (): chatUser[] => {
|
||||
return []
|
||||
}
|
||||
|
||||
constructor(
|
||||
public WsChatService: WsChatService,
|
||||
@@ -198,6 +203,19 @@ export class RoomService {
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
private setTypingOff() {
|
||||
this.typing('')
|
||||
}
|
||||
|
||||
roomLeave() {
|
||||
this.setTypingOff()
|
||||
}
|
||||
|
||||
open() {
|
||||
// this.typing(this.message)
|
||||
}
|
||||
|
||||
|
||||
leave(rid?) {
|
||||
this.WsChatService.leaveRoom(this.id)
|
||||
}
|
||||
@@ -437,7 +455,7 @@ export class RoomService {
|
||||
console.log('FIX UPDATE ', message.result)
|
||||
message.result._updatedAt = message.result._updatedAt['$date']
|
||||
} else {
|
||||
console.log('FIX UPDATE 11', message)
|
||||
// console.log('FIX UPDATE 11', message)
|
||||
message._updatedAt = message._updatedAt['$date']
|
||||
}
|
||||
return message
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Platform } from '@ionic/angular';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
import { SortService } from '../functions/sort.service';
|
||||
import { chatUser } from 'src/app/models/chatMethod';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -28,6 +29,10 @@ export class WsChatMethodsService {
|
||||
dmCount = 0;
|
||||
groupCount = 0;
|
||||
|
||||
|
||||
currentRoom = null
|
||||
users: chatUser[] = []
|
||||
|
||||
constructor(
|
||||
private WsChatService: WsChatService,
|
||||
private storage: Storage,
|
||||
@@ -40,10 +45,37 @@ export class WsChatMethodsService {
|
||||
await this.getAllRooms();
|
||||
this.subscribeToRoom()
|
||||
|
||||
|
||||
//
|
||||
await this.getUser()
|
||||
this.getUserStatus()
|
||||
|
||||
})()
|
||||
|
||||
}
|
||||
|
||||
openRoom(roomId) {
|
||||
|
||||
if(this.currentRoom) {
|
||||
if(this.getDmRoom(this.currentRoom)) {
|
||||
this.getDmRoom(this.currentRoom).roomLeave()
|
||||
} else if(this.getGroupRoom(this.currentRoom)) {
|
||||
this.getGroupRoom(this.currentRoom).roomLeave()
|
||||
}
|
||||
}
|
||||
|
||||
this.currentRoom = roomId
|
||||
|
||||
if(this.currentRoom) {
|
||||
if(this.getDmRoom(this.currentRoom)) {
|
||||
this.getDmRoom(this.currentRoom).open()
|
||||
} else if(this.getGroupRoom(this.currentRoom)) {
|
||||
this.getGroupRoom(this.currentRoom).open()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async getAllRooms () {
|
||||
this.loadingWholeList = true
|
||||
|
||||
@@ -140,6 +172,7 @@ export class WsChatMethodsService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
prepareRoom(roomData) {
|
||||
let room:RoomService;
|
||||
|
||||
@@ -155,6 +188,7 @@ export class WsChatMethodsService {
|
||||
})
|
||||
|
||||
room.receiveMessage()
|
||||
room.getAllUsers = this.getUsers
|
||||
room.receiveMessageDelete();
|
||||
|
||||
let roomId = this.getRoomId(roomData)
|
||||
@@ -170,6 +204,51 @@ export class WsChatMethodsService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
getReceptorName(roomData) {
|
||||
try {
|
||||
return roomData.usernames.find((e)=> e != SessionStore.user.RochetChatUser)
|
||||
} catch(e) {
|
||||
return '*'
|
||||
}
|
||||
}
|
||||
|
||||
getUserStatus(id?:string) {
|
||||
|
||||
this.WsChatService.getUserStatus((d) => {
|
||||
|
||||
const username = d.fields.args[0][1]
|
||||
const statusNum = d.fields.args[0][2]
|
||||
|
||||
console.log('d', d)
|
||||
|
||||
const statusText = this.statusNumberToText(statusNum)
|
||||
this.getUserByName(username).status = statusText
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getUserByName(username) {
|
||||
return this.users.find((user)=> user.username == username)
|
||||
}
|
||||
|
||||
statusNumberToText(text) {
|
||||
if(text == '0') {
|
||||
return "offline"
|
||||
}
|
||||
else if(text == '1') {
|
||||
return "online"
|
||||
}
|
||||
else if(text == '2') {
|
||||
return "away"
|
||||
}
|
||||
else if(text == '3') {
|
||||
return "busy"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deleteMessage(id?) {
|
||||
return this.WsChatService.deleteMessage(id);
|
||||
}
|
||||
@@ -229,4 +308,28 @@ export class WsChatMethodsService {
|
||||
return !roomData.fname
|
||||
}
|
||||
|
||||
getUsers = () =>{
|
||||
return this.users
|
||||
}
|
||||
|
||||
async getUser() {
|
||||
|
||||
// let _res = await this.chatService.getAllUsers().toPromise()
|
||||
|
||||
// let user = _res['users'].filter(data => data.username != SessionStore.user.RochetChatUser);
|
||||
|
||||
// user = user.sort((a,b) => {
|
||||
// if(a.name < b.name) {
|
||||
// return -1;
|
||||
// }
|
||||
// if(a.name > b.name) {
|
||||
// return 1;
|
||||
// }
|
||||
// return 0;
|
||||
// });
|
||||
|
||||
// this.users = user
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export class WsChatService {
|
||||
});
|
||||
}
|
||||
|
||||
hidingRoom(roomId){
|
||||
hidingRoom(roomId) {
|
||||
|
||||
const requestId = uuidv4()
|
||||
|
||||
@@ -350,6 +350,19 @@ export class WsChatService {
|
||||
}})
|
||||
}
|
||||
|
||||
|
||||
getUserStatus(funx:Function){
|
||||
this.ws.registerCallback({
|
||||
type:'Onmessage',
|
||||
funx:(message)=>{
|
||||
if(message.msg == 'changed' && message.collection == "stream-notify-logged") {
|
||||
funx(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
loadHistory(roomId, limit: number = 50) {
|
||||
|
||||
const requestId = uuidv4()
|
||||
|
||||
Reference in New Issue
Block a user