fix(backend): add detailed schema to fetch-rss endpoint (#13764)

This commit is contained in:
zyoshoka
2024-04-29 15:36:01 +09:00
committed by GitHub
parent e2ff5f58b2
commit 2ff90a80d4
5 changed files with 234 additions and 11 deletions

View File

@@ -28,6 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import MarqueeText from '@/components/MkMarquee.vue';
import { useInterval } from '@/scripts/use-interval.js';
import { shuffle } from '@/scripts/shuffle.js';
@@ -42,13 +43,13 @@ const props = defineProps<{
refreshIntervalSec?: number;
}>();
const items = ref([]);
const items = ref<Misskey.entities.FetchRssResponse['items']>([]);
const fetching = ref(true);
const key = ref(0);
const tick = () => {
window.fetch(`/api/fetch-rss?url=${props.url}`, {}).then(res => {
res.json().then(feed => {
res.json().then((feed: Misskey.entities.FetchRssResponse) => {
if (props.shuffle) {
shuffle(feed.items);
}

View File

@@ -24,6 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref, watch, computed } from 'vue';
import * as Misskey from 'misskey-js';
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
import { GetFormResultType } from '@/scripts/form.js';
import MkContainer from '@/components/MkContainer.vue';
@@ -64,7 +65,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
emit,
);
const rawItems = ref([]);
const rawItems = ref<Misskey.entities.FetchRssResponse['items']>([]);
const items = computed(() => rawItems.value.slice(0, widgetProps.maxEntries));
const fetching = ref(true);
const fetchEndpoint = computed(() => {
@@ -79,8 +80,8 @@ const tick = () => {
window.fetch(fetchEndpoint.value, {})
.then(res => res.json())
.then(feed => {
rawItems.value = feed.items ?? [];
.then((feed: Misskey.entities.FetchRssResponse) => {
rawItems.value = feed.items;
fetching.value = false;
});
};

View File

@@ -28,6 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref, watch, computed } from 'vue';
import * as Misskey from 'misskey-js';
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js';
import MarqueeText from '@/components/MkMarquee.vue';
import { GetFormResultType } from '@/scripts/form.js';
@@ -87,7 +88,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
emit,
);
const rawItems = ref([]);
const rawItems = ref<Misskey.entities.FetchRssResponse['items']>([]);
const items = computed(() => {
const newItems = rawItems.value.slice(0, widgetProps.maxEntries);
if (widgetProps.shuffle) {
@@ -110,8 +111,8 @@ const tick = () => {
window.fetch(fetchEndpoint.value, {})
.then(res => res.json())
.then(feed => {
rawItems.value = feed.items ?? [];
.then((feed: Misskey.entities.FetchRssResponse) => {
rawItems.value = feed.items;
fetching.value = false;
key.value++;
});