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()) => {
|
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) => {
|
new PopupSchedule(initDate, (timestamp) => {
|
||||||
const minTimestamp = (Date.now() / 1000 | 0) + 10;
|
const minTimestamp = (Date.now() / 1000 | 0) + 10;
|
||||||
if(timestamp <= minTimestamp) {
|
if(timestamp <= minTimestamp) {
|
||||||
@ -666,7 +668,7 @@ export default class ChatInput {
|
|||||||
if(this.chat.type !== 'scheduled' && timestamp) {
|
if(this.chat.type !== 'scheduled' && timestamp) {
|
||||||
this.appImManager.openScheduled(this.chat.peerId);
|
this.appImManager.openScheduled(this.chat.peerId);
|
||||||
}
|
}
|
||||||
}).show();
|
}, canSendWhenOnline).show();
|
||||||
};
|
};
|
||||||
|
|
||||||
public setUnreadCount() {
|
public setUnreadCount() {
|
||||||
|
@ -28,7 +28,7 @@ const checkDate = (date: Date) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default class PopupSchedule extends PopupDatePicker {
|
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, {
|
super(checkDate(initDate), onPick, {
|
||||||
noButtons: true,
|
noButtons: true,
|
||||||
noTitle: true,
|
noTitle: true,
|
||||||
@ -43,9 +43,11 @@ export default class PopupSchedule extends PopupDatePicker {
|
|||||||
this.element.classList.add('popup-schedule');
|
this.element.classList.add('popup-schedule');
|
||||||
this.header.append(this.controlsDiv);
|
this.header.append(this.controlsDiv);
|
||||||
this.title.replaceWith(this.monthTitle);
|
this.title.replaceWith(this.monthTitle);
|
||||||
|
this.body.append(this.btnConfirm);
|
||||||
|
|
||||||
|
if(canSendWhenOnline) {
|
||||||
const btnSendWhenOnline = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: 'Schedule.SendWhenOnline'});
|
const btnSendWhenOnline = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: 'Schedule.SendWhenOnline'});
|
||||||
this.body.append(this.btnConfirm, btnSendWhenOnline);
|
this.body.append(btnSendWhenOnline);
|
||||||
|
|
||||||
attachClickEvent(btnSendWhenOnline, () => {
|
attachClickEvent(btnSendWhenOnline, () => {
|
||||||
onPick(SEND_WHEN_ONLINE_TIMESTAMP);
|
onPick(SEND_WHEN_ONLINE_TIMESTAMP);
|
||||||
@ -53,3 +55,4 @@ export default class PopupSchedule extends PopupDatePicker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -427,6 +427,10 @@ export class AppUsersManager {
|
|||||||
return '+' + formatPhoneNumber(phone).formatted;
|
return '+' + formatPhoneNumber(phone).formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isUserOnlineVisible(id: number) {
|
||||||
|
return this.getUserStatusForSort(id) > 3;
|
||||||
|
}
|
||||||
|
|
||||||
public getUserStatusForSort(status: User['status'] | number) {
|
public getUserStatusForSort(status: User['status'] | number) {
|
||||||
if(typeof(status) === 'number') {
|
if(typeof(status) === 'number') {
|
||||||
status = this.getUser(status).status;
|
status = this.getUser(status).status;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user