<commit_before>package com.thangiee.lolhangouts.ui.login

import com.parse.{GetCallback, ParseException, ParseObject, ParseQuery}
import com.thangiee.lolhangouts.data.Cached
import com.thangiee.lolhangouts.data.usecases.LoginUseCase._
import com.thangiee.lolhangouts.data.usecases._
import com.thangiee.lolhangouts.ui.core.Presenter
import com.thangiee.lolhangouts.ui.utils._

import scala.concurrent.ExecutionContext.Implicits.global

class LoginPresenter(view: LoginView, loginUseCase: LoginUseCase) extends Presenter {
  private var isGuestMode = false

  override def initialize(): Unit = {
    super.initialize()

    // don't run this code when first time opening the app since
    // the app will be redirected to region selection screen
    if (Cached.isFirstLaunch) {
      info("[*] checking for new app version")
      loginUseCase.loadAppVersion().map { oldVer =>
        val currentVersion = view.getCurrentAppVersion
        if (oldVer != currentVersion) {
          // check if app was updated and if it is, show changelog
          loginUseCase.updateAppVersion(currentVersion)
          runOnUiThread(view.showChangeLog())
        } else {
          // check if new version is available in the Play store
          ParseQuery.getQuery("AppVersion").getFirstInBackground(new GetCallback[ParseObject] {
            override def done(storeVersion: ParseObject, e: ParseException): Unit = {
              if (e == null && currentVersion != storeVersion.getString("version")) {
                runOnUiThread(view.showUpdateApp(storeVersion.getString("version")))
              }
            }
          })
        }
      }
    }
  }

  override def resume(): Unit = {
    super.resume()
    info("[*] loading login info")
    loginUseCase.loadLoginInfo().onSuccess {
      case (username, password, selectedRegion, isLoginOffline) => selectedRegion match {
        case Some(region) =><commit_msg>fix if statement check for first launch<commit_after>package com.thangiee.lolhangouts.ui.login

import com.parse.{GetCallback, ParseException, ParseObject, ParseQuery}
import com.thangiee.lolhangouts.data.Cached
import com.thangiee.lolhangouts.data.usecases.LoginUseCase._
import com.thangiee.lolhangouts.data.usecases._
import com.thangiee.lolhangouts.ui.core.Presenter
import com.thangiee.lolhangouts.ui.utils._

import scala.concurrent.ExecutionContext.Implicits.global

class LoginPresenter(view: LoginView, loginUseCase: LoginUseCase) extends Presenter {
  private var isGuestMode = false

  override def initialize(): Unit = {
    super.initialize()

    // don't run this code when first time opening the app since
    // the app will be redirected to region selection screen
    if (!Cached.isFirstLaunch) {
      info("[*] checking for new app version")
      loginUseCase.loadAppVersion().map { oldVer =>
        val currentVersion = view.getCurrentAppVersion
        if (oldVer != currentVersion) {
          // check if app was updated and if it is, show changelog
          loginUseCase.updateAppVersion(currentVersion)
          runOnUiThread(view.showChangeLog())
        } else {
          // check if new version is available in the Play store
          ParseQuery.getQuery("AppVersion").getFirstInBackground(new GetCallback[ParseObject] {
            override def done(storeVersion: ParseObject, e: ParseException): Unit = {
              if (e == null && currentVersion != storeVersion.getString("version")) {
                runOnUiThread(view.showUpdateApp(storeVersion.getString("version")))
              }
            }
          })
        }
      }
    }
  }

  override def resume(): Unit = {
    super.resume()
    info("[*] loading login info")
    loginUseCase.loadLoginInfo().onSuccess {
      case (username, password, selectedRegion, isLoginOffline) => selectedRegion match {
        case Some(region) =>
{'fraction_non_alphanumeric': 0.09643878346763712, 'fraction_numerical': 0.0, 'mean_word_length': 3.151024811218986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4507423', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1070, 'n_words': 264}