29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import ActivityScheduleService from "./module/Config/ActivityScheduleService";
|
|
|
|
const { ccclass } = cc._decorator;
|
|
|
|
/** Shared home refresh lifecycle, independent of any particular activity entry. */
|
|
@ccclass
|
|
export default class HomeActivitySchedule extends cc.Component {
|
|
private visibility = 0;
|
|
onEnable(): void {
|
|
cc.game.on(cc.game.EVENT_SHOW, this.onShow, this);
|
|
cc.game.on(cc.game.EVENT_HIDE, this.onHide, this);
|
|
this.onShow();
|
|
}
|
|
private tick = (): void => { ActivityScheduleService.tick(); };
|
|
private onShow = (): void => {
|
|
const visibility = ++this.visibility;
|
|
this.unschedule(this.tick);
|
|
this.schedule(this.tick, 1);
|
|
this.tick();
|
|
void ActivityScheduleService.checkCloudRiseOpening(() => visibility === this.visibility);
|
|
};
|
|
private onHide = (): void => { this.visibility++; this.unschedule(this.tick); };
|
|
onDisable(): void {
|
|
this.onHide();
|
|
cc.game.off(cc.game.EVENT_SHOW, this.onShow, this);
|
|
cc.game.off(cc.game.EVENT_HIDE, this.onHide, this);
|
|
}
|
|
}
|