@salesforcedevs/dx-components 1.2.2-avatar-button-2 → 1.2.2-avatar-button-4
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
|
@@ -73,8 +73,9 @@ export default class AvatarButton extends LightningElement {
|
|
|
73
73
|
private isLoading = false;
|
|
74
74
|
private settingsUrl = TBID_SETTINGS_URL;
|
|
75
75
|
private profileUrl = TBID_PROFILE_URL;
|
|
76
|
-
private _didReceiveUserInfo = false;
|
|
77
76
|
private eventSource?: EventSource;
|
|
77
|
+
private _hasRendered = false;
|
|
78
|
+
private _didReceiveUserInfo = false;
|
|
78
79
|
|
|
79
80
|
private get loginUrl() {
|
|
80
81
|
return `${TBID_API_LOGIN_URL}?startURL=${encodeURIComponent(
|
|
@@ -90,14 +91,31 @@ export default class AvatarButton extends LightningElement {
|
|
|
90
91
|
const searchParams = new URLSearchParams(window.location.search);
|
|
91
92
|
|
|
92
93
|
if (searchParams.get("loginSuccess") === "true") {
|
|
93
|
-
// clear the query param
|
|
94
94
|
this.isLoading = true;
|
|
95
|
+
// clear the query param
|
|
95
96
|
searchParams.delete("loginSuccess");
|
|
96
|
-
window.
|
|
97
|
+
window.history.replaceState(
|
|
98
|
+
null,
|
|
99
|
+
"",
|
|
100
|
+
`${window.location.pathname}${
|
|
101
|
+
window.location.hash
|
|
102
|
+
}${searchParams.toString()}`
|
|
103
|
+
);
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
window.addEventListener("tbid-login", this.handleSsoLogin);
|
|
100
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
|
+
}
|
|
101
119
|
|
|
102
120
|
const isWidgetDisabled = window.SFIDWidget?.disabled;
|
|
103
121
|
const isWidgetLoggedIn = window.SFIDWidget?.openid_response;
|
|
@@ -122,6 +140,7 @@ export default class AvatarButton extends LightningElement {
|
|
|
122
140
|
} else {
|
|
123
141
|
if (this.isLoading) {
|
|
124
142
|
// This was a login.
|
|
143
|
+
console.log("Subscribing to platform events!");
|
|
125
144
|
this.platformEventsSubscribe();
|
|
126
145
|
// this.trackLogin(); TODO: track only clicks
|
|
127
146
|
}
|
|
@@ -129,11 +148,6 @@ export default class AvatarButton extends LightningElement {
|
|
|
129
148
|
}
|
|
130
149
|
}
|
|
131
150
|
|
|
132
|
-
disconnectedCallback() {
|
|
133
|
-
window.removeEventListener("tbid-login", this.handleSsoLogin);
|
|
134
|
-
window.removeEventListener("tbid-logout", this.handleSsoLogout);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
151
|
private handleUserDataChange = ({ data }: EventSourceEvent) => {
|
|
138
152
|
let parsedEventData: any;
|
|
139
153
|
|
|
@@ -192,6 +206,7 @@ export default class AvatarButton extends LightningElement {
|
|
|
192
206
|
};
|
|
193
207
|
|
|
194
208
|
private platformEventsSubscribe = () => {
|
|
209
|
+
console.log("platform events subscribe");
|
|
195
210
|
this.teardownEventSource();
|
|
196
211
|
this.setupEventSource();
|
|
197
212
|
};
|