Skip to content

Commit

Permalink
Linting & Commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
erfanmola committed Oct 10, 2023
1 parent 772e34f commit 89db46e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
22 changes: 3 additions & 19 deletions webApp/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup>
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { onMounted } from 'vue';
import WebApp from '@twa-dev/sdk';
Expand All @@ -10,35 +9,20 @@
import { AppearanceProvider, LocaleProvider, AuthProvider } from '@erfanmola/televue';
import '@erfanmola/televue/style.css';
// Check if we are in dev mode
const devMode = (import.meta.env.MODE === 'development') && true;
// Retrive VITE_HEX_HMAC_SIGNATURE environment variable if available
const hex_hmac_signature = import.meta.env.VITE_HEX_HMAC_SIGNATURE;
// Try to retrieve the saved `locale` from LocalStorage if available
const locale = localStorage.getItem('dpxwallet_locale');
const slideTransition = ref('slide-left');
const router = useRouter();
onMounted(() => {
// Preload Audio files that we are going to use
Utils.PreLoadAudio('Success.mp3');
Utils.PreLoadAudio('Failed.mp3');
});
router.afterEach((to, from) => {
const toPath = to.path.split('/').filter((item) => item.length).length;
const fromPath = from.path.split('/').filter((item) => item.length).length;
slideTransition.value = (toPath) < (fromPath) ? 'slide-right' : 'slide-left';
});
WebApp.setHeaderColor('secondary_bg_color');
WebApp.setBackgroundColor('secondary_bg_color');
WebApp.expand();
Expand All @@ -57,7 +41,7 @@
</LocaleProvider>
</AppearanceProvider>

<template #unauthorized>
<template #unauthorized v-if="hex_hmac_signature">
Your client is not authorized, please use this WebApp from a valid Telegram Client
</template>
</component>
Expand Down
25 changes: 11 additions & 14 deletions webApp/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ let Audios = {};

const Utils = {

// Wrapper for Toastify function
Toast: (text, duration = 2000) => {
Toastify({text: text, duration: duration, gravity: 'top', position: 'left', style: {background: 'var(--tg-theme-text-color)', color: 'var(--tg-theme-bg-color)'}}).showToast();
},

// Send request to DPX API & return reponse
DPXSendRequest: async (endpoint = '/', data = [], method = 'POST', i18n = null) => {

const FD = new FormData();
Expand Down Expand Up @@ -72,6 +74,7 @@ const Utils = {

},

// Preload audio file
PreLoadAudio: (name) => {

if (Audios[name] === undefined) {
Expand All @@ -82,12 +85,14 @@ const Utils = {

},

// Play an audio file
PlayAudio: (name) => {

Audios[name].play();

},

// a prefered way of showing Telegram WebApp prompts and handling it's callback
Prompt: (title = null, text, options) => {

if (WebApp.isVersionAtLeast('6.2')) {
Expand Down Expand Up @@ -141,6 +146,7 @@ const Utils = {

},

// Scan QRCode if supported
ScanQRCode: (text, onReceive) => {

if (WebApp.isVersionAtLeast('6.4')) {
Expand Down Expand Up @@ -172,22 +178,10 @@ const Utils = {

},

readTextFromClipboard: (onPaste) => {

if (WebApp.isVersionAtLeast('6.4')) {

WebApp.readTextFromClipboard(onPaste);

}else{

Utils.Toast('Unsupported');

}

},

// Hide keyboard when user clicks enter
hideKeyboardOnEnter: (event) => { if (event.keyCode === 13) { event.target.blur(); } },

// Copy text to clipboard
copyTextToClipboard: (text) => {

if (!navigator.clipboard) {
Expand Down Expand Up @@ -220,6 +214,7 @@ const Utils = {

},

// Get wallet/secret from LocalStorage
GetWallet(param = null) {

let info = window.localStorage.getItem(`wallet_user_${ WebApp.initDataUnsafe.user.id }`);
Expand All @@ -244,6 +239,7 @@ const Utils = {

},

// Set wallet/secret to LocalStorage
SetWallet(wallet = null, secret = null) {

if (wallet === null) {
Expand All @@ -263,6 +259,7 @@ const Utils = {

},

// a hacky trick to fix mispositioning of UI elements when keyboard opens
HandleInputFocus: () => {

window.scrollTo(0, 0);
Expand Down
1 change: 1 addition & 0 deletions webApp/src/views/Badges.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,5 @@
}
}
</style>
1 change: 1 addition & 0 deletions webApp/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Utils from '../utils';
import { useRankStore } from '../stores/useRanks';
import badge from '../components/badge.vue';
import Header from '../components/Header.vue';
Expand Down
2 changes: 2 additions & 0 deletions webApp/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
</template>

<style lang="scss">
#section-login {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -143,4 +144,5 @@
}
}
}
</style>
4 changes: 3 additions & 1 deletion webApp/src/views/Transfer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { inject, ref, onMounted } from 'vue';
import { inject, ref } from 'vue';
import { useI18n } from "vue-i18n";
import { useRouter, useRoute } from 'vue-router';
Expand Down Expand Up @@ -160,6 +160,7 @@
</template>
<style lang="scss">
#section-transfer {
display: flex;
flex-direction: column;
Expand All @@ -183,4 +184,5 @@
}
}
}
</style>
2 changes: 2 additions & 0 deletions webApp/src/views/Wallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
</template>

<style lang="scss">
#section-wallet {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -272,4 +273,5 @@
}
}
}
</style>

0 comments on commit 89db46e

Please sign in to comment.