mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-19 21:52:21 +03:00
fix(radar): close cumulative quality regressions
This commit is contained in:
@@ -5,7 +5,7 @@ import { useLocale, useTranslations } from "next-intl";
|
||||
|
||||
import {
|
||||
NEWS_DISMISS_EVENT,
|
||||
NEWS_DISMISS_STORAGE_KEY,
|
||||
NEWS_DISMISS_STORAGE_NAME,
|
||||
fetchNewsPayload,
|
||||
parseDismissedNewsIds,
|
||||
selectActiveNews,
|
||||
@@ -23,7 +23,7 @@ function subscribeToDismissals(callback: () => void) {
|
||||
|
||||
function readDismissedIds(): string {
|
||||
try {
|
||||
return localStorage.getItem(NEWS_DISMISS_STORAGE_KEY) ?? "";
|
||||
return localStorage.getItem(NEWS_DISMISS_STORAGE_NAME) ?? "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export default function NewsBanner() {
|
||||
const dismiss = () => {
|
||||
dismissedIds.add(announcement.id);
|
||||
try {
|
||||
localStorage.setItem(NEWS_DISMISS_STORAGE_KEY, serializeDismissedNewsIds(dismissedIds));
|
||||
localStorage.setItem(NEWS_DISMISS_STORAGE_NAME, serializeDismissedNewsIds(dismissedIds));
|
||||
} catch {
|
||||
// Storage is optional; the next announcement fetch remains functional.
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { requireManagementAuth } from "@/lib/api/requireManagementAuth";
|
||||
import { isPaidModelTarget } from "@/shared/utils/freeModels";
|
||||
import { getAuditRequestContext, logAuditEvent } from "@/lib/compliance";
|
||||
import { isAuthRequired } from "@/shared/utils/apiAuth";
|
||||
import { isAuthRequired, isDashboardSessionAuthenticated } from "@/shared/utils/apiAuth";
|
||||
import { isCliTokenAuthValid } from "@/lib/middleware/cliTokenAuth";
|
||||
import { extractApiKey } from "@/sse/services/auth";
|
||||
import { getApiKeyMetadata } from "@/lib/db/apiKeys";
|
||||
|
||||
@@ -1736,6 +1736,8 @@
|
||||
"quotaShare": "Chia sẻ hạn mức",
|
||||
"discovery": "Khám phá",
|
||||
"freeProviderRankings": "Xếp hạng nhà cung cấp miễn phí",
|
||||
"radar": "Radar",
|
||||
"setup": "Thiết lập",
|
||||
"freeTiers": "Gói miễn phí",
|
||||
"gamification": "Trò chơi hóa",
|
||||
"leaderboard": "Bảng xếp hạng",
|
||||
|
||||
@@ -362,7 +362,8 @@ function normalizeRadarIdentity(
|
||||
}
|
||||
|
||||
function normalizeDisplayName(value: unknown): string | null | undefined {
|
||||
if (value === undefined || value === null) return value;
|
||||
if (value === undefined) return undefined;
|
||||
if (value === null) return null;
|
||||
if (typeof value !== "string") return undefined;
|
||||
const normalized = value.trim();
|
||||
if (
|
||||
|
||||
@@ -6,7 +6,7 @@ export const CHANGELOG_RAW_URL =
|
||||
"https://raw.githubusercontent.com/diegosouzapw/OmniRoute/main/CHANGELOG.md";
|
||||
export const CHANGELOG_GITHUB_URL =
|
||||
"https://github.com/diegosouzapw/OmniRoute/blob/main/CHANGELOG.md";
|
||||
export const NEWS_DISMISS_STORAGE_KEY = "omniroute-news-dismissed-v2";
|
||||
export const NEWS_DISMISS_STORAGE_NAME = "omniroute-news-dismissed-v2";
|
||||
export const NEWS_DISMISS_EVENT = "omniroute:news-dismissed";
|
||||
|
||||
const NEWS_ID_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,78}[a-z0-9])?$/;
|
||||
@@ -31,19 +31,21 @@ const httpsUrlSchema = z
|
||||
return url.protocol === "https:" && !url.username && !url.password;
|
||||
}, "Announcement links must use HTTPS without embedded credentials");
|
||||
|
||||
const localizedTextMapSchema = z.record(localizedTextSchema).superRefine((value, context) => {
|
||||
if (!value.en) {
|
||||
context.addIssue({ code: z.ZodIssueCode.custom, message: "English copy is required" });
|
||||
}
|
||||
for (const locale of Object.keys(value)) {
|
||||
if (!LOCALE_PATTERN.test(locale)) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: `Invalid locale: ${locale}`,
|
||||
});
|
||||
const localizedTextMapSchema = z
|
||||
.record(z.string(), localizedTextSchema)
|
||||
.superRefine((value, context) => {
|
||||
if (!value.en) {
|
||||
context.addIssue({ code: z.ZodIssueCode.custom, message: "English copy is required" });
|
||||
}
|
||||
}
|
||||
});
|
||||
for (const locale of Object.keys(value)) {
|
||||
if (!LOCALE_PATTERN.test(locale)) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: `Invalid locale: ${locale}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const newsFeedItemSchema = z
|
||||
.object({
|
||||
|
||||
Reference in New Issue
Block a user