mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-30 17:15:16 +01:00
refs #850 Add define types for visibility in constants
This commit is contained in:
parent
0b8aa46aab
commit
87d394b025
16
src/constants/visibility/index.d.ts
vendored
Normal file
16
src/constants/visibility/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
export interface VisibilityType {
|
||||
name: string,
|
||||
value: number,
|
||||
key: string
|
||||
}
|
||||
|
||||
export interface VisibilityList {
|
||||
Public: VisibilityType,
|
||||
Unlisted: VisibilityType,
|
||||
Private: VisibilityType,
|
||||
Direct: VisibilityType
|
||||
}
|
||||
|
||||
declare var v: VisibilityList
|
||||
|
||||
export default v
|
@ -1,7 +1,6 @@
|
||||
import Mastodon, { Account } from 'megalodon'
|
||||
import Visibilities from '~/src/constants/visibility'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import Visibility from '~/src/types/visibility'
|
||||
import Visibility, { VisibilityType } from '~/src/constants/visibility'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface GeneralState {
|
||||
@ -10,7 +9,7 @@ export interface GeneralState {
|
||||
}
|
||||
|
||||
const state = (): GeneralState => ({
|
||||
visibility: Visibilities.Public.value,
|
||||
visibility: Visibility.Public.value,
|
||||
sensitive: false
|
||||
})
|
||||
|
||||
@ -35,7 +34,7 @@ const actions: ActionTree<GeneralState, RootState> = {
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const res = await client.get<Account>('/accounts/verify_credentials')
|
||||
const visibility: Visibility | undefined = Object.values(Visibilities as Array<Visibility>).find((v) => {
|
||||
const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array<VisibilityType>).find((v) => {
|
||||
return v.key === res.data.source!.privacy
|
||||
})
|
||||
commit(MUTATION_TYPES.CHANGE_VISIBILITY, visibility!.value)
|
||||
@ -47,7 +46,7 @@ const actions: ActionTree<GeneralState, RootState> = {
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const visibility = Object.values(Visibilities as Array<Visibility>).find((v) => {
|
||||
const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array<VisibilityType>).find((v) => {
|
||||
return v.value === value
|
||||
})
|
||||
const res = await client.patch<Account>('/accounts/update_credentials', {
|
||||
|
@ -1,10 +1,9 @@
|
||||
import Mastodon, { Status, Attachment, Tag, Response, Account } from 'megalodon'
|
||||
import { ipcRenderer } from 'electron'
|
||||
import Visibility from '~/src/constants/visibility'
|
||||
import Visibility, { VisibilityType } from '~/src/constants/visibility'
|
||||
import TootStatus, { StatusState } from './NewToot/Status'
|
||||
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
import VisibilityType from '~/src/types/visibility'
|
||||
|
||||
export interface NewTootState {
|
||||
modalOpen: boolean,
|
||||
@ -216,7 +215,7 @@ const actions: ActionTree<NewTootState, RootState> = {
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const res: Response<Account> = await client.get<Account>('/accounts/verify_credentials')
|
||||
const visibility: VisibilityType = Object.values(Visibility as Array<Visibility>).find((v) => {
|
||||
const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array<VisibilityType>).find((v) => {
|
||||
return v.key === res.data.source!.privacy
|
||||
})
|
||||
if (visibility === undefined) {
|
||||
|
@ -1,5 +0,0 @@
|
||||
export default interface Visibility {
|
||||
name: string,
|
||||
value: number,
|
||||
key: string
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user