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 searching.value = true
try { try {
const cleanDomain = form.domainName.trim() 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 domain.value = cleanDomain
ElMessage({ ElMessage({
message: t('message.domain_confirmed', { message: t('message.domain_confirmed', {

View File

@ -44,12 +44,15 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed, onMounted } from 'vue' import { defineComponent, computed, onMounted, reactive } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { ElMessageBox } from 'element-plus' import { ElMessageBox } from 'element-plus'
import { useTranslation } from 'i18next-vue' import { useTranslation } from 'i18next-vue'
import { useStore } from '@/store' import { useStore } from '@/store'
import { ACTION_TYPES } from '@/store/Settings/Filters' 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({ export default defineComponent({
name: 'Filters', name: 'Filters',
@ -59,13 +62,23 @@ export default defineComponent({
const route = useRoute() const route = useRoute()
const { t } = useTranslation() 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 filters = computed(() => store.state.Settings.Filters.filters)
const filtersLoading = computed(() => store.state.Settings.Filters.filtersLoading) const filtersLoading = computed(() => store.state.Settings.Filters.filtersLoading)
const backgroundColor = computed(() => store.state.App.theme.background_color) const backgroundColor = computed(() => store.state.App.theme.background_color)
const sns = computed(() => store.state.TimelineSpace.sns)
const id = computed(() => route.params.id) const id = computed(() => route.params.id)
const sns = computed(() => account.server?.sns)
onMounted(async () => { 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}`) await store.dispatch(`${space}/${ACTION_TYPES.FETCH_FILTERS}`)
}) })
@ -83,9 +96,9 @@ export default defineComponent({
filters, filters,
filtersLoading, filtersLoading,
backgroundColor, backgroundColor,
sns,
id, id,
deleteFilter, deleteFilter,
sns,
$t: t $t: t
} }
} }

View File

@ -6,13 +6,16 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed, onMounted, toRefs } from 'vue' import { defineComponent, computed, onMounted, toRefs, reactive } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { useStore } from '@/store' import { useStore } from '@/store'
import { useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { useTranslation } from 'i18next-vue' import { useTranslation } from 'i18next-vue'
import FilterForm from './form.vue' import FilterForm from './form.vue'
import { ACTION_TYPES } from '@/store/Settings/Filters/Edit' 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({ export default defineComponent({
name: 'EditFilter', name: 'EditFilter',
@ -22,17 +25,29 @@ export default defineComponent({
const space = 'Settings/Filters/Edit' const space = 'Settings/Filters/Edit'
const store = useStore() const store = useStore()
const router = useRouter() const router = useRouter()
const route = useRoute()
const { t } = useTranslation() const { t } = useTranslation()
const { filter_id } = toRefs(props) 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 loading = computed(() => store.state.Settings.Filters.Edit.loading)
const sns = computed(() => store.state.TimelineSpace.sns)
const filter = computed({ const filter = computed({
get: () => store.state.Settings.Filters.Edit.filter, get: () => store.state.Settings.Filters.Edit.filter,
set: value => store.dispatch(`${space}/${ACTION_TYPES.EDIT_FILTER}`, value) 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) store.dispatch(`${space}/${ACTION_TYPES.FETCH_FILTER}`, filter_id.value)
}) })
@ -54,10 +69,10 @@ export default defineComponent({
return { return {
loading, loading,
sns,
filter, filter,
cancel, cancel,
onSubmit, onSubmit,
sns,
$t: t $t: t
} }
} }

View File

@ -6,13 +6,16 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed } from 'vue' import { defineComponent, computed, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { useTranslation } from 'i18next-vue' import { useTranslation } from 'i18next-vue'
import { useStore } from '@/store' import { useStore } from '@/store'
import FilterForm from './form.vue' import FilterForm from './form.vue'
import { ACTION_TYPES } from '@/store/Settings/Filters/New' 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({ export default defineComponent({
name: 'NewFilter', name: 'NewFilter',
@ -21,14 +24,28 @@ export default defineComponent({
const space = 'Settings/Filters/New' const space = 'Settings/Filters/New'
const store = useStore() const store = useStore()
const router = useRouter() const router = useRouter()
const route = useRoute()
const { t } = useTranslation() 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 loading = computed(() => store.state.Settings.Filters.New.loading)
const sns = computed(() => store.state.TimelineSpace.sns)
const filter = computed({ const filter = computed({
get: () => store.state.Settings.Filters.New.filter, get: () => store.state.Settings.Filters.New.filter,
set: value => store.dispatch(`${space}/${ACTION_TYPES.EDIT_FILTER}`, value) 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 cancel = () => router.go(-1)
const onSubmit = () => { const onSubmit = () => {
@ -48,10 +65,10 @@ export default defineComponent({
return { return {
loading, loading,
sns,
filter, filter,
cancel, cancel,
onSubmit, onSubmit,
sns,
$t: t $t: t
} }
} }

View File

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

View File

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

View File

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

View File

@ -1,7 +1,14 @@
<template> <template>
<div id="follow-requests"> <div id="follow-requests">
<template v-for="account in 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> </template>
</div> </div>
</template> </template>
@ -36,7 +43,7 @@ export default defineComponent({
}) })
const client = ref<MegalodonInterface | null>(null) const client = ref<MegalodonInterface | null>(null)
const requests = ref<Array<Entity.Account>>([]) const requests = ref<Array<Entity.Account | Entity.FollowRequest>>([])
onMounted(async () => { onMounted(async () => {
await initialize() 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 { return {
requests, requests,
accept, accept,
reject reject,
isAccount
} }
} }
}) })

View File

@ -2,7 +2,7 @@
<div id="list"> <div id="list">
<table class="tag-list"> <table class="tag-list">
<tbody> <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> <td>
{{ tag.tagName }} {{ tag.tagName }}
</td> </td>

View File

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

View File

@ -1,6 +1,6 @@
<template> <template>
<div id="search_tag"> <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 }"> <template v-slot="{ item, index, active }">
<DynamicScrollerItem :item="item" :active="active" :size-dependencies="[item.name]" :data-index="index" :watchData="true"> <DynamicScrollerItem :item="item" :active="active" :size-dependencies="[item.name]" :data-index="index" :watchData="true">
<tag :tag="item"></tag> <tag :tag="item"></tag>
@ -19,8 +19,8 @@ export default defineComponent({
name: 'search-tag', name: 'search-tag',
components: { Tag }, components: { Tag },
props: { props: {
results: { tags: {
type: Object as PropType<Array<Entity.Account>>, type: Object as PropType<Array<Entity.Tag>>,
required: true required: true
} }
} }

View File

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

View File

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

View File

@ -70,8 +70,8 @@
> >
<font-awesome-icon icon="eye" class="hide" /> <font-awesome-icon icon="eye" class="hide" />
</el-button> </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 :srzc="media.preview_url" :title="media.description" /> <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-if="media.type == 'gifv'">GIF</el-tag>
<el-tag class="media-label" size="small" v-else-if="media.type == 'video'">VIDEO</el-tag> <el-tag class="media-label" size="small" v-else-if="media.type == 'video'">VIDEO</el-tag>
</div> </div>

View File

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