Skip to content

Commit e71f1aa

Browse files
feat: making desktop login less confusing
This is a total hack but trying to make the desktop login process a little less confusing. When we first load the UI from twitch giving us a token, we attempt to put our token on the clipboard. Then we observe the clipboard for the token disappearing. We assume the clipboard being cleared means the application logged in successfully. closes nullinside-development-group/nullinside-twitch-streaming-tools#56
1 parent a015459 commit e71f1aa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/src/app/view/login-landing-desktop/login-landing-desktop.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ export class LoginLandingDesktopComponent implements OnInit {
6464
expiresUtc: oAuth.expiresUtc
6565
};
6666

67-
this.desktopData = JSON.stringify(oAuth);
68-
navigator.clipboard.writeText(this.desktopData);
69-
this.loading = false;
70-
this.timer?.unsubscribe();
67+
// DO NOT assign this.desktopData until AFTER you update the clipboard successfully.
68+
// The absence of a value on this.desktopData is what tells the application we haven't logged in yet.
69+
const json = JSON.stringify(oAuth);
70+
navigator.clipboard.writeText(json);
71+
this.desktopData = json;
7172

73+
this.loading = false;
7274
this.timer = interval(1000)
7375
.subscribe({
7476
next: _ => {
@@ -89,7 +91,7 @@ export class LoginLandingDesktopComponent implements OnInit {
8991
try {
9092
navigator.clipboard.readText().then(text => {
9193
// If the text matches what we put on the clipboard then we aren't signed in yet.
92-
if (text === this.desktopData) {
94+
if (undefined === this.desktopData || text === this.desktopData) {
9395
return;
9496
}
9597

0 commit comments

Comments
 (0)