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