mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-22 13:36:27 +08:00
impr: remove unnecessary rest call to users/tags (fehmer) (#4826)
This commit is contained in:
parent
6c3cfe0ff4
commit
bd2d360fc2
2 changed files with 3 additions and 15 deletions
|
@ -95,10 +95,6 @@ export default class Users {
|
|||
);
|
||||
}
|
||||
|
||||
async getTags(): Ape.EndpointResponse {
|
||||
return await this.httpClient.get(`${BASE_PATH}/tags`);
|
||||
}
|
||||
|
||||
async createTag(tagName: string): Ape.EndpointResponse {
|
||||
return await this.httpClient.post(`${BASE_PATH}/tags`, {
|
||||
payload: { tagName },
|
||||
|
|
|
@ -55,9 +55,8 @@ export async function initSnapshot(): Promise<
|
|||
//getData recreates the user if it doesnt exist - thats why it needs to be called first, by itself
|
||||
const userResponse = await Ape.users.getData();
|
||||
|
||||
const [configResponse, tagsResponse, presetsResponse] = await Promise.all([
|
||||
const [configResponse, presetsResponse] = await Promise.all([
|
||||
Ape.configs.get(),
|
||||
Ape.users.getTags(),
|
||||
Ape.presets.get(),
|
||||
]);
|
||||
|
||||
|
@ -73,12 +72,6 @@ export async function initSnapshot(): Promise<
|
|||
responseCode: configResponse.status,
|
||||
};
|
||||
}
|
||||
if (tagsResponse.status !== 200) {
|
||||
throw {
|
||||
message: `${tagsResponse.message} (tags)`,
|
||||
responseCode: tagsResponse.status,
|
||||
};
|
||||
}
|
||||
if (presetsResponse.status !== 200) {
|
||||
throw {
|
||||
message: `${presetsResponse.message} (presets)`,
|
||||
|
@ -86,10 +79,9 @@ export async function initSnapshot(): Promise<
|
|||
};
|
||||
}
|
||||
|
||||
const [userData, configData, tagsData, presetsData] = [
|
||||
const [userData, configData, presetsData] = [
|
||||
userResponse,
|
||||
configResponse,
|
||||
tagsResponse,
|
||||
presetsResponse,
|
||||
].map((response) => response.data);
|
||||
|
||||
|
@ -170,7 +162,7 @@ export async function initSnapshot(): Promise<
|
|||
// }
|
||||
// LoadingPage.updateText("Downloading tags...");
|
||||
snap.customThemes = userData.customThemes ?? [];
|
||||
snap.tags = tagsData;
|
||||
snap.tags = userData.tags || [];
|
||||
|
||||
snap.tags.forEach((tag) => {
|
||||
tag.display = tag.name.replaceAll("_", " ");
|
||||
|
|
Loading…
Add table
Reference in a new issue