fix lint and test
This commit is contained in:
parent
f993c87a7c
commit
9ae8096021
|
|
@ -10,7 +10,7 @@ import { BroadcastChannel } from 'broadcast-channel';
|
||||||
type TabState = {
|
type TabState = {
|
||||||
id: string;
|
id: string;
|
||||||
lastActiveTime: number; // ユーザーが最後に操作した時間
|
lastActiveTime: number; // ユーザーが最後に操作した時間
|
||||||
lastHeartbeat: number; // 最後に生存報告を受け取った時間
|
lastHeartbeat: number; // 最後に生存報告を受け取った時間
|
||||||
};
|
};
|
||||||
|
|
||||||
type BroadcastMessage = {
|
type BroadcastMessage = {
|
||||||
|
|
@ -44,7 +44,7 @@ export class TabManager extends EventEmitter<EventTypes> {
|
||||||
// 定数設定
|
// 定数設定
|
||||||
private readonly BROADCAST_CHANNEL_NAME = 'tabSync';
|
private readonly BROADCAST_CHANNEL_NAME = 'tabSync';
|
||||||
private readonly HEARTBEAT_INTERVAL = 1000; // 1秒ごとに定期処理
|
private readonly HEARTBEAT_INTERVAL = 1000; // 1秒ごとに定期処理
|
||||||
private readonly PEER_TIMEOUT = 3000; // 3秒連絡がなければ死亡とみなす
|
private readonly PEER_TIMEOUT = 3000; // 3秒連絡がなければ死亡とみなす
|
||||||
|
|
||||||
constructor(tabId: string) {
|
constructor(tabId: string) {
|
||||||
super();
|
super();
|
||||||
|
|
@ -183,7 +183,7 @@ export class TabManager extends EventEmitter<EventTypes> {
|
||||||
|
|
||||||
if (this.isMain !== amILeader) {
|
if (this.isMain !== amILeader) {
|
||||||
this.isMain = amILeader;
|
this.isMain = amILeader;
|
||||||
if (window.document.hasFocus()) {
|
if (window.document.hasFocus() && 'requestIdleCallback' in window) {
|
||||||
window.requestIdleCallback(() => {
|
window.requestIdleCallback(() => {
|
||||||
this.onChangeStatus(this.isMain);
|
this.onChangeStatus(this.isMain);
|
||||||
}, { timeout: 100 });
|
}, { timeout: 100 });
|
||||||
|
|
@ -208,7 +208,7 @@ export class TabManager extends EventEmitter<EventTypes> {
|
||||||
* リソースの解放
|
* リソースの解放
|
||||||
*/
|
*/
|
||||||
public destroy() {
|
public destroy() {
|
||||||
if (this.heartbeatIntervalId != null) clearInterval(this.heartbeatIntervalId);
|
if (this.heartbeatIntervalId != null) window.clearInterval(this.heartbeatIntervalId);
|
||||||
window.removeEventListener('focus', this.updateActivity);
|
window.removeEventListener('focus', this.updateActivity);
|
||||||
window.removeEventListener('click', this.updateActivity);
|
window.removeEventListener('click', this.updateActivity);
|
||||||
window.removeEventListener('keydown', this.updateActivity);
|
window.removeEventListener('keydown', this.updateActivity);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue