mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-14 09:25:47 +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 { getConfig } from '../../../tools/config/getConfig';
|
||||
import widgets from '../../../widgets';
|
||||
import { IRssWidget } from '../../../widgets/rss/RssWidgetTile';
|
||||
|
||||
function Put(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (process.env.DISABLE_EDIT_MODE === 'true') {
|
||||
@@ -30,16 +32,17 @@ function Put(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
const previousConfig = getConfig(slug);
|
||||
|
||||
const newConfig: BackendConfigType = {
|
||||
let newConfig: BackendConfigType = {
|
||||
...config,
|
||||
apps: [
|
||||
...config.apps.map((app) => ({
|
||||
...app,
|
||||
network: {
|
||||
...app.network,
|
||||
statusCodes: app.network.okStatus === undefined ?
|
||||
app.network.statusCodes :
|
||||
app.network.okStatus.map((x) => x.toString()),
|
||||
statusCodes:
|
||||
app.network.okStatus === undefined
|
||||
? app.network.statusCodes
|
||||
: app.network.okStatus.map((x) => x.toString()),
|
||||
okStatus: undefined,
|
||||
},
|
||||
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
|
||||
const targetPath = path.join('data/configs', `${slug}.json`);
|
||||
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">
|
||||
{data.map((feed, index) => (
|
||||
<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
|
||||
key={index}
|
||||
withBorder
|
||||
|
||||
Reference in New Issue
Block a user