| 168 | protected updateListener; |
| 169 | |
| 170 | public initFrontendMode() { |
| 171 | this.modes.frontend = true; |
| 172 | this.updateListener = emitter.on( |
| 173 | 'update.*', |
| 174 | data => { |
| 175 | con.log('update', data); |
| 176 | if (data.cacheKey) { |
| 177 | const item = this.templist.find(el => el.cacheKey === data.cacheKey); |
| 178 | con.log(item); |
| 179 | if (item && data.state) { |
| 180 | item.watchedEp = data.state.episode; |
| 181 | item.score = data.state.score; |
| 182 | item.status = data.state.status; |
| 183 | } |
| 184 | } |
| 185 | }, |
| 186 | { objectify: true }, |
| 187 | ); |
| 188 | } |
| 189 | |
| 190 | public destroy() { |
| 191 | if (this.updateListener) { |