mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-11 01:44:50 +08:00
converted psa to ts
This commit is contained in:
parent
2769255a2b
commit
2ab2c3530c
1 changed files with 10 additions and 9 deletions
|
|
@ -1,32 +1,33 @@
|
|||
import axiosInstance from "../axios-instance";
|
||||
import * as Notifications from "./notifications";
|
||||
import * as MonkeyTypes from "../types/interfaces";
|
||||
|
||||
function clearMemory() {
|
||||
function clearMemory(): void {
|
||||
window.localStorage.setItem("confirmedPSAs", JSON.stringify([]));
|
||||
}
|
||||
|
||||
function getMemory() {
|
||||
return JSON.parse(window.localStorage.getItem("confirmedPSAs")) ?? [];
|
||||
function getMemory(): string[] {
|
||||
return JSON.parse(window.localStorage.getItem("confirmedPSAs") ?? "") ?? [];
|
||||
}
|
||||
|
||||
function setMemory(id) {
|
||||
let list = getMemory();
|
||||
function setMemory(id: string): void {
|
||||
const list = getMemory();
|
||||
list.push(id);
|
||||
window.localStorage.setItem("confirmedPSAs", JSON.stringify(list));
|
||||
}
|
||||
|
||||
async function getLatest() {
|
||||
let psa = await axiosInstance.get("/psa");
|
||||
async function getLatest(): Promise<MonkeyTypes.PSA[]> {
|
||||
const psa = await axiosInstance.get("/psa");
|
||||
return psa.data;
|
||||
}
|
||||
|
||||
export async function show() {
|
||||
export async function show(): Promise<void> {
|
||||
const latest = await getLatest();
|
||||
if (latest == null || latest.length == 0) {
|
||||
clearMemory();
|
||||
return;
|
||||
}
|
||||
let localmemory = getMemory();
|
||||
const localmemory = getMemory();
|
||||
latest.forEach((psa) => {
|
||||
if (localmemory.includes(psa._id) && psa.sticky === false) return;
|
||||
Notifications.addBanner(
|
||||
Loading…
Add table
Reference in a new issue