Commit 1c9cca63 authored by Marcelo Rivera's avatar Marcelo Rivera

(fix): signup modal should appear every time a logged out user interacts

1 merge request!602(fix): signup modal issues
Pipeline #89575879 passed with stages
in 46 minutes and 22 seconds
import { Component } from '@angular/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { Session } from '../../../services/session';
import { ScrollService } from '../../../services/ux/scroll';
import { SignupModal } from './signup';
import { Storage } from '../../../services/storage';
@Component({
selector: 'm-modal-signup-on-scroll',
template: `
<m-modal-signup open="true" *ngIf="open"></m-modal-signup>
<m-modal-signup (onClose)="onModalClosed()" #modal></m-modal-signup>
`,
})
export class SignupOnScrollModal {
export class SignupOnScrollModal implements OnInit, OnDestroy {
open: boolean = false;
route: string = '';
scroll_listener;
......@@ -21,10 +23,13 @@ export class SignupOnScrollModal {
routerSubscription: Subscription;
@ViewChild('modal', { static: true }) modal: SignupModal;
constructor(
public session: Session,
public router: Router,
public scroll: ScrollService
public scroll: ScrollService,
private storage: Storage
) {}
ngOnInit() {
......@@ -66,9 +71,13 @@ export class SignupOnScrollModal {
default:
this.scroll_listener = this.scroll.listen(e => {
if (this.scroll.view.scrollTop > 20) {
if (window.localStorage.getItem('hideSignupModal'))
if (window.localStorage.getItem('hideSignupModal')) {
this.open = false;
else this.open = true;
this.modal.open = false;
} else {
this.open = true;
this.modal.open = true;
}
}
}, 100);
}
......@@ -90,4 +99,11 @@ export class SignupOnScrollModal {
this.scroll.unListen(this.scroll_listener);
}
}
onModalClosed() {
if (this.open) {
this.storage.set('hideSignupModal', '1');
this.open = false;
}
}
}
......@@ -3,6 +3,8 @@ import {
ChangeDetectorRef,
NgZone,
ApplicationRef,
Output,
EventEmitter,
} from '@angular/core';
import { Location } from '@angular/common';
import { Router } from '@angular/router';
......@@ -19,6 +21,7 @@ import { SiteService } from '../../../common/services/site.service';
templateUrl: 'signup.html',
})
export class SignupModal {
@Output('onClose') onClosed: EventEmitter<any> = new EventEmitter<any>();
open: boolean = false;
route: string = '';
minds = window.Minds;
......@@ -74,6 +77,7 @@ export class SignupModal {
break;
default:
this.service.close();
this.onClosed.emit();
}
}
......@@ -174,6 +178,7 @@ export class SignupModal {
onClose(e: boolean) {
this.service.close();
this.onClosed.emit();
if (
this.display === 'login' ||
this.display === 'register' ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment