chore: linting

This commit is contained in:
2024-11-05 15:19:03 -06:00
parent fc1eb68687
commit a08171c919
2 changed files with 6 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { CachedData } from '@shared/types/CachedData'; import type { CachedData } from '@shared/types/CachedData';
import { createLocalStore, debugStore } from 'chrome-extension-toolkit'; import { createLocalStore, debugStore } from 'chrome-extension-toolkit';
import { generateRandomId } from '../util/random'; import { generateRandomId } from '../util/random';

View File

@@ -1,6 +1,6 @@
import { Octokit } from '@octokit/rest'; import { Octokit } from '@octokit/rest';
import { CachedData } from '@shared/types/CachedData';
import { CacheStore } from '@shared/storage/CacheStore'; import { CacheStore } from '@shared/storage/CacheStore';
import type { CachedData } from '@shared/types/CachedData';
import { serialize } from 'chrome-extension-toolkit'; import { serialize } from 'chrome-extension-toolkit';
// Types // Types
@@ -74,7 +74,7 @@ export class GitHubStatsService {
} }
private async getCachedData<T>(key: string): Promise<CachedData<T> | null> { private async getCachedData<T>(key: string): Promise<CachedData<T> | null> {
if(Object.keys(this.cache).length === 0) { if (Object.keys(this.cache).length === 0) {
this.cache = await CacheStore.get('github') as Record<string, CachedData<any>>; this.cache = await CacheStore.get('github') as Record<string, CachedData<any>>;
} }
const cachedItem = this.cache[key]; const cachedItem = this.cache[key];
@@ -85,7 +85,7 @@ export class GitHubStatsService {
} }
private async setCachedData<T>(key: string, data: T): Promise<void> { private async setCachedData<T>(key: string, data: T): Promise<void> {
if(Object.keys(this.cache).length === 0) { if (Object.keys(this.cache).length === 0) {
this.cache = await CacheStore.get('github') as Record<string, CachedData<any>>; this.cache = await CacheStore.get('github') as Record<string, CachedData<any>>;
} }
this.cache[key] = { data, dataFetched: (new Date()).getTime() }; this.cache[key] = { data, dataFetched: (new Date()).getTime() };
@@ -147,13 +147,13 @@ export class GitHubStatsService {
const cachedName = await this.getCachedData<string>(cacheKey); const cachedName = await this.getCachedData<string>(cacheKey);
let name = `@${contributor}`; let name = `@${contributor}`;
if(cachedName) { if (cachedName) {
name = cachedName.data; name = cachedName.data;
} else { } else {
try { try {
const response = await fetch(`https://api.github.com/users/${contributor}`); const response = await fetch(`https://api.github.com/users/${contributor}`);
const json = await response.json(); const json = await response.json();
if(json.name) { if (json.name) {
name = json.name; name = json.name;
} }
await this.setCachedData(cacheKey, name); await this.setCachedData(cacheKey, name);