refs #850 Fix name for local account types

This commit is contained in:
AkiraFukushima 2019-04-14 23:21:08 +09:00
parent baf6dc3084
commit a45d68684c
8 changed files with 38 additions and 38 deletions

View File

@ -2,9 +2,9 @@ import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import { ipcMain } from '~/spec/mock/electron'
import Account, { AccountState } from '@/store/Preferences/Account'
import AccountType from '~/src/types/account'
import LocalAccount from '~/src/types/LocalAccount'
const account: AccountType = {
const account: LocalAccount = {
_id: 'sample',
baseURL: 'http://example.com',
domain: 'example.com',

View File

@ -1,7 +1,7 @@
import Account, { AccountState, MUTATION_TYPES } from '@/store/Preferences/Account'
import AccountType from '~/src/types/account'
import LocalAccount from '~/src/types/localAccount'
const account: AccountType = {
const account: LocalAccount = {
_id: 'sample',
baseURL: 'http://example.com',
domain: 'example.com',

View File

@ -1,11 +1,11 @@
import { ipcRenderer } from 'electron'
import router from '@/router'
import Account from '~/src/types/account'
import LocalAccount from '~/src/types/localAccount'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
export interface GlobalHeaderState {
accounts: Array<Account>,
accounts: Array<LocalAccount>,
changing: boolean,
hide: boolean
}
@ -23,7 +23,7 @@ export const MUTATION_TYPES = {
}
const mutations: MutationTree<GlobalHeaderState> = {
[MUTATION_TYPES.UPDATE_ACCOUNTS]: (state: GlobalHeaderState, accounts: Array<Account>) => {
[MUTATION_TYPES.UPDATE_ACCOUNTS]: (state: GlobalHeaderState, accounts: Array<LocalAccount>) => {
state.accounts = accounts
},
[MUTATION_TYPES.UPDATE_CHANGING]: (state: GlobalHeaderState, value: boolean) => {
@ -35,14 +35,14 @@ const mutations: MutationTree<GlobalHeaderState> = {
}
const actions: ActionTree<GlobalHeaderState, RootState> = {
listAccounts: ({ dispatch, commit }): Promise<Array<Account>> => {
listAccounts: ({ dispatch, commit }): Promise<Array<LocalAccount>> => {
return new Promise((resolve, reject) => {
ipcRenderer.send('list-accounts', 'list')
ipcRenderer.once('error-list-accounts', (_, err: Error) => {
ipcRenderer.removeAllListeners('response-list-accounts')
reject(err)
})
ipcRenderer.once('response-list-accounts', (_, accounts: Array<Account>) => {
ipcRenderer.once('response-list-accounts', (_, accounts: Array<LocalAccount>) => {
ipcRenderer.removeAllListeners('error-list-accounts')
commit(MUTATION_TYPES.UPDATE_ACCOUNTS, accounts)
dispatch('refreshAccounts')
@ -51,14 +51,14 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
})
},
// Fetch account informations and save current state when GlobalHeader is displayed
refreshAccounts: ({ commit }): Promise<Array<Account>> => {
refreshAccounts: ({ commit }): Promise<Array<LocalAccount>> => {
return new Promise((resolve, reject) => {
ipcRenderer.send('refresh-accounts')
ipcRenderer.once('error-refresh-accounts', (_, err: Error) => {
ipcRenderer.removeAllListeners('response-refresh-accounts')
reject(err)
})
ipcRenderer.once('response-refresh-accounts', (_, accounts: Array<Account>) => {
ipcRenderer.once('response-refresh-accounts', (_, accounts: Array<LocalAccount>) => {
ipcRenderer.removeAllListeners('error-refresh-accounts')
commit(MUTATION_TYPES.UPDATE_ACCOUNTS, accounts)
resolve(accounts)
@ -66,7 +66,7 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
})
},
watchShortcutEvents: ({ state, commit, rootState, rootGetters }) => {
ipcRenderer.on('change-account', (_, account: Account) => {
ipcRenderer.on('change-account', (_, account: LocalAccount) => {
if (state.changing) {
return null
}

View File

@ -1,10 +1,10 @@
import { ipcRenderer } from 'electron'
import { Module, MutationTree, ActionTree } from 'vuex'
import Account from '~/src/types/account'
import LocalAccount from '~/src/types/localAccount'
import { RootState } from '@/store'
export interface AccountState {
accounts: Array<Account>,
accounts: Array<LocalAccount>,
accountLoading: boolean
}
@ -19,7 +19,7 @@ export const MUTATION_TYPES = {
}
const mutations: MutationTree<AccountState> = {
[MUTATION_TYPES.UPDATE_ACCOUNTS]: (state, accounts: Array<Account>) => {
[MUTATION_TYPES.UPDATE_ACCOUNTS]: (state, accounts: Array<LocalAccount>) => {
state.accounts = accounts
},
[MUTATION_TYPES.UPDATE_ACCOUNT_LOADING]: (state, value: boolean) => {
@ -28,21 +28,21 @@ const mutations: MutationTree<AccountState> = {
}
const actions: ActionTree<AccountState, RootState> = {
loadAccounts: ({ commit }): Promise<Array<Account>> => {
loadAccounts: ({ commit }): Promise<Array<LocalAccount>> => {
return new Promise((resolve, reject) => {
ipcRenderer.send('list-accounts', 'list')
ipcRenderer.once('error-list-accounts', (_, err: Error) => {
ipcRenderer.removeAllListeners('response-list-accounts')
reject(err)
})
ipcRenderer.once('response-list-accounts', (_, accounts: Array<Account>) => {
ipcRenderer.once('response-list-accounts', (_, accounts: Array<LocalAccount>) => {
ipcRenderer.removeAllListeners('error-list-accounts')
commit(MUTATION_TYPES.UPDATE_ACCOUNTS, accounts)
resolve(accounts)
})
})
},
removeAccount: (_, account: Account) => {
removeAccount: (_, account: LocalAccount) => {
return new Promise((resolve, reject) => {
ipcRenderer.send('remove-account', account._id)
ipcRenderer.once('error-remove-account', (_, err: Error) => {
@ -55,7 +55,7 @@ const actions: ActionTree<AccountState, RootState> = {
})
})
},
forwardAccount: (_, account: Account) => {
forwardAccount: (_, account: LocalAccount) => {
return new Promise((resolve, reject) => {
ipcRenderer.send('forward-account', account)
ipcRenderer.once('error-forward-account', (_, err: Error) => {
@ -68,7 +68,7 @@ const actions: ActionTree<AccountState, RootState> = {
})
})
},
backwardAccount: (_, account: Account) => {
backwardAccount: (_, account: LocalAccount) => {
return new Promise((resolve, reject) => {
ipcRenderer.send('backward-account', account)
ipcRenderer.once('error-backward-account', (_, err: Error) => {

View File

@ -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 AccountType from '~/src/types/account'
import LocalAccount from '~/src/types/localAccount'
import { Notify } from './App'
import { RootState } from '@/store'
@ -26,7 +26,7 @@ interface UnreadNotification {
}
export interface TimelineSpaceState {
account: AccountType,
account: LocalAccount,
loading: boolean,
emojis: Array<MyEmoji>,
tootMax: number,
@ -35,7 +35,7 @@ export interface TimelineSpaceState {
pleroma: boolean
}
export const blankAccount: AccountType = {
export const blankAccount: LocalAccount = {
_id: '',
baseURL: '',
domain: '',
@ -74,7 +74,7 @@ export const MUTATION_TYPES = {
}
const mutations: MutationTree<TimelineSpaceState> = {
[MUTATION_TYPES.UPDATE_ACCOUNT]: (state, account: AccountType) => {
[MUTATION_TYPES.UPDATE_ACCOUNT]: (state, account: LocalAccount) => {
state.account = account
},
[MUTATION_TYPES.CHANGE_LOADING]: (state, value: boolean) => {
@ -110,19 +110,19 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
// -------------------------------------------------
// Accounts
// -------------------------------------------------
localAccount: ({ dispatch, commit }, id: string): Promise<AccountType> => {
localAccount: ({ dispatch, commit }, id: string): Promise<LocalAccount> => {
return new Promise((resolve, reject) => {
ipcRenderer.send('get-local-account', id)
ipcRenderer.once('error-get-local-account', (_, err: Error) => {
ipcRenderer.removeAllListeners('response-get-local-account')
reject(err)
})
ipcRenderer.once('response-get-local-account', (_, account: AccountType) => {
ipcRenderer.once('response-get-local-account', (_, account: LocalAccount) => {
ipcRenderer.removeAllListeners('error-get-local-account')
if (account.username === undefined || account.username === null || account.username === '') {
dispatch('fetchAccount', account)
.then((acct: AccountType) => {
.then((acct: LocalAccount) => {
commit(MUTATION_TYPES.UPDATE_ACCOUNT, acct)
resolve(acct)
})
@ -136,14 +136,14 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
})
})
},
fetchAccount: (_, account: AccountType): Promise<AccountType> => {
fetchAccount: (_, account: LocalAccount): Promise<LocalAccount> => {
return new Promise((resolve, reject) => {
ipcRenderer.send('update-account', account)
ipcRenderer.once('error-update-account', (_, err: Error) => {
ipcRenderer.removeAllListeners('response-update-account')
reject(err)
})
ipcRenderer.once('response-update-account', (_, account: AccountType) => {
ipcRenderer.once('response-update-account', (_, account: LocalAccount) => {
ipcRenderer.removeAllListeners('error-update-account')
resolve(account)
})
@ -188,7 +188,7 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
/**
* fetchEmojis
*/
fetchEmojis: async ({ commit }, account: AccountType): Promise<Array<Emoji>> => {
fetchEmojis: async ({ commit }, account: LocalAccount): Promise<Array<Emoji>> => {
const res = await Mastodon.get<Array<Emoji>>('/custom_emojis', {}, account.baseURL + '/api/v1')
commit(MUTATION_TYPES.UPDATE_EMOJIS, res.data)
return res.data
@ -196,7 +196,7 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
/**
* fetchInstance
*/
fetchInstance: async ({ commit }, account: AccountType) => {
fetchInstance: async ({ commit }, account: LocalAccount) => {
const res = await Mastodon.get<Instance>('/instance', {}, account.baseURL + '/api/v1')
commit(MUTATION_TYPES.UPDATE_TOOT_MAX, res.data.max_toot_chars)
return true
@ -242,7 +242,7 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
commit('TimelineSpace/Contents/Public/clearTimeline', {}, { root: true })
commit('TimelineSpace/Contents/Mentions/clearMentions', {}, { root: true })
},
bindStreamings: ({ dispatch, state }, account: AccountType) => {
bindStreamings: ({ dispatch, state }, account: LocalAccount) => {
dispatch('bindUserStreaming', account)
if (state.unreadNotification.direct) {
dispatch('bindDirectMessagesStreaming')
@ -281,7 +281,7 @@ const actions: ActionTree<TimelineSpaceState, RootState> = {
// ------------------------------------------------
// Each streaming methods
// ------------------------------------------------
bindUserStreaming: ({ commit, rootState }, account: AccountType) => {
bindUserStreaming: ({ commit, rootState }, account: LocalAccount) => {
ipcRenderer.on('update-start-user-streaming', (_, update: Status) => {
commit('TimelineSpace/Contents/Home/appendTimeline', update, { root: true })
// Sometimes archive old statuses

View File

@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
import parse from 'parse-link-header'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import AccountType from '~/src/types/account'
import LocalAccount from '~/src/types/localAccount'
export interface FavouritesState {
favourites: Array<Status>,
@ -72,7 +72,7 @@ const mutations: MutationTree<FavouritesState> = {
}
const actions: ActionTree<FavouritesState, RootState> = {
fetchFavourites: async ({ commit }, account: AccountType): Promise<Array<Status>> => {
fetchFavourites: async ({ commit }, account: LocalAccount): Promise<Array<Status>> => {
const client = new Mastodon(
account.accessToken!,
account.baseURL + '/api/v1'

View File

@ -2,7 +2,7 @@ import Mastodon, { List, Response } from 'megalodon'
import { ipcRenderer } from 'electron'
import { Module, MutationTree, ActionTree } from 'vuex'
import Hashtag from '~/src/types/hashtag'
import Account from '~/src/types/account'
import LocalAccount from '~/src/types/localAccount'
import { RootState } from '@/store'
export interface SideMenuState {
@ -72,7 +72,7 @@ const mutations: MutationTree<SideMenuState> = {
}
const actions: ActionTree<SideMenuState, RootState> = {
fetchLists: async ({ commit, rootState }, account: Account | null = null): Promise<Array<List>> => {
fetchLists: async ({ commit, rootState }, account: LocalAccount | null = null): Promise<Array<List>> => {
if (account === null) account = rootState.TimelineSpace.account
const client = new Mastodon(
account!.accessToken!,

View File

@ -1,4 +1,4 @@
export default interface Account {
export default interface LocalAccount {
_id?: string,
baseURL: string,
domain: string,