|
|
@ -35,7 +35,6 @@ export class AppUsersManager { |
|
|
|
private users: {[userId: number]: User} = {}; |
|
|
|
private users: {[userId: number]: User} = {}; |
|
|
|
private usernames: {[username: string]: number} = {}; |
|
|
|
private usernames: {[username: string]: number} = {}; |
|
|
|
//public userAccess: {[userId: number]: string} = {};
|
|
|
|
//public userAccess: {[userId: number]: string} = {};
|
|
|
|
private cachedPhotoLocations: {[userId: number]: UserProfilePhoto} = {}; |
|
|
|
|
|
|
|
private contactsIndex = searchIndexManager.createIndex(); |
|
|
|
private contactsIndex = searchIndexManager.createIndex(); |
|
|
|
private contactsFillPromise: Promise<Set<number>>; |
|
|
|
private contactsFillPromise: Promise<Set<number>>; |
|
|
|
public contactsList: Set<number> = new Set(); |
|
|
|
public contactsList: Set<number> = new Set(); |
|
|
@ -80,15 +79,10 @@ export class AppUsersManager { |
|
|
|
if(user) { |
|
|
|
if(user) { |
|
|
|
this.forceUserOnline(userId); |
|
|
|
this.forceUserOnline(userId); |
|
|
|
|
|
|
|
|
|
|
|
if(!user.photo) { |
|
|
|
if(update.photo._ === 'userProfilePhotoEmpty') { |
|
|
|
user.photo = update.photo; |
|
|
|
delete user.photo; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
safeReplaceObject(user.photo, update.photo); |
|
|
|
user.photo = safeReplaceObject(user.photo, update.photo); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.cachedPhotoLocations[userId] !== undefined) { |
|
|
|
|
|
|
|
safeReplaceObject(this.cachedPhotoLocations[userId], update.photo ? |
|
|
|
|
|
|
|
update.photo : {empty: true}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rootScope.broadcast('user_update', userId); |
|
|
|
rootScope.broadcast('user_update', userId); |
|
|
@ -120,6 +114,11 @@ export class AppUsersManager { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rootScope.on('language_change', (e) => { |
|
|
|
|
|
|
|
const userId = this.getSelf().id; |
|
|
|
|
|
|
|
searchIndexManager.indexObject(userId, this.getUserSearchText(userId), this.contactsIndex); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
appStateManager.getState().then((state) => { |
|
|
|
appStateManager.getState().then((state) => { |
|
|
|
this.users = state.users; |
|
|
|
this.users = state.users; |
|
|
|
|
|
|
|
|
|
|
@ -198,12 +197,16 @@ export class AppUsersManager { |
|
|
|
return ''; |
|
|
|
return ''; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const serviceText = user.pFlags.self ? 'Saved Messages' : ''; |
|
|
|
const arr: string[] = [ |
|
|
|
return (user.first_name || '') + |
|
|
|
user.first_name, |
|
|
|
' ' + (user.last_name || '') + |
|
|
|
user.last_name, |
|
|
|
' ' + (user.phone || '') + |
|
|
|
user.phone, |
|
|
|
' ' + (user.username || '') + |
|
|
|
user.username, |
|
|
|
' ' + serviceText; |
|
|
|
user.pFlags.self ? I18n.format('SavedMessages', true) : '', |
|
|
|
|
|
|
|
user.pFlags.self ? 'Saved Messages' : '' |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return arr.filter(Boolean).join(' '); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public getContacts(query?: string, includeSaved = false) { |
|
|
|
public getContacts(query?: string, includeSaved = false) { |
|
|
@ -351,11 +354,6 @@ export class AppUsersManager { |
|
|
|
|
|
|
|
|
|
|
|
rootScope.broadcast('user_update', userId); |
|
|
|
rootScope.broadcast('user_update', userId); |
|
|
|
|
|
|
|
|
|
|
|
if(this.cachedPhotoLocations[userId] !== undefined) { |
|
|
|
|
|
|
|
safeReplaceObject(this.cachedPhotoLocations[userId], user && |
|
|
|
|
|
|
|
user.photo ? user.photo : {empty: true}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(changedTitle) { |
|
|
|
if(changedTitle) { |
|
|
|
rootScope.broadcast('peer_title_edit', user.id); |
|
|
|
rootScope.broadcast('peer_title_edit', user.id); |
|
|
|
} |
|
|
|
} |
|
|
@ -514,15 +512,11 @@ export class AppUsersManager { |
|
|
|
public getUserPhoto(id: number) { |
|
|
|
public getUserPhoto(id: number) { |
|
|
|
const user = this.getUser(id); |
|
|
|
const user = this.getUser(id); |
|
|
|
|
|
|
|
|
|
|
|
if(this.cachedPhotoLocations[id] === undefined) { |
|
|
|
return user && user.photo || { |
|
|
|
this.cachedPhotoLocations[id] = user && user.photo || { |
|
|
|
|
|
|
|
_: 'userProfilePhotoEmpty' |
|
|
|
_: 'userProfilePhotoEmpty' |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.cachedPhotoLocations[id]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getUserString(id: number) { |
|
|
|
public getUserString(id: number) { |
|
|
|
const user = this.getUser(id); |
|
|
|
const user = this.getUser(id); |
|
|
|
return 'u' + id + (user.access_hash ? '_' + user.access_hash : ''); |
|
|
|
return 'u' + id + (user.access_hash ? '_' + user.access_hash : ''); |
|
|
|