Removed extractRoleFromEvent from ActiveRoleSynchronizer

This commit is contained in:
Michael Rogers 2023-07-13 09:44:37 -05:00
parent 81c33efc6e
commit 9050b7a2da
2 changed files with 10 additions and 5 deletions

View File

@ -16,13 +16,14 @@ class ActiveRoleSynchronizer {
}; };
} }
subscribeToRoleChanges(callback) { subscribeToRoleChanges(callback) {
this.#roleChannel.addEventListener('message', this.extractRoleFromEvent(callback)); this.#roleChannel.addEventListener('message', callback);
} }
unsubscribeFromRoleChanges(callback) { unsubscribeFromRoleChanges(callback) {
this.#roleChannel.removeEventListener('message', this.extractRoleFromEvent(callback)); this.#roleChannel.removeEventListener('message', callback);
} }
setActiveRoleFromChannelMessage(role) { setActiveRoleFromChannelMessage(event) {
const role = event.data;
this.openmct.user.setActiveRole(role); this.openmct.user.setActiveRole(role);
} }
broadcastNewRole(role) { broadcastNewRole(role) {

View File

@ -46,11 +46,11 @@ export default {
async mounted() { async mounted() {
this.getUserInfo(); this.getUserInfo();
this.roleChannel = new ActiveRoleSynchronizer(this.openmct); this.roleChannel = new ActiveRoleSynchronizer(this.openmct);
this.roleChannel.subscribeToRoleChanges(this.setRoleSelection); this.roleChannel.subscribeToRoleChanges(this.onRoleChange);
await this.fetchOrPromptForRole(); await this.fetchOrPromptForRole();
}, },
beforeDestroy() { beforeDestroy() {
this.roleChannel.unsubscribeFromRoleChanges(this.setRoleSelection); this.roleChannel.unsubscribeFromRoleChanges(this.onRoleChange);
}, },
methods: { methods: {
async getUserInfo() { async getUserInfo() {
@ -97,6 +97,10 @@ export default {
] ]
}); });
}, },
onRoleChange(event) {
const role = event.data;
this.setRoleSelection(role);
},
setRoleSelection(role) { setRoleSelection(role) {
this.role = role; this.role = role;
}, },