import {VersionType} from '@caj/helper/version';
import {APP_VERSION} from './appNonSaveVar';

export enum ThemeMode {
  Darkest = 0,
  Dark = 1,
  Light = 2,
}

export function applyUpdateChanges(appVar: any): Promise<void> {
  return new Promise<void>(function (resolve, reject) {
    appVar.version += 1;

    console.log(appVar.version);

    function finish() {
      resolve();
    }

    switch (appVar.version) {
      case 3: {
        let appVarF = appVar as PREFERENCES_VARS;

        appVar = appVarF;
        finish();
        break;
      }

      case 2: {
        let appVarF = appVar;

        appVar = appVarF;
        finish();
        break;
      }

      default: {
        finish();
        break;
      }
    }
  });
}

//these variables may be changed by the user and will be saved in storage

export interface PREFERENCES_VARS {
  version: VersionType;
  theme: ThemeMode;
}

export const preferences_vars_default: PREFERENCES_VARS = {
  version: APP_VERSION, //version of datatypes in storage
  theme: ThemeMode.Dark,
};
