refactor auth payloads to slim snapshots
This commit is contained in:
@@ -247,7 +247,6 @@ const AVATAR_MAX_FILE_SIZE = 5 * 1024 * 1024;
|
||||
const AVATAR_OUTPUT_SIZE = 256;
|
||||
const AVATAR_ALLOWED_TYPES = new Set(['image/jpeg', 'image/png', 'image/webp']);
|
||||
const PLATFORM_WORK_COVER_CAROUSEL_INTERVAL_MS = 4200;
|
||||
const PROFILE_INVITE_REDEEM_ENTRY_VISIBLE_MS = 24 * 60 * 60 * 1000;
|
||||
const PROFILE_INVITE_QUERY_KEYS = ['inviteCode', 'invite_code'] as const;
|
||||
const RECOMMEND_ENTRY_SWIPE_THRESHOLD_PX = 36;
|
||||
const RECOMMEND_ENTRY_COMMIT_ANIMATION_MS = 180;
|
||||
@@ -2224,21 +2223,6 @@ function formatDashboardCount(value: number) {
|
||||
return normalizedValue.toLocaleString('zh-CN');
|
||||
}
|
||||
|
||||
function isWithinProfileInviteRedeemWindow(
|
||||
createdAt: string | null | undefined,
|
||||
) {
|
||||
if (!createdAt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const createdTime = new Date(createdAt).getTime();
|
||||
if (Number.isNaN(createdTime)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Date.now() - createdTime <= PROFILE_INVITE_REDEEM_ENTRY_VISIBLE_MS;
|
||||
}
|
||||
|
||||
function normalizeProfileInviteQueryCode(value: string | null | undefined) {
|
||||
return (value ?? '')
|
||||
.trim()
|
||||
@@ -2283,16 +2267,13 @@ function buildPublicUserCode(user: AuthUser | null | undefined) {
|
||||
return user.publicUserCode.trim();
|
||||
}
|
||||
|
||||
const raw =
|
||||
user?.id.replace(/[^a-zA-Z0-9]/gu, '').toUpperCase() ||
|
||||
user?.username.replace(/[^a-zA-Z0-9]/gu, '').toUpperCase() ||
|
||||
'00000000';
|
||||
const raw = user?.id.replace(/[^a-zA-Z0-9]/gu, '').toUpperCase() || '00000000';
|
||||
|
||||
return `SY-${raw.slice(-8).padStart(8, '0')}`;
|
||||
}
|
||||
|
||||
function getUserAvatarLabel(user: AuthUser | null | undefined) {
|
||||
return (user?.displayName || user?.username || '叙')
|
||||
return (user?.displayName || '叙')
|
||||
.slice(0, 1)
|
||||
.toUpperCase();
|
||||
}
|
||||
@@ -4889,18 +4870,14 @@ export function RpgEntryHomeView({
|
||||
});
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (
|
||||
activeTab !== 'profile' ||
|
||||
!isAuthenticated ||
|
||||
!isWithinProfileInviteRedeemWindow(authUi?.user?.createdAt)
|
||||
) {
|
||||
if (activeTab !== 'profile' || !isAuthenticated) {
|
||||
setIsReferralCenterInitialized(false);
|
||||
setReferralCenter(null);
|
||||
return;
|
||||
}
|
||||
|
||||
loadReferralCenter();
|
||||
}, [activeTab, authUi?.user?.createdAt, isAuthenticated, loadReferralCenter]);
|
||||
}, [activeTab, isAuthenticated, loadReferralCenter]);
|
||||
const openProfilePopupPanel = (panel: ProfileReferralPanel) => {
|
||||
setProfilePopupPanel(panel);
|
||||
setReferralError(null);
|
||||
|
||||
Reference in New Issue
Block a user