Send when online
This commit is contained in:
parent
b09a7dff5b
commit
ff6174a4ea
@ -73,6 +73,7 @@ import assumeType from "../../helpers/assumeType";
|
||||
import { EmoticonsDropdown } from "../emoticonsDropdown";
|
||||
import debounce from "../../helpers/schedulers/debounce";
|
||||
import { formatNumber } from "../../helpers/number";
|
||||
import { SEND_WHEN_ONLINE_TIMESTAMP } from "../../lib/mtproto/constants";
|
||||
|
||||
const USE_MEDIA_TAILS = false;
|
||||
const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([
|
||||
@ -1510,8 +1511,12 @@ export default class ChatBubbles {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const isScheduled = this.chat.type === 'scheduled';
|
||||
|
||||
if(today.getTime() === date.getTime()) {
|
||||
dateElement = i18n(this.chat.type === 'scheduled' ? 'Chat.Date.ScheduledForToday' : 'Date.Today');
|
||||
dateElement = i18n(isScheduled ? 'Chat.Date.ScheduledForToday' : 'Date.Today');
|
||||
} else if(isScheduled && message.date === SEND_WHEN_ONLINE_TIMESTAMP) {
|
||||
dateElement = i18n('MessageScheduledUntilOnline');
|
||||
} else {
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
day: 'numeric',
|
||||
@ -1527,15 +1532,11 @@ export default class ChatBubbles {
|
||||
options
|
||||
}).element;
|
||||
|
||||
if(this.chat.type === 'scheduled') {
|
||||
if(isScheduled) {
|
||||
dateElement = i18n('Chat.Date.ScheduledFor', [dateElement]);
|
||||
}
|
||||
}
|
||||
|
||||
/* if(this.chat.type === 'scheduled') {
|
||||
str = 'Scheduled for ' + str;
|
||||
} */
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.className = 'bubble service is-date';
|
||||
const bubbleContent = document.createElement('div');
|
||||
|
@ -4,6 +4,9 @@
|
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
import { attachClickEvent } from "../../helpers/dom/clickEvent";
|
||||
import { SEND_WHEN_ONLINE_TIMESTAMP } from "../../lib/mtproto/constants";
|
||||
import Button from "../button";
|
||||
import PopupDatePicker from "./datePicker";
|
||||
|
||||
const getMinDate = () => {
|
||||
@ -13,20 +16,26 @@ const getMinDate = () => {
|
||||
return date;
|
||||
};
|
||||
|
||||
const getMaxDate = () => {
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
date.setDate(date.getDate() - 1);
|
||||
return date;
|
||||
};
|
||||
|
||||
const checkDate = (date: Date) => {
|
||||
return date.getTime() > getMaxDate().getTime() ? new Date() : date;
|
||||
};
|
||||
|
||||
export default class PopupSchedule extends PopupDatePicker {
|
||||
constructor(initDate: Date, onPick: (timestamp: number) => void) {
|
||||
super(initDate, onPick, {
|
||||
super(checkDate(initDate), onPick, {
|
||||
noButtons: true,
|
||||
noTitle: true,
|
||||
closable: true,
|
||||
withConfirm: true,
|
||||
minDate: getMinDate(),
|
||||
maxDate: (() => {
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
date.setDate(date.getDate() - 1);
|
||||
return date;
|
||||
})(),
|
||||
maxDate: getMaxDate(),
|
||||
withTime: true,
|
||||
showOverflowMonths: true
|
||||
});
|
||||
@ -34,6 +43,13 @@ 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);
|
||||
|
||||
attachClickEvent(btnSendWhenOnline, () => {
|
||||
onPick(SEND_WHEN_ONLINE_TIMESTAMP);
|
||||
this.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -548,6 +548,7 @@ const lang = {
|
||||
"LinkNotFound": "Unfortunately, you can\'t access this message. You are not a member of the chat where it was posted.",
|
||||
"Create": "Create",
|
||||
"ViewDiscussion": "View discussion",
|
||||
"MessageScheduledUntilOnline": "Scheduled until online",
|
||||
|
||||
// * macos
|
||||
"AccountSettings.Filters": "Chat Folders",
|
||||
@ -562,7 +563,6 @@ const lang = {
|
||||
"Chat.CopySelectedText": "Copy Selected Text",
|
||||
"Chat.Confirm.Unpin": "Would you like to unpin this message?",
|
||||
"Chat.Date.ScheduledFor": "Scheduled for %@",
|
||||
//"Chat.Date.ScheduledUntilOnline": "Scheduled until online",
|
||||
"Chat.Date.ScheduledForToday": "Scheduled for today",
|
||||
"Chat.DropTitle": "Drop files here to send them",
|
||||
"Chat.DropQuickDesc": "in a quick way",
|
||||
@ -791,7 +791,7 @@ const lang = {
|
||||
"ScheduleController.at": "at",
|
||||
"Schedule.SendToday": "Send today at %@",
|
||||
"Schedule.SendDate": "Send on %@ at %@",
|
||||
//"Schedule.SendWhenOnline": "Send When Online",
|
||||
"Schedule.SendWhenOnline": "Send When Online",
|
||||
"Stickers.Recent": "Recent",
|
||||
//"Stickers.Favorite": "Favorite",
|
||||
"Text.Context.Copy.Username": "Copy Username",
|
||||
|
1
src/lib/mtproto/constants.ts
Normal file
1
src/lib/mtproto/constants.ts
Normal file
@ -0,0 +1 @@
|
||||
export const SEND_WHEN_ONLINE_TIMESTAMP = 0x7FFFFFFE;
|
Loading…
Reference in New Issue
Block a user