impr: remove unnecessary rest call to users/tags (fehmer) (#4826)

This commit is contained in:
Christian Fehmer 2023-11-30 14:22:12 +01:00 committed by GitHub
parent 6c3cfe0ff4
commit bd2d360fc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 15 deletions

View file

@ -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 },

View file

@ -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("_", " ");