(id)
| 95 | } |
| 96 | |
| 97 | async get(id) { |
| 98 | if (this.map.has(id)) { |
| 99 | return this.map.get(id); |
| 100 | } |
| 101 | const {[id]: ctrlSession} = await chrome.storage.session.get(id); |
| 102 | if (ctrlSession) { |
| 103 | const contrConstructor = getControllerClass(ctrlSession.mainType); |
| 104 | const ctrl = new contrConstructor(); |
| 105 | ctrl.mainType = ctrlSession.mainType; // as mainType in the session might not be default mainType |
| 106 | ctrl.id = id; |
| 107 | ctrl.state = ctrlSession.state; |
| 108 | this.map.set(id, ctrl); |
| 109 | for (const peer of ctrlSession.peers) { |
| 110 | const peerCtrl = await this.get(peer.id); |
| 111 | ctrl.peers[peer.peerType] = peerCtrl; |
| 112 | peerCtrl.peers[ctrl.peerType] = ctrl; |
| 113 | } |
| 114 | return ctrl; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | set(id, ctrl) { |
| 119 | this.map.set(id, ctrl); |
no test coverage detected