Fix types

This commit is contained in:
AkiraFukushima 2023-06-03 21:09:37 +09:00
parent e80e0fe13e
commit a56890e68c
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
16 changed files with 120 additions and 45 deletions

View File

@ -116,7 +116,11 @@ export default defineComponent({
searching.value = true
try {
const cleanDomain = form.domainName.trim()
sns.value = await detector(`https://${cleanDomain}`)
const res = await detector(`https://${cleanDomain}`)
if (res === 'friendica') {
throw new Error('Friendica is not supported')
}
sns.value = res
domain.value = cleanDomain
ElMessage({
message: t('message.domain_confirmed', {

View File

@ -44,12 +44,15 @@
</template>
<script lang="ts">
import { defineComponent, computed, onMounted } from 'vue'
import { defineComponent, computed, onMounted, reactive } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { useTranslation } from 'i18next-vue'
import { useStore } from '@/store'
import { ACTION_TYPES } from '@/store/Settings/Filters'
import { LocalAccount } from '~/src/types/localAccount'
import { LocalServer } from '~/src/types/localServer'
import { MyWindow } from '~/src/types/global'
export default defineComponent({
name: 'Filters',
@ -59,13 +62,23 @@ export default defineComponent({
const route = useRoute()
const { t } = useTranslation()
const win = (window as any) as MyWindow
const account = reactive<{ account: LocalAccount | null; server: LocalServer | null }>({
account: null,
server: null
})
const filters = computed(() => store.state.Settings.Filters.filters)
const filtersLoading = computed(() => store.state.Settings.Filters.filtersLoading)
const backgroundColor = computed(() => store.state.App.theme.background_color)
const sns = computed(() => store.state.TimelineSpace.sns)
const id = computed(() => route.params.id)
const sns = computed(() => account.server?.sns)
onMounted(async () => {
const [a, s]: [LocalAccount, LocalServer] = await win.ipcRenderer.invoke('get-local-account', id.value)
account.account = a
account.server = s
await store.dispatch(`${space}/${ACTION_TYPES.FETCH_FILTERS}`)
})
@ -83,9 +96,9 @@ export default defineComponent({
filters,
filtersLoading,
backgroundColor,
sns,
id,
deleteFilter,
sns,
$t: t
}
}

View File

@ -6,13 +6,16 @@
</template>
<script lang="ts">
import { defineComponent, computed, onMounted, toRefs } from 'vue'
import { defineComponent, computed, onMounted, toRefs, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { useStore } from '@/store'
import { useRouter } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { useTranslation } from 'i18next-vue'
import FilterForm from './form.vue'
import { ACTION_TYPES } from '@/store/Settings/Filters/Edit'
import { LocalAccount } from '~/src/types/localAccount'
import { LocalServer } from '~/src/types/localServer'
import { MyWindow } from '~/src/types/global'
export default defineComponent({
name: 'EditFilter',
@ -22,17 +25,29 @@ export default defineComponent({
const space = 'Settings/Filters/Edit'
const store = useStore()
const router = useRouter()
const route = useRoute()
const { t } = useTranslation()
const { filter_id } = toRefs(props)
const win = (window as any) as MyWindow
const id = computed(() => parseInt(route.params.id as string))
const account = reactive<{ account: LocalAccount | null; server: LocalServer | null }>({
account: null,
server: null
})
const loading = computed(() => store.state.Settings.Filters.Edit.loading)
const sns = computed(() => store.state.TimelineSpace.sns)
const filter = computed({
get: () => store.state.Settings.Filters.Edit.filter,
set: value => store.dispatch(`${space}/${ACTION_TYPES.EDIT_FILTER}`, value)
})
const sns = computed(() => account.server?.sns)
onMounted(async () => {
const [a, s]: [LocalAccount, LocalServer] = await win.ipcRenderer.invoke('get-local-account', id.value)
account.account = a
account.server = s
onMounted(() => {
store.dispatch(`${space}/${ACTION_TYPES.FETCH_FILTER}`, filter_id.value)
})
@ -54,10 +69,10 @@ export default defineComponent({
return {
loading,
sns,
filter,
cancel,
onSubmit,
sns,
$t: t
}
}

View File

@ -6,13 +6,16 @@
</template>
<script lang="ts">
import { defineComponent, computed } from 'vue'
import { useRouter } from 'vue-router'
import { defineComponent, computed, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { useTranslation } from 'i18next-vue'
import { useStore } from '@/store'
import FilterForm from './form.vue'
import { ACTION_TYPES } from '@/store/Settings/Filters/New'
import { LocalAccount } from '~/src/types/localAccount'
import { LocalServer } from '~/src/types/localServer'
import { MyWindow } from '~/src/types/global'
export default defineComponent({
name: 'NewFilter',
@ -21,14 +24,28 @@ export default defineComponent({
const space = 'Settings/Filters/New'
const store = useStore()
const router = useRouter()
const route = useRoute()
const { t } = useTranslation()
const win = (window as any) as MyWindow
const id = computed(() => parseInt(route.params.id as string))
const account = reactive<{ account: LocalAccount | null; server: LocalServer | null }>({
account: null,
server: null
})
const loading = computed(() => store.state.Settings.Filters.New.loading)
const sns = computed(() => store.state.TimelineSpace.sns)
const filter = computed({
get: () => store.state.Settings.Filters.New.filter,
set: value => store.dispatch(`${space}/${ACTION_TYPES.EDIT_FILTER}`, value)
})
const sns = computed(() => account.server?.sns)
onMounted(async () => {
const [a, s]: [LocalAccount, LocalServer] = await win.ipcRenderer.invoke('get-local-account', id.value)
account.account = a
account.server = s
})
const cancel = () => router.go(-1)
const onSubmit = () => {
@ -48,10 +65,10 @@ export default defineComponent({
return {
loading,
sns,
filter,
cancel,
onSubmit,
sns,
$t: t
}
}

View File

@ -40,7 +40,7 @@
<div class="preview" ref="previewRef">
<div class="image-wrapper" v-for="media in attachments" :key="media.id">
<img :src="media.preview_url" class="preview-image" />
<img v-if="media.preview_url" :src="media.preview_url" class="preview-image" />
<el-button class="remove-image" link @click="removeAttachment(media)"><font-awesome-icon icon="circle-xmark" /></el-button>
</div>
</div>
@ -235,7 +235,7 @@ export default defineComponent({
const attachments = ref<Array<Entity.Attachment | Entity.AsyncAttachment>>([])
const cw = ref<boolean>(false)
const visibility = ref(visibilityList.Public.key)
const nsfw = ref<boolean>(false)
const nsfw = ref<boolean | null>(false)
const inReplyTo = computed(() => store.state.TimelineSpace.Compose.inReplyTo)
const quoteTo = computed(() => store.state.TimelineSpace.Compose.quoteTo)
const poll = reactive<{ options: Array<string>; expires_in: number }>({
@ -269,8 +269,11 @@ export default defineComponent({
const credentials = await c.verifyAccountCredentials()
if (credentials.data.source) {
visibility.value = credentials.data.source.privacy
nsfw.value = credentials.data.source.sensitive
const privacy = credentials.data.source.privacy
if (privacy && (privacy === 'public' || privacy === 'unlisted' || privacy === 'private' || privacy === 'direct')) {
visibility.value = privacy
}
}
const instance = await c.getInstance()

View File

@ -1,5 +1,5 @@
<template>
<div id="contents" :style="customWidth" @mouseup="dragEnd" @mousemove="resize">
<div id="contents">
<div
class="timeline-wrapper"
v-loading="loading"

View File

@ -64,7 +64,7 @@ export default defineComponent({
const client = ref<MegalodonInterface | null>(null)
const bookmarks = ref<Array<Entity.Status>>([])
const nextMaxId = ref<string | null>(null)
const nextMaxId = ref<string | undefined>(undefined)
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const modalOpened = computed<boolean>(() => store.getters[`TimelineSpace/Modals/modalOpened`])
const currentFocusedIndex = computed(() => bookmarks.value.findIndex(toot => focusedId.value === toot.uri))
@ -90,7 +90,7 @@ export default defineComponent({
if (link !== null && link.next) {
nextMaxId.value = link.next.max_id
} else {
nextMaxId.value = null
nextMaxId.value = undefined
}
} catch (err) {
console.error(err)
@ -143,7 +143,7 @@ export default defineComponent({
if (link !== null && link.next) {
nextMaxId.value = link.next.max_id
} else {
nextMaxId.value = null
nextMaxId.value = undefined
}
})
.catch(err => {
@ -174,7 +174,7 @@ export default defineComponent({
if (link !== null && link.next) {
nextMaxId.value = link.next.max_id
} else {
nextMaxId.value = null
nextMaxId.value = undefined
}
} finally {
store.commit(`TimelineSpace/${TIMELINE_MUTATION.CHANGE_LOADING}`, false)

View File

@ -65,7 +65,7 @@ export default defineComponent({
const startReload = computed(() => store.state.TimelineSpace.HeaderMenu.reload)
const favourites = ref<Array<Entity.Status>>([])
const nextMaxId = ref<string | null>(null)
const nextMaxId = ref<string | undefined>(undefined)
const modalOpened = computed<boolean>(() => store.getters[`TimelineSpace/Modals/modalOpened`])
const currentFocusedIndex = computed(() => favourites.value.findIndex(status => focusedId.value === status.uri))
const shortcutEnabled = computed(
@ -90,7 +90,7 @@ export default defineComponent({
if (link !== null && link.next) {
nextMaxId.value = link.next.max_id
} else {
nextMaxId.value = null
nextMaxId.value = undefined
}
} catch (err) {
console.error(err)
@ -151,7 +151,7 @@ export default defineComponent({
if (link !== null && link.next) {
nextMaxId.value = link.next.max_id
} else {
nextMaxId.value = null
nextMaxId.value = undefined
}
})
.catch(err => {
@ -197,7 +197,7 @@ export default defineComponent({
if (link !== null && link.next) {
nextMaxId.value = link.next.max_id
} else {
nextMaxId.value = null
nextMaxId.value = undefined
}
} finally {
store.commit(`TimelineSpace/${TIMELINE_MUTATION.CHANGE_LOADING}`, false)

View File

@ -1,7 +1,14 @@
<template>
<div id="follow-requests">
<template v-for="account in requests">
<user :user="account" :request="true" @acceptRequest="accept" @rejectRequest="reject"></user>
<user
:key="account.id"
v-if="isAccount(account)"
:user="account"
:request="true"
@accept-equest="accept"
@reject-request="reject"
></user>
</template>
</div>
</template>
@ -36,7 +43,7 @@ export default defineComponent({
})
const client = ref<MegalodonInterface | null>(null)
const requests = ref<Array<Entity.Account>>([])
const requests = ref<Array<Entity.Account | Entity.FollowRequest>>([])
onMounted(async () => {
await initialize()
@ -84,10 +91,15 @@ export default defineComponent({
})
}
const isAccount = (req: any): req is Entity.Account => {
return (req as Entity.Account)?.moved !== undefined
}
return {
requests,
accept,
reject
reject,
isAccount
}
}
})

View File

@ -2,7 +2,7 @@
<div id="list">
<table class="tag-list">
<tbody>
<tr v-for="tag in tags" :key="tag._id" @click.stop.prevent="openTimeline(tag.tagName)">
<tr v-for="tag in tags" :key="tag.id" @click.stop.prevent="openTimeline(tag.tagName)">
<td>
{{ tag.tagName }}
</td>

View File

@ -9,10 +9,10 @@
<div class="clearfix"></div>
</el-form>
</div>
<div class="search-result">
<div class="search-result" v-if="account.account && account.server">
<search-account v-if="target === 'account'" :results="accounts"></search-account>
<search-tag v-else-if="target === 'tag'" :results="tags"></search-tag>
<search-toots v-else-if="target === 'toot'" :results="statuses"></search-toots>
<search-tag v-else-if="target === 'tag'" :tags="tags"></search-tag>
<search-toots v-else-if="target === 'toot'" :statuses="statuses" :account="account.account" :server="account.server"></search-toots>
</div>
</div>
</template>
@ -140,7 +140,8 @@ export default defineComponent({
accounts,
tags,
statuses,
$t: t
$t: t,
account
}
}
})

View File

@ -1,6 +1,6 @@
<template>
<div id="search_tag">
<DynamicScroller :items="results" :min-item-size="46" key-field="name" class="scroller" page-mode>
<DynamicScroller :items="tags" :min-item-size="46" key-field="name" class="scroller" page-mode>
<template v-slot="{ item, index, active }">
<DynamicScrollerItem :item="item" :active="active" :size-dependencies="[item.name]" :data-index="index" :watchData="true">
<tag :tag="item"></tag>
@ -19,8 +19,8 @@ export default defineComponent({
name: 'search-tag',
components: { Tag },
props: {
results: {
type: Object as PropType<Array<Entity.Account>>,
tags: {
type: Object as PropType<Array<Entity.Tag>>,
required: true
}
}

View File

@ -1,9 +1,9 @@
<template>
<div id="search_account">
<DynamicScroller :items="results" :min-item-size="60" class="scroller" page-mode>
<DynamicScroller :items="statuses" :min-item-size="60" class="scroller" page-mode>
<template v-slot="{ item, index, active }">
<DynamicScrollerItem :item="item" :active="active" :size-dependencies="[item.uri]" :data-index="index" :watchData="true">
<toot :message="item"></toot>
<toot :message="item" :account="account" :server="server"></toot>
</DynamicScrollerItem>
</template>
</DynamicScroller>
@ -14,13 +14,23 @@
import { defineComponent, PropType } from 'vue'
import { Entity } from 'megalodon'
import Toot from '@/components/organisms/Toot.vue'
import { LocalAccount } from '~/src/types/localAccount'
import { LocalServer } from '~/src/types/localServer'
export default defineComponent({
name: 'search-account',
components: { Toot },
props: {
results: {
type: Object as PropType<Array<Entity.Account>>,
statuses: {
type: Object as PropType<Array<Entity.Status>>,
required: true
},
account: {
type: Object as PropType<LocalAccount>,
required: true
},
server: {
type: Object as PropType<LocalServer>,
required: true
}
}

View File

@ -13,7 +13,7 @@ import { useTranslation } from 'i18next-vue'
import { defineComponent } from 'vue'
export default defineComponent({
name: 'receive-drop',
name: 'ReceiveDrop',
setup() {
const { t } = useTranslation()
return { $t: t }

View File

@ -70,8 +70,8 @@
>
<font-awesome-icon icon="eye" class="hide" />
</el-button>
<div class="media" v-bind:key="media.preview_url" v-for="media in mediaAttachments">
<FailoverImg :srzc="media.preview_url" :title="media.description" />
<div class="media" v-for="media in mediaAttachments" :key="media.id">
<FailoverImg :srzc="media.preview_url" :title="media.description ? media.description : ''" />
<el-tag class="media-label" size="small" v-if="media.type == 'gifv'">GIF</el-tag>
<el-tag class="media-label" size="small" v-else-if="media.type == 'video'">VIDEO</el-tag>
</div>

View File

@ -62,11 +62,11 @@
<el-button v-if="sensitive && isShowAttachments" class="hide-sensitive" link :title="$t('cards.toot.hide')" @click="toggleCW()">
<font-awesome-icon icon="eye" class="hide" />
</el-button>
<div class="media" v-bind:key="media.preview_url" v-for="media in mediaAttachments">
<div class="media" v-for="media in mediaAttachments" :key="media.id">
<FailoverImg
:src="media.preview_url ? media.preview_url : originalMessage.account.avatar"
@click="openImage(media.url, mediaAttachments)"
:title="media.description"
:title="media.description ? media.description : ''"
/>
<el-tag class="media-label" size="small" v-if="media.type === 'gifv'">GIF</el-tag>
<el-tag class="media-label" size="small" v-else-if="media.type === 'video'">VIDEO</el-tag>