mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -2,6 +2,8 @@ import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, GetAvatarRenderMa
|
|||||||
|
|
||||||
export class ChatBubbleUtilities
|
export class ChatBubbleUtilities
|
||||||
{
|
{
|
||||||
|
private static MAX_CACHE_SIZE: number = 200;
|
||||||
|
|
||||||
public static AVATAR_COLOR_CACHE: Map<string, number> = new Map();
|
public static AVATAR_COLOR_CACHE: Map<string, number> = new Map();
|
||||||
public static AVATAR_IMAGE_CACHE: Map<string, string> = new Map();
|
public static AVATAR_IMAGE_CACHE: Map<string, string> = new Map();
|
||||||
public static PET_IMAGE_CACHE: Map<string, string> = new Map();
|
public static PET_IMAGE_CACHE: Map<string, string> = new Map();
|
||||||
@@ -9,6 +11,19 @@ export class ChatBubbleUtilities
|
|||||||
|
|
||||||
private static placeHolderImageUrl: string = '';
|
private static placeHolderImageUrl: string = '';
|
||||||
|
|
||||||
|
private static pruneCache<T>(cache: Map<string, T>, maxSize: number = ChatBubbleUtilities.MAX_CACHE_SIZE): void
|
||||||
|
{
|
||||||
|
if(cache.size <= maxSize) return;
|
||||||
|
|
||||||
|
const deleteCount = cache.size - maxSize;
|
||||||
|
const iterator = cache.keys();
|
||||||
|
|
||||||
|
for(let i = 0; i < deleteCount; i++)
|
||||||
|
{
|
||||||
|
cache.delete(iterator.next().value as string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async setFigureImage(figure: string): Promise<string>
|
public static async setFigureImage(figure: string): Promise<string>
|
||||||
{
|
{
|
||||||
const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, {
|
const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, {
|
||||||
@@ -34,6 +49,9 @@ export class ChatBubbleUtilities
|
|||||||
this.AVATAR_COLOR_CACHE.set(figure, ((color && color.rgb) || 16777215));
|
this.AVATAR_COLOR_CACHE.set(figure, ((color && color.rgb) || 16777215));
|
||||||
this.AVATAR_IMAGE_CACHE.set(figure, imageUrl);
|
this.AVATAR_IMAGE_CACHE.set(figure, imageUrl);
|
||||||
|
|
||||||
|
this.pruneCache(this.AVATAR_COLOR_CACHE);
|
||||||
|
this.pruneCache(this.AVATAR_IMAGE_CACHE);
|
||||||
|
|
||||||
avatarImage.dispose();
|
avatarImage.dispose();
|
||||||
|
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
@@ -100,7 +118,11 @@ export class ChatBubbleUtilities
|
|||||||
|
|
||||||
if(!resolvedImage) resolvedImage = await getImageUrl(imageResult);
|
if(!resolvedImage) resolvedImage = await getImageUrl(imageResult);
|
||||||
|
|
||||||
if(resolvedImage) this.PET_IMAGE_CACHE.set(cacheKey, resolvedImage);
|
if(resolvedImage)
|
||||||
|
{
|
||||||
|
this.PET_IMAGE_CACHE.set(cacheKey, resolvedImage);
|
||||||
|
this.pruneCache(this.PET_IMAGE_CACHE);
|
||||||
|
}
|
||||||
|
|
||||||
return resolvedImage;
|
return resolvedImage;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ const CatalogClassicViewInner: FC<{}> = () =>
|
|||||||
</div> }
|
</div> }
|
||||||
<Grid>
|
<Grid>
|
||||||
{ !navigationHidden &&
|
{ !navigationHidden &&
|
||||||
<Column overflow="hidden" size={ 3 }>
|
<Column overflow="auto" size={ 3 }>
|
||||||
{ activeNodes && (activeNodes.length > 0) &&
|
{ activeNodes && (activeNodes.length > 0) &&
|
||||||
<CatalogNavigationView node={ activeNodes[0] } /> }
|
<CatalogNavigationView node={ activeNodes[0] } /> }
|
||||||
</Column> }
|
</Column> }
|
||||||
|
|||||||
Reference in New Issue
Block a user