Don't show send when online if user hid his online
This commit is contained in:
parent
09cc5f8573
commit
4c90cfb97a
@ -654,6 +654,8 @@ export default class ChatInput {
|
||||
}
|
||||
|
||||
public scheduleSending = (callback: () => void = this.sendMessage.bind(this, true), initDate = new Date()) => {
|
||||
const canSendWhenOnline = this.chat.peerId > 0 && this.appUsersManager.isUserOnlineVisible(this.chat.peerId);
|
||||
|
||||
new PopupSchedule(initDate, (timestamp) => {
|
||||
const minTimestamp = (Date.now() / 1000 | 0) + 10;
|
||||
if(timestamp <= minTimestamp) {
|
||||
@ -666,7 +668,7 @@ export default class ChatInput {
|
||||
if(this.chat.type !== 'scheduled' && timestamp) {
|
||||
this.appImManager.openScheduled(this.chat.peerId);
|
||||
}
|
||||
}).show();
|
||||
}, canSendWhenOnline).show();
|
||||
};
|
||||
|
||||
public setUnreadCount() {
|
||||
|
@ -28,7 +28,7 @@ const checkDate = (date: Date) => {
|
||||
};
|
||||
|
||||
export default class PopupSchedule extends PopupDatePicker {
|
||||
constructor(initDate: Date, onPick: (timestamp: number) => void) {
|
||||
constructor(initDate: Date, onPick: (timestamp: number) => void, canSendWhenOnline: boolean) {
|
||||
super(checkDate(initDate), onPick, {
|
||||
noButtons: true,
|
||||
noTitle: true,
|
||||
@ -43,13 +43,16 @@ export default class PopupSchedule extends PopupDatePicker {
|
||||
this.element.classList.add('popup-schedule');
|
||||
this.header.append(this.controlsDiv);
|
||||
this.title.replaceWith(this.monthTitle);
|
||||
this.body.append(this.btnConfirm);
|
||||
|
||||
const btnSendWhenOnline = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: 'Schedule.SendWhenOnline'});
|
||||
this.body.append(this.btnConfirm, btnSendWhenOnline);
|
||||
if(canSendWhenOnline) {
|
||||
const btnSendWhenOnline = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: 'Schedule.SendWhenOnline'});
|
||||
this.body.append(btnSendWhenOnline);
|
||||
|
||||
attachClickEvent(btnSendWhenOnline, () => {
|
||||
onPick(SEND_WHEN_ONLINE_TIMESTAMP);
|
||||
this.hide();
|
||||
});
|
||||
attachClickEvent(btnSendWhenOnline, () => {
|
||||
onPick(SEND_WHEN_ONLINE_TIMESTAMP);
|
||||
this.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -427,6 +427,10 @@ export class AppUsersManager {
|
||||
return '+' + formatPhoneNumber(phone).formatted;
|
||||
}
|
||||
|
||||
public isUserOnlineVisible(id: number) {
|
||||
return this.getUserStatusForSort(id) > 3;
|
||||
}
|
||||
|
||||
public getUserStatusForSort(status: User['status'] | number) {
|
||||
if(typeof(status) === 'number') {
|
||||
status = this.getUser(status).status;
|
||||
|
Loading…
Reference in New Issue
Block a user