Skip to content

Commit

Permalink
Api Upgraded
Browse files Browse the repository at this point in the history
  • Loading branch information
Blank-09 committed Sep 1, 2022
1 parent 7331ba9 commit e8a2850
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-vite-react-anime-player",
"productName": "Anime Player",
"version": "2.2.3",
"version": "2.2.4",
"description": "Anime Player built with electron, vite and react",
"author": "Priyanshu",
"license": "MIT",
Expand Down
18 changes: 8 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,10 @@
<div class="key">No of Times Played:</div>
<div class="value" id="noOfTimesPlayedText">--</div>
</div>
<div class="d-none">
<br />
<div>
<div class="key">Your Rank:</div>
<div class="value">#<span id="rankText">--</span></div>
</div>
<br />
<div>
<div class="key">Your Rank:</div>
<div class="value">#<span id="rankText">--</span></div>
</div>
</main>

Expand Down Expand Up @@ -268,12 +266,12 @@
<div class="input-container">
<div class="input-text">
<input
type="text"
id="usernameInputBox"
placeholder="Enter Your New Name"
type="text"
id="usernameInputBox"
placeholder="Enter Your New Name"
/>
</div>

<div class="input-button">
<button id="usernameInputBtn">Change Name</button>
</div>
Expand Down
20 changes: 14 additions & 6 deletions src/ts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import { IAPIData } from "@/interface/IapiData";
import { IUserData } from "@/interface/ILocalStorage";
import { userScore } from "./functions";

const location = window.location.hostname;
const apiURL =
"https://script.google.com/macros/s/AKfycbzdh-sv8lYNXqo8kvSxufU_hiz_i-IIUt8Dr6KojNYFsD5ZCiNYV7ldgbuGLG2PNNPphg/exec";
"https://script.google.com/macros/s/AKfycbz8vXR3g9KmyXHVlxFcLfcJn6yEYdX96PKEyPf8vFRuhgCfqkhThgegD48Az1fpMOdncg/exec";

export const localStorageKey = "app-user-details";


export function register(username: string) {
if (localStorage.getItem(localStorageKey) !== null) return;

const location = window.location.hostname;
const payload = {
name: username,
nuid: 1,
Expand Down Expand Up @@ -44,7 +45,9 @@ export function register(username: string) {
});
}

export async function updateScore() {
export async function updateScore() {
if (userScore == 0) return;

const data = getLocalStorageData();
if (data == null) return;

Expand All @@ -63,8 +66,6 @@ export async function updateScore() {

setLocalStorageData(data);

var location = window.location.hostname;

const payload = {
id: data.id,
name: data.name,
Expand All @@ -78,7 +79,14 @@ export async function updateScore() {
body: JSON.stringify(payload),
})
.then((res) => res.json())
.then(resolve)
.then((data) => {
var userData = getLocalStorageData();
if (data.rank && userData) {
userData.rank = data.rank;
setLocalStorageData(userData);
}
resolve(data);
})
.catch(reject);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/eventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ usernameExitBtn.onclick = () => {

usernameInputBtn.onclick = () => {
var isValid = validateName(usernameInputBox);

if (!isValid) {
usernameInputBox.placeholder = "Invalid Name";
usernameInputBox.value = "";
Expand Down

0 comments on commit e8a2850

Please sign in to comment.