Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
优化直播状态更新,修复上下播提醒bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KinoriN committed Oct 16, 2019
1 parent e029a16 commit 34a6e26
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
8 changes: 3 additions & 5 deletions electron/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const ipcInit = () => {
event.reply('getFollowedVtbMidsReply', vtbInfosService.getFollowedVtbMids());
});
ipcMain.on('getFollowLists', (event: Electron.IpcMainEvent) => {
console.log(FollowListService.getFollowLists())
event.reply('getFollowListsReply', FollowListService.getFollowLists());
});
ipcMain.on('addFollowList', (event: Electron.IpcMainEvent, name: string) => {
Expand Down Expand Up @@ -80,7 +79,8 @@ const appInit = () => {
let lastLiveVtbs: number[] = [];
vtbInfosService.onUpdate((vtbInfos) => {
if (mainWin) {
const followVtbs = FollowListService.getFollowLists().map((followList: FollowList) => ([...followList.mids]))[0];
const followVtbs = vtbInfosService.getFollowedVtbMids();
mainWin.webContents.send('updateVtbInfos', vtbInfosService.getFollowedVtbInfos());
let nowLiveFollowedVtbs = vtbInfos.filter((vtbInfo: VtbInfo) => (followVtbs.includes(vtbInfo.mid) && vtbInfo.liveStatus)).map((vtbInfo: VtbInfo) => vtbInfo.mid);
let upLiveFollowedVtbs: number[] = [];
let downLiveFollowedVtbs: number[] = [];
Expand All @@ -106,8 +106,6 @@ const appInit = () => {
ipcInit();
}
app.once('ready', () => {
mainWin = createMainWin(app, playerObjMap)
appInit();
vtbInfosService.onceUpdate(() => {
createMainWin(app, playerObjMap)
})
})
3 changes: 0 additions & 3 deletions electron/src/mainWinMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ export const createMainWinMenu = (app: Electron.App, players: Map<number, Player
[...players.values()].forEach((player: PlayerObj, index: number) => {
const row = Math.floor(index / Math.ceil(playerNum / betterRowNumber));
const col = index % Math.ceil(playerNum / betterRowNumber);
console.log(`${row} ${col}`)
try {
player.playerWin.setBounds({ x: display.bounds.x + col * playerWidth, y: display.bounds.y + row * playerHeight, height: playerHeight, width: playerWidth })
} catch (e) {
console.log(e);
console.log({ x: display.bounds.x + col * playerWidth, y: display.bounds.y + row * playerHeight, height: playerHeight, width: playerWidth })
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bili-dd-monitor",
"version": "0.0.11",
"version": "0.0.12",
"author": "kinori",
"scripts": {
"ng": "ng",
Expand Down Expand Up @@ -75,8 +75,8 @@
"output": "build"
},
"releaseInfo": {
"releaseName": "0.0.11",
"releaseNotes": "修复关注列表bug"
"releaseName": "0.0.12",
"releaseNotes": "优化直播状态更新,修复上下播提醒bug"
},
"win": {
"icon": "./public/icon256.ico"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export class AppLivingComponent implements OnInit {
})
}
ngOnInit() {
this.vtbInfoService.getFollowedVtbInfos().subscribe((followedVtbInfos: VtbInfo[]) => {
this.followedVtbInfos = followedVtbInfos;
this.loadData();
this.vtbInfoService.updateVtbInfos().subscribe((vtbInfos: VtbInfo[]) => {
this.followedVtbInfos = vtbInfos;
this.zone.run(() => {

})
})
this.timer = setInterval(this.loadData, 2000);
}
ngOnDestroy(): void {
clearInterval(this.timer);
Expand Down
8 changes: 8 additions & 0 deletions projects/app/src/app/services/vtb-info.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ export class VtbInfoService {
})
break;
}
case 'updateVtbInfos': {
this.electron.ipcRenderer.on('updateVtbInfos', ((event: Electron.Event, vtbInfos: VtbInfo[]) => {
observer.next(vtbInfos);
}))
}
}
}
}
updateVtbInfos(): Observable<VtbInfo[]> {
return new Observable(this.sequenceSubscriber('updateVtbInfos'));
}
getVtbInfos(): Observable<VtbInfo[]> {
this.electron.ipcRenderer.send('getVtbInfos');
return new Observable(this.sequenceSubscriber('getVtbInfos'));
Expand Down

0 comments on commit 34a6e26

Please sign in to comment.