changes
This commit is contained in:
@@ -56,6 +56,8 @@ export class FastcheckPage {
|
||||
popupError = signal<string>('');
|
||||
webSessionId = signal<string>('');
|
||||
paid = signal<boolean>(false);
|
||||
loginOnly = signal<boolean>(false);
|
||||
sessionToken = signal<string>(localStorage.getItem('fc_session') ?? '');
|
||||
private pollHandle: ReturnType<typeof setInterval> | null = null;
|
||||
private lastLookedUpNumber = '';
|
||||
|
||||
@@ -113,6 +115,7 @@ export class FastcheckPage {
|
||||
return;
|
||||
}
|
||||
this.error.set('');
|
||||
this.loginOnly.set(false);
|
||||
this.openPopup();
|
||||
}
|
||||
|
||||
@@ -122,6 +125,32 @@ export class FastcheckPage {
|
||||
this.paid.set(false);
|
||||
this.popupLoading.set(true);
|
||||
|
||||
const existing = this.sessionToken();
|
||||
if (existing) {
|
||||
this.http.get<WebSessionResponse>(`${FASTCHECK_API}/websession/${existing}`).subscribe({
|
||||
next: (res) => {
|
||||
if (res?.Status) {
|
||||
this.popupLoading.set(false);
|
||||
this.webSessionId.set(existing);
|
||||
if (this.loginOnly()) {
|
||||
this.paid.set(true);
|
||||
} else {
|
||||
this.acceptFastcheck(existing);
|
||||
}
|
||||
} else {
|
||||
this.sessionToken.set('');
|
||||
this.createNewSession();
|
||||
}
|
||||
},
|
||||
error: () => { this.sessionToken.set(''); this.createNewSession(); }
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.createNewSession();
|
||||
}
|
||||
|
||||
private createNewSession(): void {
|
||||
this.http.get<WebSessionResponse>(`${FASTCHECK_API}/websession`).subscribe({
|
||||
next: (res) => {
|
||||
this.popupLoading.set(false);
|
||||
@@ -142,13 +171,20 @@ export class FastcheckPage {
|
||||
closePopup(): void {
|
||||
this.popupOpen.set(false);
|
||||
this.stopPolling();
|
||||
if (this.webSessionId()) {
|
||||
if (this.loginOnly() && this.paid()) {
|
||||
// Keep session alive — user is logged in, preserve token for next action.
|
||||
const tok = this.webSessionId();
|
||||
localStorage.setItem('fc_session', tok);
|
||||
this.sessionToken.set(tok);
|
||||
} else if (this.webSessionId()) {
|
||||
// Best-effort logout; ignore errors.
|
||||
this.http
|
||||
.request('DELETE', `${FASTCHECK_API}/websession/${this.webSessionId()}`, {
|
||||
body: { sessionId: this.webSessionId() }
|
||||
})
|
||||
.subscribe({ error: () => undefined });
|
||||
localStorage.removeItem('fc_session');
|
||||
this.sessionToken.set('');
|
||||
}
|
||||
this.webSessionId.set('');
|
||||
}
|
||||
@@ -162,7 +198,11 @@ export class FastcheckPage {
|
||||
next: (res) => {
|
||||
if (res?.Status) {
|
||||
this.stopPolling();
|
||||
this.acceptFastcheck(sessionId);
|
||||
if (this.loginOnly()) {
|
||||
this.paid.set(true);
|
||||
} else {
|
||||
this.acceptFastcheck(sessionId);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: () => undefined
|
||||
@@ -285,9 +325,7 @@ export class FastcheckPage {
|
||||
}
|
||||
|
||||
shareByTelegram(): void {
|
||||
const num = this.fastcheckNumber();
|
||||
const amount = this.fastcheckAmount();
|
||||
const text = encodeURIComponent(`fastCHECK: ${num} — ${amount} ₽`);
|
||||
window.open(`https://t.me/share/url?url=https%3A%2F%2Fqr.vitanova.network%2F&text=${text}`, '_blank');
|
||||
this.loginOnly.set(true);
|
||||
this.openPopup();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user