Skip to content

Commit 1b45701

Browse files
committed
improve build subscription
1 parent 3210086 commit 1b45701

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/models/bundled-application-store/set-up-bundled-application-ws.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export const setUpBundledApplicationWs = (rootStore: RootStore, appcenterApi: Ap
5252
subBranches.map(async (branch) => {
5353
const ws = await AppWebSocketChannel.connect(appcenterApi, branch)
5454
const sub = ws.events.subscribe((event) => {
55-
console.log(event)
5655
if (event.type === 'buildUpdated') {
5756
rootStore.branchStore.branches.get(branch.id)?.setBuild(event.data)
5857
}

src/websockets/app-websocket-channel.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export class AppWebSocketChannel {
8787
console.log(`open ws ${this._branch.name}`)
8888
this._socket.addListener((message) => this._onMessage(message))
8989
this._method(new WatchRepoMethod())
90+
if (this._branch?.lastBuild?.status === 'inProgress') {
91+
this._method(new BuildSubscribeMethod(this._branch.lastBuild?.buildId))
92+
this._subscribedBuildIds.add(this._branch.lastBuild?.buildId)
93+
}
9094

9195
this._heartbeatInterval = setInterval(() => {
9296
this._socket.send(new WsHeartBeat().toJson())
@@ -95,10 +99,10 @@ export class AppWebSocketChannel {
9599

96100
private _onMessage(message: Message) {
97101
if (message.type !== 'Text') {
102+
console.debug(message)
98103
return
99104
}
100105
const event: WsAppEvent = message.data ? JSON.parse(message.data) : {}
101-
102106
if (event.type === 'buildUpdated') {
103107
if (event.data.sourceBranch === this._branch.name) {
104108
if (!this._subscribedBuildIds.has(event.data.id)) {
@@ -108,8 +112,10 @@ export class AppWebSocketChannel {
108112
// TODO: maybe only emit for current branches
109113
this._eventSubject.next(event)
110114
}
111-
} else {
115+
} else if (event.type === 'logConsoleLines') {
112116
this._eventSubject.next(event)
117+
} else {
118+
console.debug(message)
113119
}
114120
}
115121

0 commit comments

Comments
 (0)