
Handle instant peer changing correctly Display unread badge only in chats Delay opening on ESG hover Lazy load sticker sets thumbs Fix onchanging profile info flick Hide shared media menu tabs Scroll on click to shared media tab Fix media tabs scroll position Fix voice messages playback in search on iOS Hover & play on waveform Better input fields border animation Don't lock scroll on horizontal scrollables if unnecessary Restrict editing & deleting outgoing messages Display avatars in notifications Open chat on notification click Don't close country selector on scrolling Select single country by enter Fix jumping text in context menus Changed preloader color
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
/*
|
|
* https://github.com/morethanwords/tweb
|
|
* Copyright (C) 2019-2021 Eduard Kuzmenko
|
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
*
|
|
* Originally from:
|
|
* https://github.com/zhukov/webogram
|
|
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
|
|
* https://github.com/zhukov/webogram/blob/master/LICENSE
|
|
*/
|
|
|
|
import { MOUNT_CLASS_TO } from '../../config/debug';
|
|
import { tsNow } from '../../helpers/date';
|
|
import sessionStorage from '../sessionStorage';
|
|
|
|
export class ServerTimeManager {
|
|
public timestampNow = tsNow(true);
|
|
public midnightNoOffset = this.timestampNow - (this.timestampNow % 86400);
|
|
public midnightOffseted = new Date();
|
|
|
|
public midnightOffset = this.midnightNoOffset - (Math.floor(+this.midnightOffseted / 1000));
|
|
|
|
public serverTimeOffset = 0; // in seconds
|
|
public timeParams = {
|
|
midnightOffset: this.midnightOffset,
|
|
serverTimeOffset: this.serverTimeOffset
|
|
};
|
|
|
|
constructor() {
|
|
this.midnightOffseted.setHours(0, 0, 0, 0);
|
|
|
|
sessionStorage.get('server_time_offset').then((to) => {
|
|
if(to) {
|
|
this.serverTimeOffset = to;
|
|
this.timeParams.serverTimeOffset = to;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
const serverTimeManager = new ServerTimeManager();
|
|
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.serverTimeManager = serverTimeManager);
|
|
export default serverTimeManager;
|