import wixWindow from ‘wix-window’ ;
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
export function logInButton_click ( event ) {
wixWindow . openLightbox ( 'login' )
}
export function registerButton_click ( event ) {
wixWindow . openLightbox ( 'Sign up' )
}
export function profilePic_click ( event ) {
wixWindow . openLightbox ( 'Sign up' )
}
export function continueWithoutAccountButton_click ( event ) {
$w ( "#welcomeScreen" ). hide ();
}
$w . onReady (() => {
**if** ( wixUsers . currentUser . loggedIn ) {
**if** ( wixUsers . currentUser . loggedIn ) {
$w ( "#welcomeScreen" ). hide ();
} **else** {
$w ( "#welcomeScreen" ). show ();
}
}
if ( wixUsers . currentUser . loggedIn ) {
let user = wixUsers . currentUser ;
wixData . query ( "Members" )
. eq ( "_id" , user . id )
. limit ( 1 )
. find ()
. then (( results ) => {
$w ( "#shareSomething" ). placeholder = "What's new " + results . items [ 0 ]. username ;
$w . onReady (() => {
waitForLoading ();
});
**function** waitForLoading () {
setTimeout (() => {
$w ( '#loadingScreen' ). hide ( 'FadeOut' );
}, 2000 );
}
}
, $w . onReady ( **function** () {
**let** user = wixUsers . currentUser ;
wixData . query ( “Members” )
. eq ( “_id” , user . id )
. limit ( 1 )
. find ()
. then (( results ) => {
$w ( “#loginCheck” ). text = "Hello " + results . items [ 0 ]. username ;
**function** loginCheck () {
**if** ( wixUsers . currentUser . loggedIn ) {
$w ( "#star" ). hide ();
**let** user = wixUsers . currentUser ;
wixData . query ( "Members" )
. eq ( "_id" , user . id )
. limit ( 1 )
. find ()
. then (( results ) => {
$w ( "#loginCheck" ). text = "Hello " + results . items [ 0 ]. username ;
});
} **else** {
$w ( "#loginCheck" ). text = "Please log in." ;
$w ( "#star" ). show ();
}
} //there is an error here.