Sync service launch links

This commit is contained in:
DCCONSTRUCTIONS
2026-05-02 13:07:18 +03:00
parent 17e007f49d
commit c6e1de6345
6 changed files with 69 additions and 34 deletions
+13 -5
View File
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from "react";
import type { Client } from "../entities/client/types";
import type { Invite } from "../entities/invite/types";
import { syncServiceLaunchLink } from "../entities/service/links";
import type { LauncherServiceView, Service } from "../entities/service/types";
import type { SyncStatus } from "../entities/sync/types";
import type { ClientGroup, ClientMembership, LauncherUser } from "../entities/user/types";
@@ -18,7 +19,7 @@ import { ServiceStage } from "../widgets/service-stage/ServiceStage";
import { TopBar } from "../widgets/top-bar/TopBar";
export function LauncherApp() {
const [data, setData] = useState<LauncherData>(initialLauncherData);
const [data, setData] = useState<LauncherData>(() => syncLauncherServiceLinks(initialLauncherData));
const [activeProfileId, setActiveProfileId] = useState(profileOptions[0].userId);
const [activeClientId, setActiveClientId] = useState(profileOptions[0].defaultClientId);
const [selectedServiceId, setSelectedServiceId] = useState<string | undefined>();
@@ -51,7 +52,7 @@ export function LauncherApp() {
loadPersistedLauncherData()
.then((persistedData) => {
if (isMounted && persistedData) {
setData(persistedData);
setData(syncLauncherServiceLinks(persistedData));
}
})
.finally(() => {
@@ -232,11 +233,11 @@ export function LauncherApp() {
...current,
services: current.services.map((service) =>
service.id === serviceId
? {
? syncServiceLaunchLink({
...service,
...patch,
updatedAt: new Date().toISOString(),
}
})
: service
),
}));
@@ -444,7 +445,7 @@ export function LauncherApp() {
subtitle: "Новый сервис",
description: "Описание сервиса для витрины.",
fullDescription: "Заполните описание, медиа и ссылку запуска в редакторе контента.",
url: "https://service.handhdc.ru",
url: "https://service.handhdc.ru/sso/launch",
launchUrl: "https://service.handhdc.ru/sso/launch",
accentColor: "#F7F8F4",
fallbackGradient: "linear-gradient(135deg, rgba(247, 248, 244, 0.72), rgba(36, 37, 42, 0.9) 52%, #090B0F 88%)",
@@ -529,3 +530,10 @@ export function LauncherApp() {
</div>
);
}
function syncLauncherServiceLinks(data: LauncherData): LauncherData {
return {
...data,
services: data.services.map(syncServiceLaunchLink),
};
}