mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-14 17:26:26 +01:00
🐛 Fix rss widget crash with legacy string (#848)
This commit is contained in:
@@ -8,6 +8,8 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
|
|
||||||
import { BackendConfigType, ConfigType } from '../../../types/config';
|
import { BackendConfigType, ConfigType } from '../../../types/config';
|
||||||
import { getConfig } from '../../../tools/config/getConfig';
|
import { getConfig } from '../../../tools/config/getConfig';
|
||||||
|
import widgets from '../../../widgets';
|
||||||
|
import { IRssWidget } from '../../../widgets/rss/RssWidgetTile';
|
||||||
|
|
||||||
function Put(req: NextApiRequest, res: NextApiResponse) {
|
function Put(req: NextApiRequest, res: NextApiResponse) {
|
||||||
if (process.env.DISABLE_EDIT_MODE === 'true') {
|
if (process.env.DISABLE_EDIT_MODE === 'true') {
|
||||||
@@ -30,16 +32,17 @@ function Put(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
|
|
||||||
const previousConfig = getConfig(slug);
|
const previousConfig = getConfig(slug);
|
||||||
|
|
||||||
const newConfig: BackendConfigType = {
|
let newConfig: BackendConfigType = {
|
||||||
...config,
|
...config,
|
||||||
apps: [
|
apps: [
|
||||||
...config.apps.map((app) => ({
|
...config.apps.map((app) => ({
|
||||||
...app,
|
...app,
|
||||||
network: {
|
network: {
|
||||||
...app.network,
|
...app.network,
|
||||||
statusCodes: app.network.okStatus === undefined ?
|
statusCodes:
|
||||||
app.network.statusCodes :
|
app.network.okStatus === undefined
|
||||||
app.network.okStatus.map((x) => x.toString()),
|
? app.network.statusCodes
|
||||||
|
: app.network.okStatus.map((x) => x.toString()),
|
||||||
okStatus: undefined,
|
okStatus: undefined,
|
||||||
},
|
},
|
||||||
integration: {
|
integration: {
|
||||||
@@ -83,6 +86,30 @@ function Put(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
newConfig = {
|
||||||
|
...newConfig,
|
||||||
|
widgets: [
|
||||||
|
...newConfig.widgets.map((x) => {
|
||||||
|
if (x.type !== 'rss') {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rssWidget = x as IRssWidget;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...rssWidget,
|
||||||
|
properties: {
|
||||||
|
...rssWidget.properties,
|
||||||
|
rssFeedUrl:
|
||||||
|
typeof rssWidget.properties.rssFeedUrl === 'string'
|
||||||
|
? [rssWidget.properties.rssFeedUrl]
|
||||||
|
: rssWidget.properties.rssFeedUrl,
|
||||||
|
},
|
||||||
|
} as IRssWidget;
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
// Save the body in the /data/config folder with the slug as filename
|
// Save the body in the /data/config folder with the slug as filename
|
||||||
const targetPath = path.join('data/configs', `${slug}.json`);
|
const targetPath = path.join('data/configs', `${slug}.json`);
|
||||||
fs.writeFileSync(targetPath, JSON.stringify(newConfig, null, 2), 'utf8');
|
fs.writeFileSync(targetPath, JSON.stringify(newConfig, null, 2), 'utf8');
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ function RssTile({ widget }: RssTileProps) {
|
|||||||
<ScrollArea className="scroll-area-w100" w="100%" mt="sm" mb="sm">
|
<ScrollArea className="scroll-area-w100" w="100%" mt="sm" mb="sm">
|
||||||
{data.map((feed, index) => (
|
{data.map((feed, index) => (
|
||||||
<Stack w="100%" spacing="xs">
|
<Stack w="100%" spacing="xs">
|
||||||
{feed.feed && feed.feed.items.map((item: any, index: number) => (
|
{feed.feed &&
|
||||||
|
feed.feed.items.map((item: any, index: number) => (
|
||||||
<Card
|
<Card
|
||||||
key={index}
|
key={index}
|
||||||
withBorder
|
withBorder
|
||||||
|
|||||||
Reference in New Issue
Block a user