Moved common types to separate file

This commit is contained in:
Marcel Hellkamp 2023-07-24 19:19:09 +02:00
parent 5375a2764a
commit a0157e508f
7 changed files with 52 additions and 48 deletions

View File

@ -1,12 +1,13 @@
<script setup lang="ts">
import { computed, inject, onBeforeUnmount, onMounted, onUpdated, ref, watch } from 'vue';
import Card, { type Post } from './components/Card.vue';
import Card from './components/Card.vue';
import { useDocumentVisibility, usePreferredDark, useWindowSize, watchDebounced } from '@vueuse/core'
import ConfigModal from './components/ConfigModal.vue';
import { loadConfig, type Config } from './config';
import { loadConfig } from './config';
import InfoBar from './components/InfoBar.vue';
import { gitVersion } from '@/defaults'
import { regexEscape } from '@/utils'
import {type Config, type Post} from '@/types';
const config = ref<Config>();

View File

@ -2,22 +2,7 @@
import { useIntervalFn } from '@vueuse/core'
import { ref } from 'vue';
import moment from 'moment'
export type Post = {
id: string;
url: string;
content: string;
date: string;
author?: {
name: string;
avatar?: string;
url?: string;
};
media?: string;
pinned?: boolean;
};
import { type Post } from '@/types';
const props = defineProps<{
post: Post

View File

@ -1,8 +1,9 @@
<script setup lang="ts">
import { sanatizeConfig, isServer, isLanguage, toQuery, type Config } from '@/config';
import { sanatizeConfig, isServer, isLanguage, toQuery } from '@/config';
import { computed, ref } from 'vue';
import { arrayUnique } from '@/utils';
import { useClipboard } from '@vueuse/core'
import {type Config} from '@/types';
const emit = defineEmits(['update:modelValue'])
const modalDom = ref(null)

View File

@ -1,6 +1,5 @@
<script setup lang="ts">
import { type Config } from '@/config';
import { ref } from 'vue';
import { type Config } from '@/types';
const props = defineProps<{
config: Config

View File

@ -1,34 +1,9 @@
import { arrayUnique, deepClone, isString } from "./utils";
import { fallbackConfig, siteConfigUrl } from "@/defaults";
import {type Config} from '@/types';
export type Config = {
servers: Array<string>,
tags: Array<string>,
accounts: Array<string>,
loadPublic: boolean,
loadFederated: boolean,
loadTrends: boolean,
languages: Array<string>,
badWords: Array<string>,
hideSensitive: boolean,
hideBoosts: boolean,
hideReplies: boolean,
hideBots: boolean,
limit: number,
interval: number,
title: string,
theme: string,
showInfobar: boolean,
showText: boolean,
showMedia: boolean,
playVideos: boolean,
}
var siteConfig: Config | null = null;

View File

@ -1,5 +1,5 @@
import type { Config } from "./config"
import {type Config} from '@/types';
// Fallback configuration in case the site config fails to load or is missing required fields.
// TODO: Maybe just fail in that case and not hard-code mastodon.social?

43
src/types.ts Normal file
View File

@ -0,0 +1,43 @@
export type Post = {
id: string;
url: string;
content: string;
date: string;
author?: {
name: string;
avatar?: string;
url?: string;
};
media?: string;
pinned?: boolean;
};
export type Config = {
servers: Array<string>,
tags: Array<string>,
accounts: Array<string>,
loadPublic: boolean,
loadFederated: boolean,
loadTrends: boolean,
languages: Array<string>,
badWords: Array<string>,
hideSensitive: boolean,
hideBoosts: boolean,
hideReplies: boolean,
hideBots: boolean,
limit: number,
interval: number,
title: string,
theme: string,
showInfobar: boolean,
showText: boolean,
showMedia: boolean,
playVideos: boolean,
}