From ed04dd17400e835f07cf1c8e5d08835b969fef1f Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 6 Mar 2020 10:15:01 +0800 Subject: [PATCH] fix "score cost per closet item" isn't calculated at "texture upload" page --- app/Http/Controllers/SkinlibController.php | 1 + resources/assets/src/views/skinlib/Upload/index.tsx | 9 ++++----- resources/assets/tests/views/skinlib/Upload.test.tsx | 5 +++-- resources/misc/changelogs/en/5.0.0.md | 1 + resources/misc/changelogs/zh_CN/5.0.0.md | 1 + 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php index e738c285..cce969d2 100644 --- a/app/Http/Controllers/SkinlibController.php +++ b/app/Http/Controllers/SkinlibController.php @@ -211,6 +211,7 @@ class SkinlibController extends Controller ), 'scorePublic' => intval(option('score_per_storage')), 'scorePrivate' => intval(option('private_score_per_storage')), + 'closetItemCost' => intval(option('score_per_closet_item')), 'award' => intval(option('score_award_per_texture')), 'contentPolicy' => $parsedown->text(option_localized('content_policy')), ]); diff --git a/resources/assets/src/views/skinlib/Upload/index.tsx b/resources/assets/src/views/skinlib/Upload/index.tsx index 464c05ad..b7ae7fd6 100644 --- a/resources/assets/src/views/skinlib/Upload/index.tsx +++ b/resources/assets/src/views/skinlib/Upload/index.tsx @@ -28,6 +28,7 @@ const Upload: React.FC = () => { const award = useBlessingExtra('award') const scorePublic = useBlessingExtra('scorePublic') const scorePrivate = useBlessingExtra('scorePrivate') + const closetItemCost = useBlessingExtra('closetItemCost') useEffect(() => { const mount = document.querySelector('#previewer')! @@ -119,6 +120,8 @@ const Upload: React.FC = () => { } const costRatio = isPrivate ? scorePrivate : scorePublic + const size = file?.size ?? 0 + const scoreCost = (~~(size / 1024) || 1) * costRatio + closetItemCost return ( <> @@ -241,11 +244,7 @@ const Upload: React.FC = () => { {file && (
-

- {t('skinlib.upload.cost', { - score: (~~(file.size / 1024) || 1) * costRatio, - })} -

+

{t('skinlib.upload.cost', { score: scoreCost })}

)} {isPrivate && ( diff --git a/resources/assets/tests/views/skinlib/Upload.test.tsx b/resources/assets/tests/views/skinlib/Upload.test.tsx index f5f6db01..480321ec 100644 --- a/resources/assets/tests/views/skinlib/Upload.test.tsx +++ b/resources/assets/tests/views/skinlib/Upload.test.tsx @@ -18,6 +18,7 @@ beforeEach(() => { privacyNotice: 'privacy notice', scorePrivate: 10, scorePublic: 1, + closetItemCost: 10, award: 0, contentPolicy: 'the policy', } @@ -145,7 +146,7 @@ describe('score cost', () => { }) expect( - queryByText(t('skinlib.upload.cost', { score: 1 })), + queryByText(t('skinlib.upload.cost', { score: 11 })), ).toBeInTheDocument() }) @@ -159,7 +160,7 @@ describe('score cost', () => { fireEvent.click(getByLabelText(t('skinlib.upload.set-as-private'))) expect( - queryByText(t('skinlib.upload.cost', { score: 10 })), + queryByText(t('skinlib.upload.cost', { score: 20 })), ).toBeInTheDocument() }) }) diff --git a/resources/misc/changelogs/en/5.0.0.md b/resources/misc/changelogs/en/5.0.0.md index 9659157a..1fb49e61 100644 --- a/resources/misc/changelogs/en/5.0.0.md +++ b/resources/misc/changelogs/en/5.0.0.md @@ -63,6 +63,7 @@ - Fixed that avatar can't be resized when requesting an non-existed user. - Fixed that the same texture files with different models were treated as different textures. (Thanks [Steven Qiu](https://github.com/tnqzh123)) - Fixed when uploading duplicated texture, alert is missing. +- Fixed that "score cost per closet item" isn't calculated at "texture upload" page. ## Removed diff --git a/resources/misc/changelogs/zh_CN/5.0.0.md b/resources/misc/changelogs/zh_CN/5.0.0.md index bfb07f1e..0ff7af75 100644 --- a/resources/misc/changelogs/zh_CN/5.0.0.md +++ b/resources/misc/changelogs/zh_CN/5.0.0.md @@ -63,6 +63,7 @@ - 修复获取不存在的用户的头像时,未能正确设置尺寸的问题 - 修复同一材质文件但模型不同被认为不同材质的问题(感谢 [Steven Qiu](https://github.com/tnqzh123)) - 修复上传重复材质时没有提示用户的问题 +- 「材质上传」页面的积分消耗没有计算衣柜收藏所需的积分 ## 移除