Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/admin-ui/src/__mock-backend__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ export const otherCalls: Omit<Routes, keyof typeof namedSpacedCalls> = {
return { "geth.dnp.dappnode.eth": { endpoints: [], customEndpoints: [], isCore: false } };
},
notificationsUpdateEndpoints: async () => {},
notificationsGetAll: async () => []
notificationsGetAll: async () => [],
notificationsApplyPreviousEndpoints: async () => {
return { endpoints: [], customEndpoints: [] };
},
};

export const calls: Routes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ const InstallDnpView: React.FC<InstallDnpViewProps> = ({ dnp, progressLogs }) =>
manifest.notifications?.customEndpoints || []
);

const mergedNotificationsConfig = useApi.notificationsApplyPreviousEndpoints({
dnpName: dnpName,
isCore,
newNotificationsConfig: manifest.notifications || {}
});

useEffect(() => {
if (mergedNotificationsConfig.data) {
const { endpoints: newEndpoints, customEndpoints: newCustomEndpoints } = mergedNotificationsConfig.data;
setEndpoints(newEndpoints || []);
setCustomEndpoints(newCustomEndpoints || []);
}
}, [mergedNotificationsConfig.data]);

useEffect(() => {
setUserSettings(settings || {});
}, [settings, setUserSettings]);
Expand Down
2 changes: 1 addition & 1 deletion packages/dappmanager/src/calls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export { getCoreVersion } from "./getCoreVersion.js";
export { getUserActionLogs } from "./getUserActionLogs.js";
export { getHostUptime } from "./getHostUptime.js";
export { getIsConnectedToInternet } from "./getIsConnectedToInternet.js";
export { notificationsGetAllEndpoints, notificationsUpdateEndpoints, notificationsGetAll } from "./notifications.js";
export { notificationsGetAllEndpoints, notificationsUpdateEndpoints, notificationsGetAll, notificationsApplyPreviousEndpoints } from "./notifications.js";
export * from "./httpsPortal.js";
export { ipfsTest } from "./ipfsTest.js";
export { ipfsClientTargetSet } from "./ipfsClientTargetSet.js";
Expand Down
15 changes: 15 additions & 0 deletions packages/dappmanager/src/calls/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@ export async function notificationsUpdateEndpoints({
}): Promise<void> {
await notifications.updateEndpoints(dnpName, isCore, notificationsConfig);
}

/**
* Joins new endpoints with previous ones
*/
export async function notificationsApplyPreviousEndpoints({
dnpName,
isCore,
newNotificationsConfig
}: {
dnpName: string;
isCore: boolean;
newNotificationsConfig: NotificationsConfig;
}): Promise<NotificationsConfig> {
return await notifications.applyPreviousEndpoints(dnpName, isCore, newNotificationsConfig);
}
10 changes: 10 additions & 0 deletions packages/types/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ export interface Routes {
notificationsConfig: NotificationsConfig;
}) => Promise<void>;

/**
* Applies the previous endpoints configuration to the new ones if their names match
*/
notificationsApplyPreviousEndpoints: (kwargs: {
dnpName: string;
isCore: boolean;
newNotificationsConfig: NotificationsConfig;
}) => Promise<NotificationsConfig>;

/**
* Returns the user action logs. This logs are stored in a different
* file and format, and are meant to ease user support
Expand Down Expand Up @@ -715,6 +724,7 @@ export const routesData: { [P in keyof Routes]: RouteData } = {
notificationsGetAll: { log: true },
notificationsGetAllEndpoints: { log: true },
notificationsUpdateEndpoints: { log: true },
notificationsApplyPreviousEndpoints: {},
getUserActionLogs: {},
getHostUptime: {},
httpsPortalMappingAdd: { log: true },
Expand Down
Loading