Skip to content

Commit

Permalink
switch /textures/versions to settings.json
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Aug 2, 2024
1 parent 92f2342 commit f87732b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
21 changes: 10 additions & 11 deletions src/v2/repository/texture.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,20 @@ export default class TextureFirestormRepository implements TextureRepository {
return packs.values({ field: "resolution" }).then((res) => res.sort());
}

public getTags(): Promise<Array<string>> {
return textures.values({ field: "tags", flatten: true }).then((res) => res.sort());
public async getTags(): Promise<Array<string>> {
const res = await textures.values({ field: "tags", flatten: true });
return res.sort();
}

public getVersions(): Promise<Array<string>> {
return paths
.values({ field: "versions", flatten: true })
.then((res) => res.sort(MinecraftSorter).reverse());
public async getVersions(): Promise<Array<string>> {
const versions = await settings.get("versions");
return Object.values(versions).flat().sort(MinecraftSorter).reverse();
}

public getVersionByEdition(edition: Edition): Promise<Array<string>> {
return settings.get("versions").then((versions) => {
if (versions[edition] === undefined) throw new NotFoundError("edition not found");
return versions[edition];
});
public async getVersionByEdition(edition: Edition): Promise<Array<string>> {
const versions = await settings.get("versions");
if (!versions[edition]) throw new NotFoundError("edition not found");
return versions[edition];
}

public createTexture(texture: TextureCreationParam): Promise<Texture> {
Expand Down
3 changes: 1 addition & 2 deletions src/v2/tools/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const folder = () => {

const keyToPath = (key: string): string => {
const escapedKey = key.replace(/(\/|\\)/g, "-");
const p = join(folder(), `cache-${escapedKey}.json`);
return p;
return join(folder(), `cache-${escapedKey}.json`);
};

export interface CacheData<T> {
Expand Down

0 comments on commit f87732b

Please sign in to comment.