refactor: Use type instead of interface
This commit is contained in:
parent
824ac51cd8
commit
ab8c74b481
|
@ -2,7 +2,7 @@ import { createLocalVue } from '@vue/test-utils'
|
|||
import Vuex from 'vuex'
|
||||
import { ipcMain } from '~/spec/mock/electron'
|
||||
import Account, { AccountState } from '@/store/Preferences/Account'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
const account: LocalAccount = {
|
||||
_id: 'sample',
|
||||
|
@ -54,10 +54,9 @@ describe('Account', () => {
|
|||
event.sender.send('error-list-accounts', new Error())
|
||||
})
|
||||
|
||||
await store.dispatch('Account/loadAccounts')
|
||||
.catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
await store.dispatch('Account/loadAccounts').catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.once('list-accounts', (event: any, _) => {
|
||||
|
@ -73,10 +72,9 @@ describe('Account', () => {
|
|||
ipcMain.once('remove-account', (event: any, _) => {
|
||||
event.sender.send('error-remove-account', new Error())
|
||||
})
|
||||
await store.dispatch('Account/removeAccount', account)
|
||||
.catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
await store.dispatch('Account/removeAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.once('remove-account', (event: any, _) => {
|
||||
|
@ -92,10 +90,9 @@ describe('Account', () => {
|
|||
ipcMain.once('forward-account', (event: any, _) => {
|
||||
event.sender.send('error-forward-account', new Error())
|
||||
})
|
||||
await store.dispatch('Account/forwardAccount', account)
|
||||
.catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
await store.dispatch('Account/forwardAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.once('forward-account', (event: any, _) => {
|
||||
|
@ -111,10 +108,9 @@ describe('Account', () => {
|
|||
ipcMain.once('backward-account', (event: any, _) => {
|
||||
event.sender.send('error-backward-account', new Error())
|
||||
})
|
||||
await store.dispatch('Account/backwardAccount', account)
|
||||
.catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
await store.dispatch('Account/backwardAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.once('backward-account', (event: any, _) => {
|
||||
|
@ -130,10 +126,9 @@ describe('Account', () => {
|
|||
ipcMain.once('remove-all-accounts', (event: any, _) => {
|
||||
event.sender.send('error-remove-all-accounts', new Error())
|
||||
})
|
||||
await store.dispatch('Account/removeAllAccounts', account)
|
||||
.catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
await store.dispatch('Account/removeAllAccounts', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.once('remove-all-accounts', (event: any, _) => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { createLocalVue } from '@vue/test-utils'
|
|||
import Vuex from 'vuex'
|
||||
import { ipcMain } from '~/spec/mock/electron'
|
||||
import SideMenu, { SideMenuState } from '~/src/renderer/store/TimelineSpace/SideMenu'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
|
||||
jest.mock('megalodon')
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Account, { AccountState, MUTATION_TYPES } from '@/store/Preferences/Account'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
const account: LocalAccount = {
|
||||
_id: 'sample',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import i18n from '~/src/config/i18n'
|
||||
import Jump, { JumpState, MUTATION_TYPES, Channel } from '@/store/TimelineSpace/Modals/Jump'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import { List } from 'megalodon'
|
||||
|
||||
describe('TimelineSpace/Modals/Jump', () => {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
export interface DisplayStyleType {
|
||||
name: string,
|
||||
export type DisplayStyleType = {
|
||||
name: string
|
||||
value: number
|
||||
}
|
||||
|
||||
export interface DisplayStyleList {
|
||||
DisplayNameAndUsername: DisplayStyleType,
|
||||
DisplayName: DisplayStyleType,
|
||||
export type DisplayStyleList = {
|
||||
DisplayNameAndUsername: DisplayStyleType
|
||||
DisplayName: DisplayStyleType
|
||||
Username: DisplayStyleType
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
export interface VisibilityType {
|
||||
name: string,
|
||||
value: number,
|
||||
export type VisibilityType = {
|
||||
name: string
|
||||
value: number
|
||||
key: string
|
||||
}
|
||||
|
||||
export interface VisibilityList {
|
||||
Public: VisibilityType,
|
||||
Unlisted: VisibilityType,
|
||||
Private: VisibilityType,
|
||||
export type VisibilityList = {
|
||||
Public: VisibilityType
|
||||
Unlisted: VisibilityType
|
||||
Private: VisibilityType
|
||||
Direct: VisibilityType
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { isEmpty } from 'lodash'
|
|||
import Mastodon, { Account as RemoteAccount } from 'megalodon'
|
||||
import Datastore from 'nedb'
|
||||
import log from 'electron-log'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
export default class Account {
|
||||
private db: Datastore
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Mastodon, { OAuth } from 'megalodon'
|
||||
import Account from './account'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
const appName = 'Whalebird'
|
||||
const appURL = 'https://whalebird.org'
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import Datastore from 'nedb'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
|
||||
export default class Hashtags {
|
||||
private db: Datastore
|
||||
|
||||
constructor (db: Datastore) {
|
||||
constructor(db: Datastore) {
|
||||
this.db = db
|
||||
this.db.ensureIndex({ fieldName: 'tagName', unique: true }, (_) => {})
|
||||
this.db.ensureIndex({ fieldName: 'tagName', unique: true }, _ => {})
|
||||
}
|
||||
|
||||
listTags (): Promise<Array<LocalTag>> {
|
||||
listTags(): Promise<Array<LocalTag>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.find<LocalTag>({}, (err, docs) => {
|
||||
if (err) return reject(err)
|
||||
|
@ -18,7 +18,7 @@ export default class Hashtags {
|
|||
})
|
||||
}
|
||||
|
||||
insertTag (tag: string): Promise<LocalTag> {
|
||||
insertTag(tag: string): Promise<LocalTag> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.insert({ tagName: tag }, (err, doc) => {
|
||||
if (err) return reject(err)
|
||||
|
@ -27,7 +27,7 @@ export default class Hashtags {
|
|||
})
|
||||
}
|
||||
|
||||
removeTag (localTag: LocalTag): Promise<number> {
|
||||
removeTag(localTag: LocalTag): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.remove(
|
||||
{
|
||||
|
|
|
@ -31,8 +31,8 @@ import Hashtags from './hashtags'
|
|||
import UnreadNotification from './unreadNotification'
|
||||
import i18n from '../config/i18n'
|
||||
import Language from '../constants/language'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import { UnreadNotification as UnreadNotificationConfig } from '~/src/types/unreadNotification'
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Mastodon, { StreamListener, Status, Notification } from 'megalodon'
|
||||
import log from 'electron-log'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
export default class Streaming {
|
||||
private client: Mastodon
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Streaming from './streaming'
|
||||
import WebSocket from './websocket'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
export default class StreamingManager {
|
||||
private streaming: Streaming
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Mastodon, { WebSocket as SocketListener, Status, Notification } from 'megalodon'
|
||||
import log from 'electron-log'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
export default class WebSocket {
|
||||
private client: Mastodon
|
||||
|
|
|
@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron'
|
|||
import { Module, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface AuthorizeState {}
|
||||
export type AuthorizeState = {}
|
||||
|
||||
const state = (): AuthorizeState => ({})
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
import router from '@/router'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface GlobalHeaderState {
|
||||
accounts: Array<LocalAccount>,
|
||||
changing: boolean,
|
||||
export type GlobalHeaderState = {
|
||||
accounts: Array<LocalAccount>
|
||||
changing: boolean
|
||||
hide: boolean
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
|
|||
if (state.changing) {
|
||||
return null
|
||||
}
|
||||
if (rootState.route.params.id as string === account._id!) {
|
||||
if ((rootState.route.params.id as string) === account._id!) {
|
||||
return null
|
||||
}
|
||||
// When the modal window is active, don't change account
|
||||
|
|
|
@ -3,8 +3,8 @@ import axios from 'axios'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface LoginState {
|
||||
selectedInstance: string | null,
|
||||
export type LoginState = {
|
||||
selectedInstance: string | null
|
||||
searching: boolean
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,9 @@ const actions: ActionTree<LoginState, RootState> = {
|
|||
},
|
||||
confirmInstance: async ({ commit }, domain: string): Promise<boolean> => {
|
||||
commit(MUTATION_TYPES.CHANGE_SEARCHING, true)
|
||||
await axios.get(`https://${domain}/api/v1/instance`)
|
||||
.finally(() => {
|
||||
commit(MUTATION_TYPES.CHANGE_SEARCHING, false)
|
||||
})
|
||||
await axios.get(`https://${domain}/api/v1/instance`).finally(() => {
|
||||
commit(MUTATION_TYPES.CHANGE_SEARCHING, false)
|
||||
})
|
||||
commit(MUTATION_TYPES.CHANGE_INSTANCE, domain)
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -6,18 +6,20 @@ import Notification, { NotificationState } from './Preferences/Notification'
|
|||
import { Module } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface PreferencesState {}
|
||||
export type PreferencesState = {}
|
||||
|
||||
const state = (): PreferencesState => ({})
|
||||
|
||||
export interface PreferencesModuleState extends PreferencesState {
|
||||
General: GeneralState,
|
||||
Account: AccountState,
|
||||
Language: LanguageState,
|
||||
Notification: NotificationState,
|
||||
type PreferencesModule = {
|
||||
General: GeneralState
|
||||
Account: AccountState
|
||||
Language: LanguageState
|
||||
Notification: NotificationState
|
||||
Appearance: AppearanceState
|
||||
}
|
||||
|
||||
export type PreferencesModuleState = PreferencesState & PreferencesModule
|
||||
|
||||
const Preferences: Module<PreferencesState, RootState> = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface AccountState {
|
||||
accounts: Array<LocalAccount>,
|
||||
export type AccountState = {
|
||||
accounts: Array<LocalAccount>
|
||||
accountLoading: boolean
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Sound } from '~/src/types/sound'
|
|||
import { Timeline } from '~/src/types/timeline'
|
||||
import { BaseConfig, General } from '~/src/types/preference'
|
||||
|
||||
export interface GeneralState {
|
||||
export type GeneralState = {
|
||||
general: General
|
||||
loading: boolean
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import { RootState } from '@/store'
|
|||
import { Language as LanguageSet } from '~/src/types/language'
|
||||
import { BaseConfig } from '~/src/types/preference'
|
||||
|
||||
export interface LanguageState {
|
||||
export type LanguageState = {
|
||||
language: LanguageSet
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { RootState } from '@/store'
|
|||
import { Notify } from '~/src/types/notify'
|
||||
import { BaseConfig, Notification } from '~/src/types/preference'
|
||||
|
||||
export interface NotificationState {
|
||||
export type NotificationState = {
|
||||
notification: Notification
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import Timeline, { TimelineState } from './Settings/Timeline'
|
|||
import { Module, MutationTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface SettingsState {
|
||||
export type SettingsState = {
|
||||
accountID: string | null
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,13 @@ const mutations: MutationTree<SettingsState> = {
|
|||
}
|
||||
}
|
||||
|
||||
export interface SettingsModuleState extends SettingsState {
|
||||
type SettingsModule = {
|
||||
General: GeneralState
|
||||
Timeline: TimelineState
|
||||
}
|
||||
|
||||
export type SettingsModuleState = SettingsModule & SettingsState
|
||||
|
||||
const Settings: Module<SettingsState, RootState> = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
|
|
|
@ -3,8 +3,8 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import Visibility, { VisibilityType } from '~/src/constants/visibility'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface GeneralState {
|
||||
visibility: number,
|
||||
export type GeneralState = {
|
||||
visibility: number
|
||||
sensitive: boolean
|
||||
}
|
||||
|
||||
|
@ -29,12 +29,9 @@ const mutations: MutationTree<GeneralState> = {
|
|||
|
||||
const actions: ActionTree<GeneralState, RootState> = {
|
||||
fetchSettings: async ({ commit, rootState }): Promise<Account> => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res = await client.get<Account>('/accounts/verify_credentials')
|
||||
const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array<VisibilityType>).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)
|
||||
|
@ -42,11 +39,8 @@ const actions: ActionTree<GeneralState, RootState> = {
|
|||
return res.data
|
||||
},
|
||||
setVisibility: async ({ commit, rootState }, value: number) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array<VisibilityType>).find((v) => {
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
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', {
|
||||
|
@ -58,10 +52,7 @@ const actions: ActionTree<GeneralState, RootState> = {
|
|||
return res.data
|
||||
},
|
||||
setSensitive: async ({ commit, rootState }, value: boolean) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res = await client.patch<Account>('/accounts/update_credentials', {
|
||||
source: {
|
||||
sensitive: value
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import { RootState } from '@/store'
|
||||
import { UnreadNotification } from '~/src/types/unreadNotification'
|
||||
|
||||
export interface TimelineState {
|
||||
export type TimelineState = {
|
||||
unreadNotification: UnreadNotification
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import Contents, { ContentsModuleState } from './TimelineSpace/Contents'
|
|||
import router from '@/router'
|
||||
import unreadSettings from '~/src/constants/unreadNotification'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { Notify } from '~/src/types/notify'
|
||||
import { RootState } from '@/store'
|
||||
import { UnreadNotification } from '~/src/types/unreadNotification'
|
||||
|
@ -17,12 +17,12 @@ import { TimelineFetchError } from '@/errors/fetch'
|
|||
|
||||
declare var Notification: any
|
||||
|
||||
interface MyEmoji {
|
||||
type MyEmoji = {
|
||||
name: string
|
||||
image: string
|
||||
}
|
||||
|
||||
export interface TimelineSpaceState {
|
||||
export type TimelineSpaceState = {
|
||||
account: LocalAccount
|
||||
loading: boolean
|
||||
emojis: Array<MyEmoji>
|
||||
|
@ -479,13 +479,15 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
|
|||
}
|
||||
}
|
||||
|
||||
export interface TimelineSpaceModuleState extends TimelineSpaceState {
|
||||
type TimelineSpaceModule = {
|
||||
SideMenu: SideMenuState
|
||||
HeaderMenu: HeaderMenuState
|
||||
Modals: ModalsModuleState
|
||||
Contents: ContentsModuleState
|
||||
}
|
||||
|
||||
export type TimelineSpaceModuleState = TimelineSpaceModule & TimelineSpaceState
|
||||
|
||||
const TimelineSpace: Module<TimelineSpaceState, RootState> = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
|
|
|
@ -13,11 +13,11 @@ import Mentions, { MentionsState } from './Contents/Mentions'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ContentsState {
|
||||
export type ContentsState = {
|
||||
loading: boolean
|
||||
}
|
||||
|
||||
export interface ContentsModuleState extends ContentsState {
|
||||
type ContentsModule = {
|
||||
SideBar: SideBarModuleState
|
||||
Home: HomeState
|
||||
Notifications: NotificationsState
|
||||
|
@ -31,6 +31,8 @@ export interface ContentsModuleState extends ContentsState {
|
|||
FollowRequests: FollowRequestsState
|
||||
}
|
||||
|
||||
export type ContentsModuleState = ContentsModule & ContentsState
|
||||
|
||||
const state = (): ContentsState => ({
|
||||
loading: false
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface DirectMessagesState {
|
||||
export type DirectMessagesState = {
|
||||
lazyLoading: boolean
|
||||
heading: boolean
|
||||
timeline: Array<Status>
|
||||
|
|
|
@ -2,9 +2,9 @@ import Mastodon, { Status, Response } from 'megalodon'
|
|||
import parse from 'parse-link-header'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
export interface FavouritesState {
|
||||
export type FavouritesState = {
|
||||
favourites: Array<Status>
|
||||
lazyLoading: boolean
|
||||
filter: string
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Account, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface FollowRequestsState {
|
||||
export type FollowRequestsState = {
|
||||
requests: Array<Account>
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,15 @@ import Tag, { TagState } from './Hashtag/Tag'
|
|||
import { Module, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface HashtagState {}
|
||||
export type HashtagState = {}
|
||||
|
||||
export interface HashtagModuleState extends HashtagState {
|
||||
List: ListState,
|
||||
type HashtagModule = {
|
||||
List: ListState
|
||||
Tag: TagState
|
||||
}
|
||||
|
||||
export type HashtagModuleState = HashtagModule & HashtagState
|
||||
|
||||
const state = (): HashtagState => ({})
|
||||
|
||||
const actions: ActionTree<HashtagState, RootState> = {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ListState {
|
||||
export type ListState = {
|
||||
tags: Array<LocalTag>
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import { RootState } from '@/store'
|
||||
import { LoadPositionWithTag } from '@/types/loadPosition'
|
||||
|
||||
export interface TagState {
|
||||
export type TagState = {
|
||||
timeline: Array<Status>
|
||||
unreadTimeline: Array<Status>
|
||||
lazyLoading: boolean
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface HomeState {
|
||||
export type HomeState = {
|
||||
lazyLoading: boolean
|
||||
heading: boolean
|
||||
showReblogs: boolean
|
||||
|
|
|
@ -4,14 +4,16 @@ import Edit, { EditState } from './Lists/Edit'
|
|||
import { Module } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ListsState {}
|
||||
export type ListsState = {}
|
||||
|
||||
export interface ListsModuleState extends ListsState {
|
||||
Index: IndexState,
|
||||
Show: ShowState,
|
||||
type ListModule = {
|
||||
Index: IndexState
|
||||
Show: ShowState
|
||||
Edit: EditState
|
||||
}
|
||||
|
||||
export type ListsModuleState = ListModule & ListsState
|
||||
|
||||
const state = (): ListsState => ({})
|
||||
|
||||
export default {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import { RootState } from '@/store'
|
||||
import { RemoveAccountFromList } from '@/types/removeAccountFromList'
|
||||
|
||||
export interface EditState {
|
||||
export type EditState = {
|
||||
members: Array<Account>
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { List, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface IndexState {
|
||||
export type IndexState = {
|
||||
lists: Array<List>
|
||||
}
|
||||
|
||||
|
@ -22,19 +22,13 @@ const mutations: MutationTree<IndexState> = {
|
|||
|
||||
const actions: ActionTree<IndexState, RootState> = {
|
||||
fetchLists: async ({ commit, rootState }): Promise<Array<List>> => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<List>> = await client.get<Array<List>>('/lists')
|
||||
commit(MUTATION_TYPES.CHANGE_LISTS, res.data)
|
||||
return res.data
|
||||
},
|
||||
createList: async ({ rootState }, title: string): Promise<List> => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<List> = await client.post<List>('/lists', {
|
||||
title: title
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import { RootState } from '@/store'
|
||||
import { LoadPositionWithList } from '@/types/loadPosition'
|
||||
|
||||
export interface ShowState {
|
||||
export type ShowState = {
|
||||
timeline: Array<Status>
|
||||
unreadTimeline: Array<Status>
|
||||
lazyLoading: boolean
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface LocalState {
|
||||
export type LocalState = {
|
||||
timeline: Array<Status>
|
||||
unreadTimeline: Array<Status>
|
||||
lazyLoading: boolean
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Notification, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface MentionsState {
|
||||
export type MentionsState = {
|
||||
lazyLoading: boolean
|
||||
heading: boolean
|
||||
mentions: Array<Notification>
|
||||
|
|
|
@ -3,7 +3,7 @@ import Mastodon, { Notification, Status, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface NotificationsState {
|
||||
export type NotificationsState = {
|
||||
lazyLoading: boolean
|
||||
heading: boolean
|
||||
notifications: Array<Notification>
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface PublicState {
|
||||
export type PublicState = {
|
||||
timeline: Array<Status>
|
||||
unreadTimeline: Array<Status>
|
||||
lazyLoading: boolean
|
||||
|
|
|
@ -4,14 +4,16 @@ import Toots, { TootsState } from './Search/Toots'
|
|||
import { Module } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface SearchState {}
|
||||
export type SearchState = {}
|
||||
|
||||
export interface SearchModuleState extends SearchState {
|
||||
type SearchModule = {
|
||||
Account: AccountState
|
||||
Tag: TagState
|
||||
Toots: TootsState
|
||||
}
|
||||
|
||||
export type SearchModuleState = SearchModule & SearchState
|
||||
|
||||
const state = (): SearchState => ({})
|
||||
|
||||
const Search: Module<SearchState, RootState> = {
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Account } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface AccountState {
|
||||
export type AccountState = {
|
||||
results: Array<Account>
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Tag, Results } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface TagState {
|
||||
export type TagState = {
|
||||
results: Array<Tag>
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Status, Results } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface TootsState {
|
||||
export type TootsState = {
|
||||
results: Array<Status>
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,21 @@ import TootDetail, { TootDetailState } from './SideBar/TootDetail'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface SideBarState {
|
||||
openSideBar: boolean,
|
||||
export type SideBarState = {
|
||||
openSideBar: boolean
|
||||
// 0: blank
|
||||
// 1: account-profile
|
||||
// 2: toot-detail
|
||||
component: number
|
||||
}
|
||||
|
||||
export interface SideBarModuleState extends SideBarState {
|
||||
TootDetail: TootDetailState,
|
||||
type SideBarModule = {
|
||||
TootDetail: TootDetailState
|
||||
AccountProfile: AccountProfileModuleState
|
||||
}
|
||||
|
||||
export type SideBarModuleState = SideBarModule & SideBarState
|
||||
|
||||
const state = (): SideBarState => ({
|
||||
openSideBar: false,
|
||||
component: 0
|
||||
|
|
|
@ -5,18 +5,20 @@ import Followers, { FollowersState } from './AccountProfile/Followers'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface AccountProfileState {
|
||||
export type AccountProfileState = {
|
||||
account: Account | null
|
||||
relationship: Relationship | null
|
||||
loading: boolean
|
||||
}
|
||||
|
||||
export interface AccountProfileModuleState extends AccountProfileState {
|
||||
type AccountProfileModule = {
|
||||
Followers: FollowersState
|
||||
Follows: FollowsState
|
||||
Timeline: TimelineState
|
||||
}
|
||||
|
||||
export type AccountProfileModuleState = AccountProfileModule & AccountProfileState
|
||||
|
||||
const state = (): AccountProfileState => ({
|
||||
account: null,
|
||||
relationship: null,
|
||||
|
|
|
@ -2,8 +2,8 @@ import Mastodon, { Account, Relationship, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface FollowersState {
|
||||
followers: Array<Account>,
|
||||
export type FollowersState = {
|
||||
followers: Array<Account>
|
||||
relationships: Array<Relationship>
|
||||
}
|
||||
|
||||
|
@ -28,20 +28,14 @@ const mutations: MutationTree<FollowersState> = {
|
|||
|
||||
const actions: ActionTree<FollowersState, RootState> = {
|
||||
fetchFollowers: async ({ commit, rootState }, account: Account) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<Account>> = await client.get<Array<Account>>(`/accounts/${account.id}/followers`, { limit: 80 })
|
||||
commit(MUTATION_TYPES.UPDATE_FOLLOWERS, res.data)
|
||||
return res.data
|
||||
},
|
||||
fetchRelationships: async ({ commit, rootState }, accounts: Array<Account>) => {
|
||||
const ids = accounts.map(a => a.id)
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<Relationship>> = await client.get<Array<Relationship>>(`/accounts/relationships`, {
|
||||
id: ids
|
||||
})
|
||||
|
|
|
@ -2,8 +2,8 @@ import Mastodon, { Account, Relationship, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface FollowsState {
|
||||
follows: Array<Account>,
|
||||
export type FollowsState = {
|
||||
follows: Array<Account>
|
||||
relationships: Array<Relationship>
|
||||
}
|
||||
|
||||
|
@ -28,20 +28,14 @@ const mutations: MutationTree<FollowsState> = {
|
|||
|
||||
const actions: ActionTree<FollowsState, RootState> = {
|
||||
fetchFollows: async ({ commit, rootState }, account: Account) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<Account>> = await client.get<Array<Account>>(`/accounts/${account.id}/following`, { limit: 80 })
|
||||
commit(MUTATION_TYPES.UPDATE_FOLLOWS, res.data)
|
||||
return res.data
|
||||
},
|
||||
fetchRelationships: async ({ commit, rootState }, accounts: Array<Account>) => {
|
||||
const ids = accounts.map(a => a.id)
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<Relationship>> = await client.get<Array<Relationship>>(`/accounts/relationships`, {
|
||||
id: ids
|
||||
})
|
||||
|
|
|
@ -3,9 +3,9 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import { RootState } from '@/store'
|
||||
import { LoadPositionWithAccount } from '@/types/loadPosition'
|
||||
|
||||
export interface TimelineState {
|
||||
timeline: Array<Status>,
|
||||
pinnedToots: Array<Status>,
|
||||
export type TimelineState = {
|
||||
timeline: Array<Status>
|
||||
pinnedToots: Array<Status>
|
||||
lazyLoading: boolean
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ const mutations: MutationTree<TimelineState> = {
|
|||
state.lazyLoading = value
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_PINNED_TOOT]: (state, message: Status) => {
|
||||
state.pinnedToots = state.pinnedToots.map((toot) => {
|
||||
state.pinnedToots = state.pinnedToots.map(toot => {
|
||||
if (toot.id === message.id) {
|
||||
return message
|
||||
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
|
@ -56,7 +56,7 @@ const mutations: MutationTree<TimelineState> = {
|
|||
},
|
||||
[MUTATION_TYPES.UPDATE_TOOT]: (state, message: Status) => {
|
||||
// Replace target message in timeline
|
||||
state.timeline = state.timeline.map((toot) => {
|
||||
state.timeline = state.timeline.map(toot => {
|
||||
if (toot.id === message.id) {
|
||||
return message
|
||||
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
|
@ -72,7 +72,7 @@ const mutations: MutationTree<TimelineState> = {
|
|||
})
|
||||
},
|
||||
[MUTATION_TYPES.DELETE_TOOT]: (state, message: Status) => {
|
||||
state.timeline = state.timeline.filter((toot) => {
|
||||
state.timeline = state.timeline.filter(toot => {
|
||||
if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
return false
|
||||
} else {
|
||||
|
@ -85,10 +85,7 @@ const mutations: MutationTree<TimelineState> = {
|
|||
const actions: ActionTree<TimelineState, RootState> = {
|
||||
fetchTimeline: async ({ commit, rootState }, account: Account) => {
|
||||
commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true, { root: true })
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const pinned: Response<Array<Status>> = await client.get<Array<Status>>(`/accounts/${account.id}/statuses`, { limit: 10, pinned: true })
|
||||
commit(MUTATION_TYPES.UPDATE_PINNED_TOOTS, pinned.data)
|
||||
const res: Response<Array<Status>> = await client.get<Array<Status>>(`/accounts/${account.id}/statuses`, { limit: 40 })
|
||||
|
@ -101,12 +98,12 @@ const actions: ActionTree<TimelineState, RootState> = {
|
|||
return Promise.resolve(null)
|
||||
}
|
||||
commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, true)
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
try {
|
||||
const res: Response<Array<Status>> = await client.get<Array<Status>>(`/accounts/${loadPosition.account.id}/statuses`, { max_id: loadPosition.status.id, limit: 40 })
|
||||
const res: Response<Array<Status>> = await client.get<Array<Status>>(`/accounts/${loadPosition.account.id}/statuses`, {
|
||||
max_id: loadPosition.status.id,
|
||||
limit: 40
|
||||
})
|
||||
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
|
||||
} finally {
|
||||
commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, false)
|
||||
|
|
|
@ -2,9 +2,9 @@ import Mastodon, { Status, Context, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface TootDetailState {
|
||||
message: Status | null,
|
||||
ancestors: Array<Status>,
|
||||
export type TootDetailState = {
|
||||
message: Status | null
|
||||
ancestors: Array<Status>
|
||||
descendants: Array<Status>
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ const mutations: MutationTree<TootDetailState> = {
|
|||
},
|
||||
[MUTATION_TYPES.UPDATE_ANCESTORS_TOOT]: (state, message: Status) => {
|
||||
// Replace target message in ancestors
|
||||
state.ancestors = state.ancestors.map((toot) => {
|
||||
state.ancestors = state.ancestors.map(toot => {
|
||||
if (toot.id === message.id) {
|
||||
return message
|
||||
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
|
@ -54,7 +54,7 @@ const mutations: MutationTree<TootDetailState> = {
|
|||
})
|
||||
},
|
||||
[MUTATION_TYPES.DELETE_ANCESTORS_TOOT]: (state, message: Status) => {
|
||||
state.ancestors = state.ancestors.filter((toot) => {
|
||||
state.ancestors = state.ancestors.filter(toot => {
|
||||
if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
return false
|
||||
} else {
|
||||
|
@ -87,7 +87,7 @@ const mutations: MutationTree<TootDetailState> = {
|
|||
},
|
||||
[MUTATION_TYPES.UPDATE_DESCENDANTS_TOOT]: (state, message: Status) => {
|
||||
// Replace target message in descendants
|
||||
state.descendants = state.descendants.map((toot) => {
|
||||
state.descendants = state.descendants.map(toot => {
|
||||
if (toot.id === message.id) {
|
||||
return message
|
||||
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
|
@ -103,7 +103,7 @@ const mutations: MutationTree<TootDetailState> = {
|
|||
})
|
||||
},
|
||||
[MUTATION_TYPES.DELETE_DESCENDANTS_TOOT]: (state, message: Status) => {
|
||||
state.descendants = state.descendants.filter((toot) => {
|
||||
state.descendants = state.descendants.filter(toot => {
|
||||
if (toot.reblog !== null && toot.reblog.id === message.id) {
|
||||
return false
|
||||
} else {
|
||||
|
@ -120,10 +120,7 @@ const actions: ActionTree<TootDetailState, RootState> = {
|
|||
commit(MUTATION_TYPES.CHANGE_TOOT, message)
|
||||
},
|
||||
fetchToot: async ({ commit, rootState }, message: Status) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Context> = await client.get<Context>(`/statuses/${message.id}/context`, { limit: 40 })
|
||||
|
||||
commit(MUTATION_TYPES.UPDATE_ANCESTORS, res.data.ancestors)
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
|
|||
import { RootState } from '@/store'
|
||||
import AxiosLoading from '@/utils/axiosLoading'
|
||||
|
||||
export interface HeaderMenuState {
|
||||
export type HeaderMenuState = {
|
||||
title: string
|
||||
reload: boolean
|
||||
loading: boolean
|
||||
|
|
|
@ -9,19 +9,21 @@ import Report, { ReportState } from './Modals/Report'
|
|||
import { Module, GetterTree } from 'vuex'
|
||||
import { RootState } from '@/store/index'
|
||||
|
||||
export interface ModalsState {}
|
||||
export type ModalsState = {}
|
||||
|
||||
export interface ModalsModuleState extends ModalsState {
|
||||
Jump: JumpState,
|
||||
AddListMember: AddListMemberState,
|
||||
ImageViewer: ImageViewerState,
|
||||
ListMembership: ListMembershipState,
|
||||
MuteConfirm: MuteConfirmState,
|
||||
NewToot: NewTootModuleState,
|
||||
Report: ReportState,
|
||||
type ModalsModule = {
|
||||
Jump: JumpState
|
||||
AddListMember: AddListMemberState
|
||||
ImageViewer: ImageViewerState
|
||||
ListMembership: ListMembershipState
|
||||
MuteConfirm: MuteConfirmState
|
||||
NewToot: NewTootModuleState
|
||||
Report: ReportState
|
||||
Shortcut: ShortcutState
|
||||
}
|
||||
|
||||
export type ModalsModuleState = ModalsModule & ModalsState
|
||||
|
||||
const state = (): ModalsState => ({})
|
||||
|
||||
const getters: GetterTree<ModalsState, RootState> = {
|
||||
|
|
|
@ -2,7 +2,7 @@ import Mastodon, { Account, Response } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface AddListMemberState {
|
||||
export type AddListMemberState = {
|
||||
modalOpen: boolean
|
||||
accounts: Array<Account>
|
||||
targetListId: string | null
|
||||
|
|
|
@ -2,10 +2,10 @@ import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
|
|||
import { Attachment } from 'megalodon'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ImageViewerState {
|
||||
modalOpen: boolean,
|
||||
currentIndex: number,
|
||||
mediaList: Array<Attachment>,
|
||||
export type ImageViewerState = {
|
||||
modalOpen: boolean
|
||||
currentIndex: number
|
||||
mediaList: Array<Attachment>
|
||||
loading: boolean
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,10 @@ const mutations: MutationTree<ImageViewerState> = {
|
|||
[MUTATION_TYPES.CHANGE_MEDIA_LIST]: (state, mediaList: Array<Attachment>) => {
|
||||
state.mediaList = mediaList
|
||||
},
|
||||
[MUTATION_TYPES.INCREMENT_INDEX]: (state) => {
|
||||
[MUTATION_TYPES.INCREMENT_INDEX]: state => {
|
||||
state.currentIndex++
|
||||
},
|
||||
[MUTATION_TYPES.DECREMENT_INDEX]: (state) => {
|
||||
[MUTATION_TYPES.DECREMENT_INDEX]: state => {
|
||||
state.currentIndex--
|
||||
},
|
||||
[MUTATION_TYPES.CHANGE_LOADING]: (state, value: boolean) => {
|
||||
|
@ -86,14 +86,14 @@ const getters: GetterTree<ImageViewerState, RootState> = {
|
|||
return null
|
||||
},
|
||||
showLeft: (state): boolean => {
|
||||
const notFirst = (state.currentIndex > 0)
|
||||
const isManyItem = (state.mediaList.length > 1)
|
||||
return (notFirst && isManyItem)
|
||||
const notFirst = state.currentIndex > 0
|
||||
const isManyItem = state.mediaList.length > 1
|
||||
return notFirst && isManyItem
|
||||
},
|
||||
showRight: (state): boolean => {
|
||||
const notLast = (state.currentIndex < (state.mediaList.length - 1))
|
||||
const isManyItem = (state.mediaList.length > 1)
|
||||
return (notLast && isManyItem)
|
||||
const notLast = state.currentIndex < state.mediaList.length - 1
|
||||
const isManyItem = state.mediaList.length > 1
|
||||
return notLast && isManyItem
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,20 +2,20 @@ import router from '@/router'
|
|||
import i18n from '~/src/config/i18n'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { List } from 'megalodon'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface Channel {
|
||||
name: string,
|
||||
export type Channel = {
|
||||
name: string
|
||||
path: string
|
||||
}
|
||||
|
||||
export interface JumpState {
|
||||
modalOpen: boolean,
|
||||
channel: string,
|
||||
defaultChannelList: Array<Channel>,
|
||||
listChannelList: Array<Channel>,
|
||||
tagChannelList: Array<Channel>,
|
||||
export type JumpState = {
|
||||
modalOpen: boolean
|
||||
channel: string
|
||||
defaultChannelList: Array<Channel>
|
||||
listChannelList: Array<Channel>
|
||||
tagChannelList: Array<Channel>
|
||||
selectedChannel: Channel
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ const mutations: MutationTree<JumpState> = {
|
|||
state.selectedChannel = channel
|
||||
},
|
||||
[MUTATION_TYPES.UPDATE_LIST_CHANNEL]: (state, lists: Array<List>) => {
|
||||
state.listChannelList = lists.map((l) => {
|
||||
state.listChannelList = lists.map(l => {
|
||||
const channel: Channel = {
|
||||
name: `#${l.title}`,
|
||||
path: `lists/${l.id}`
|
||||
|
|
|
@ -3,10 +3,10 @@ import lodash from 'lodash'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ListMembershipState {
|
||||
modalOpen: boolean,
|
||||
account: Account | null,
|
||||
lists: Array<List>,
|
||||
export type ListMembershipState = {
|
||||
modalOpen: boolean
|
||||
account: Account | null
|
||||
lists: Array<List>
|
||||
belongToLists: Array<List>
|
||||
}
|
||||
|
||||
|
@ -47,19 +47,13 @@ const actions: ActionTree<ListMembershipState, RootState> = {
|
|||
commit(MUTATION_TYPES.CHANGE_ACCOUNT, account)
|
||||
},
|
||||
fetchListMembership: async ({ commit, rootState }, account: Account) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<List>> = await client.get<Array<List>>(`/accounts/${account.id}/lists`)
|
||||
commit(MUTATION_TYPES.CHANGE_BELONG_TO_LISTS, res.data.map(l => l.id))
|
||||
return res.data
|
||||
},
|
||||
fetchLists: async ({ commit, rootState }) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Array<List>> = await client.get<Array<List>>('/lists')
|
||||
commit(MUTATION_TYPES.CHANGE_LISTS, res.data)
|
||||
return res.data
|
||||
|
@ -69,10 +63,7 @@ const actions: ActionTree<ListMembershipState, RootState> = {
|
|||
const removedLists = lodash.difference(state.belongToLists, belongToLists)
|
||||
const addedLists = lodash.difference(belongToLists, state.belongToLists)
|
||||
commit(MUTATION_TYPES.CHANGE_BELONG_TO_LISTS, belongToLists)
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const removedPromise = removedLists.map(id => {
|
||||
return client.del<{}>(`/lists/${id}/accounts`, {
|
||||
account_ids: [state.account!.id]
|
||||
|
|
|
@ -2,8 +2,8 @@ import Mastodon, { Account, Response, Relationship } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface MuteConfirmState {
|
||||
modalOpen: boolean,
|
||||
export type MuteConfirmState = {
|
||||
modalOpen: boolean
|
||||
account: Account | null
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,7 @@ const actions: ActionTree<MuteConfirmState, RootState> = {
|
|||
commit(MUTATION_TYPES.CHANGE_ACCOUNT, account)
|
||||
},
|
||||
submit: async ({ state, rootState, dispatch }, notify: boolean) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
const res: Response<Relationship> = await client.post<Relationship>(`/accounts/${state.account!.id}/mute`, {
|
||||
notifications: notify
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ type MediaDescription = {
|
|||
description: string
|
||||
}
|
||||
|
||||
export interface NewTootState {
|
||||
export type NewTootState = {
|
||||
modalOpen: boolean
|
||||
initialStatus: string
|
||||
initialSpoiler: string
|
||||
|
@ -36,10 +36,12 @@ export interface NewTootState {
|
|||
loading: boolean
|
||||
}
|
||||
|
||||
export interface NewTootModuleState extends NewTootState {
|
||||
type NewTootModule = {
|
||||
Status: StatusState
|
||||
}
|
||||
|
||||
export type NewTootModuleState = NewTootModule & NewTootState
|
||||
|
||||
const state = (): NewTootState => ({
|
||||
modalOpen: false,
|
||||
initialStatus: '',
|
||||
|
|
|
@ -11,7 +11,7 @@ interface SuggestAccount extends Suggest {}
|
|||
|
||||
interface SuggestHashtag extends Suggest {}
|
||||
|
||||
export interface StatusState {
|
||||
export type StatusState = {
|
||||
filteredAccounts: Array<SuggestAccount>
|
||||
filteredHashtags: Array<SuggestHashtag>
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ import Mastodon, { Status } from 'megalodon'
|
|||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ReportState {
|
||||
modalOpen: boolean,
|
||||
export type ReportState = {
|
||||
modalOpen: boolean
|
||||
message: Status | null
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,7 @@ const actions: ActionTree<ReportState, RootState> = {
|
|||
commit(MUTATION_TYPES.CHANGE_MODAL_OPEN, true)
|
||||
},
|
||||
submit: async ({ rootState }, { account_id, status_id, comment }) => {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken!,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
|
||||
return client.post<{}>(`/reports`, {
|
||||
account_id: account_id,
|
||||
status_ids: [status_id],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Module, MutationTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface ShortcutState {
|
||||
export type ShortcutState = {
|
||||
modalOpen: boolean
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import Mastodon, { List, Response, Account } from 'megalodon'
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import LocalTag from '~/src/types/localTag'
|
||||
import LocalAccount from '~/src/types/localAccount'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface SideMenuState {
|
||||
export type SideMenuState = {
|
||||
unreadHomeTimeline: boolean
|
||||
unreadNotifications: boolean
|
||||
unreadMentions: boolean
|
||||
|
|
|
@ -14,23 +14,21 @@ import molecules, { MoleculesModuleState } from './molecules'
|
|||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export interface RootState {
|
||||
App: AppState,
|
||||
GlobalHeader: GlobalHeaderState,
|
||||
Login: LoginState,
|
||||
Authorize: AuthorizeState,
|
||||
TimelineSpace: TimelineSpaceModuleState,
|
||||
Preferences: PreferencesModuleState,
|
||||
Settings: SettingsModuleState,
|
||||
molecules: MoleculesModuleState,
|
||||
export type RootState = {
|
||||
App: AppState
|
||||
GlobalHeader: GlobalHeaderState
|
||||
Login: LoginState
|
||||
Authorize: AuthorizeState
|
||||
TimelineSpace: TimelineSpaceModuleState
|
||||
Preferences: PreferencesModuleState
|
||||
Settings: SettingsModuleState
|
||||
molecules: MoleculesModuleState
|
||||
route: Route
|
||||
}
|
||||
|
||||
export default new Vuex.Store({
|
||||
strict: process.env.NODE_ENV !== 'production',
|
||||
plugins: process.env.NODE_ENV !== 'production'
|
||||
? [createLogger({})]
|
||||
: [],
|
||||
plugins: process.env.NODE_ENV !== 'production' ? [createLogger({})] : [],
|
||||
modules: {
|
||||
App,
|
||||
GlobalHeader,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Toot, { TootState } from './molecules/Toot'
|
||||
|
||||
export interface MoleculesModuleState {
|
||||
export type MoleculesModuleState = {
|
||||
Toot: TootState
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { ipcRenderer } from 'electron'
|
|||
import { Module, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface TootState {}
|
||||
export type TootState = {}
|
||||
|
||||
const state = (): TootState => ({})
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import { Status, Account } from 'megalodon'
|
||||
|
||||
export interface LoadPosition {
|
||||
export type LoadPosition = {
|
||||
status: Status
|
||||
}
|
||||
|
||||
export interface LoadPositionWithAccount extends LoadPosition {
|
||||
export type LoadPositionWithAccount = LoadPosition & {
|
||||
account: Account
|
||||
}
|
||||
|
||||
export interface LoadPositionWithList extends LoadPosition {
|
||||
export type LoadPositionWithList = LoadPosition & {
|
||||
list_id: string
|
||||
}
|
||||
|
||||
export interface LoadPositionWithTag extends LoadPosition {
|
||||
export type LoadPositionWithTag = LoadPosition & {
|
||||
tag: string
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Account } from 'megalodon'
|
||||
|
||||
export interface RemoveAccountFromList {
|
||||
export type RemoveAccountFromList = {
|
||||
account: Account
|
||||
listId: string
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default interface LocalAccount {
|
||||
export type LocalAccount = {
|
||||
_id?: string
|
||||
baseURL: string
|
||||
domain: string
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default interface LocalTag {
|
||||
tagName: string,
|
||||
export type LocalTag = {
|
||||
tagName: string
|
||||
_id?: string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue