修复聊天室字号偏好和游戏通知显示
This commit is contained in:
@@ -303,12 +303,13 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存聊天室屏蔽与禁音偏好。
|
||||
* 保存聊天室屏蔽、禁音与字号偏好。
|
||||
*/
|
||||
public function updateChatPreferences(UpdateChatPreferencesRequest $request): JsonResponse
|
||||
{
|
||||
$user = Auth::user();
|
||||
$data = $request->validated();
|
||||
$existingPreferences = is_array($user->chat_preferences) ? $user->chat_preferences : [];
|
||||
$blockedSystemSenders = collect($data['blocked_system_senders'] ?? [])
|
||||
->map(function (string $sender): string {
|
||||
// 猜谜活动前端文案允许升级,但持久化键仍复用旧值,避免历史偏好失效。
|
||||
@@ -324,6 +325,15 @@ class UserController extends Controller
|
||||
'sound_muted' => (bool) $data['sound_muted'],
|
||||
];
|
||||
|
||||
// 字号偏好和屏蔽/禁音共用账号配置,旧请求未携带字号时保留原值。
|
||||
$fontSize = array_key_exists('font_size', $data) && $data['font_size'] !== null
|
||||
? (int) $data['font_size']
|
||||
: ($existingPreferences['font_size'] ?? null);
|
||||
|
||||
if ($fontSize !== null) {
|
||||
$preferences['font_size'] = (int) $fontSize;
|
||||
}
|
||||
|
||||
$user->update([
|
||||
'chat_preferences' => $preferences,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user