@salesforcedevs/dx-components 1.2.2-avatar-button-4 → 1.2.2-avatar-button-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -105,17 +105,6 @@ export default class AvatarButton extends LightningElement {
|
|
|
105
105
|
|
|
106
106
|
window.addEventListener("tbid-login", this.handleSsoLogin);
|
|
107
107
|
window.addEventListener("tbid-logout", this.handleSsoLogout);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
disconnectedCallback() {
|
|
111
|
-
window.removeEventListener("tbid-login", this.handleSsoLogin);
|
|
112
|
-
window.removeEventListener("tbid-logout", this.handleSsoLogout);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
renderedCallback() {
|
|
116
|
-
if (this._hasRendered) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
108
|
|
|
120
109
|
const isWidgetDisabled = window.SFIDWidget?.disabled;
|
|
121
110
|
const isWidgetLoggedIn = window.SFIDWidget?.openid_response;
|
|
@@ -133,21 +122,24 @@ export default class AvatarButton extends LightningElement {
|
|
|
133
122
|
setTimeout(() => {
|
|
134
123
|
if (!window.SFIDWidget?.openid_response) {
|
|
135
124
|
// this.trackLogin(); TODO: track only clicks
|
|
136
|
-
this.platformEventsSubscribe();
|
|
137
125
|
this.requestUserInfo();
|
|
138
126
|
}
|
|
139
127
|
}, 1000);
|
|
140
128
|
} else {
|
|
141
129
|
if (this.isLoading) {
|
|
142
130
|
// This was a login.
|
|
143
|
-
console.log("Subscribing to platform events!");
|
|
144
|
-
this.platformEventsSubscribe();
|
|
145
131
|
// this.trackLogin(); TODO: track only clicks
|
|
146
132
|
}
|
|
147
133
|
this.requestUserInfo();
|
|
148
134
|
}
|
|
149
135
|
}
|
|
150
136
|
|
|
137
|
+
disconnectedCallback() {
|
|
138
|
+
window.removeEventListener("tbid-login", this.handleSsoLogin);
|
|
139
|
+
window.removeEventListener("tbid-logout", this.handleSsoLogout);
|
|
140
|
+
this.teardownEventSource();
|
|
141
|
+
}
|
|
142
|
+
|
|
151
143
|
private handleUserDataChange = ({ data }: EventSourceEvent) => {
|
|
152
144
|
let parsedEventData: any;
|
|
153
145
|
|
|
@@ -206,7 +198,6 @@ export default class AvatarButton extends LightningElement {
|
|
|
206
198
|
};
|
|
207
199
|
|
|
208
200
|
private platformEventsSubscribe = () => {
|
|
209
|
-
console.log("platform events subscribe");
|
|
210
201
|
this.teardownEventSource();
|
|
211
202
|
this.setupEventSource();
|
|
212
203
|
};
|
|
@@ -348,6 +339,9 @@ export default class AvatarButton extends LightningElement {
|
|
|
348
339
|
const userInfoRes = await fetch(TBID_API_USERINFO_URL);
|
|
349
340
|
|
|
350
341
|
if (userInfoRes.ok) {
|
|
342
|
+
if (!this.eventSource) {
|
|
343
|
+
this.setupEventSource();
|
|
344
|
+
}
|
|
351
345
|
const userInfo = await userInfoRes.json();
|
|
352
346
|
this.updateAvatarWithUserInfo(userInfo);
|
|
353
347
|
this._didReceiveUserInfo = true;
|