diff --git a/package-lock.json b/package-lock.json index 498d1025..1bb83c85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13167,9 +13167,9 @@ "dev": true }, "megalodon": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/megalodon/-/megalodon-0.6.3.tgz", - "integrity": "sha512-rxh9Kbbwm9Hnn/e8xdzH2Fw5kD/TamgyGFEzOcsnKCqF4iI2qHuojCBm7KeWohgRlwJ9oq7QYVReEVTipqI8kQ==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/megalodon/-/megalodon-0.7.0.tgz", + "integrity": "sha512-mpRXvUYvJ9D1A/CUgecUok/vjSbd9nV5zzOjt5QdzdiFKtv3ETJC7a5zk9X2aXSFawUcgpaZwyVLxfVO4n6pyg==", "requires": { "@types/oauth": "0.9.1", "@types/request": "2.48.1", @@ -13177,14 +13177,14 @@ "axios": "0.18.0", "oauth": "0.9.15", "request": "2.88.0", - "typescript": "2.9.2", + "typescript": "3.4.5", "websocket": "1.0.28" }, "dependencies": { "typescript": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", - "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==" + "version": "3.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==" } } }, @@ -21120,7 +21120,7 @@ "integrity": "sha512-00y/20/80P7H4bCYkzuuvvfDvh+dgtXi5kzDf3UcZwN6boTYaKvsrtZ5lIYm1Gsg48siMErd9M4zjSYfYFHTrA==", "requires": { "debug": "2.6.9", - "nan": "2.13.2", + "nan": "2.14.0", "typedarray-to-buffer": "3.1.5", "yaeti": "0.0.6" }, @@ -21134,9 +21134,9 @@ } }, "nan": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", - "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==" + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" } } }, diff --git a/package.json b/package.json index 506ff07a..9e563f75 100644 --- a/package.json +++ b/package.json @@ -171,7 +171,7 @@ "i18next": "^12.1.0", "i18next-sync-fs-backend": "^1.1.0", "lodash": "^4.17.11", - "megalodon": "0.6.3", + "megalodon": "0.7.0", "moment": "^2.21.0", "mousetrap": "^1.6.2", "nedb": "^1.8.0", diff --git a/spec/renderer/integration/store/TimelineSpace.spec.ts b/spec/renderer/integration/store/TimelineSpace.spec.ts index 62d4c4a3..dce5f1db 100644 --- a/spec/renderer/integration/store/TimelineSpace.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace.spec.ts @@ -94,6 +94,9 @@ const contentsStore = { Local: LocalStore, Public: PublicStore, Mentions: MentionStore + }, + actions: { + changeLoading: jest.fn() } } @@ -168,7 +171,7 @@ describe('TimelineSpace', () => { } }) it('should be detected', async () => { - (Mastodon.get as any).mockResolvedValue(mockedResponse) + ;(Mastodon.get as any).mockResolvedValue(mockedResponse) await store.dispatch('TimelineSpace/detectPleroma') expect(store.state.TimelineSpace.pleroma).toEqual(true) expect(store.state.TimelineSpace.useWebsocket).toEqual(true) @@ -203,7 +206,7 @@ describe('TimelineSpace', () => { } }) it('should be detected', async () => { - (Mastodon.get as any).mockResolvedValue(mockedResponse) + ;(Mastodon.get as any).mockResolvedValue(mockedResponse) await store.dispatch('TimelineSpace/detectPleroma') expect(store.state.TimelineSpace.pleroma).toEqual(false) expect(store.state.TimelineSpace.useWebsocket).toEqual(false) @@ -229,17 +232,14 @@ describe('TimelineSpace', () => { visible_in_picker: true } mockedResponse = { - data: [ - emacsEmoji, - rubyEmoji - ], + data: [emacsEmoji, rubyEmoji], status: 200, statusText: 'OK', headers: {} } }) it('should be updated', async () => { - (Mastodon.get as any).mockResolvedValue(mockedResponse) + ;(Mastodon.get as any).mockResolvedValue(mockedResponse) await store.dispatch('TimelineSpace/fetchEmojis', {}) expect(store.state.TimelineSpace.emojis).toEqual([ { @@ -249,7 +249,8 @@ describe('TimelineSpace', () => { { image: 'http://example.com/ruby', name: ':ruby:' - }]) + } + ]) }) }) @@ -264,7 +265,7 @@ describe('TimelineSpace', () => { } }) it('should be updated', async () => { - (Mastodon.get as any).mockResolvedValue(mockedResponse) + ;(Mastodon.get as any).mockResolvedValue(mockedResponse) await store.dispatch('TimelineSpace/fetchInstance', {}) expect(store.state.TimelineSpace.tootMax).toEqual(5000) }) diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts index 113bc13e..35dc93c3 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts @@ -7,7 +7,7 @@ import Home, { HomeState } from '@/store/TimelineSpace/Contents/Home' jest.mock('megalodon') const account: Account = { - id: 1, + id: '1', username: 'h3poteto', acct: 'h3poteto@pleroma.io', display_name: 'h3poteto', @@ -28,7 +28,7 @@ const account: Account = { bot: false } const status1: Status = { - id: 1, + id: '1', uri: 'http://example.com', url: 'http://example.com', account: account, @@ -58,7 +58,7 @@ const status1: Status = { pinned: null } const status2: Status = { - id: 2, + id: '2', uri: 'http://example.com', url: 'http://example.com', account: account, @@ -141,9 +141,7 @@ describe('Home', () => { get: (_path: string, _params: object) => { return new Promise>(resolve => { const res: Response = { - data: [ - status1 - ], + data: [status1], status: 200, statusText: 'OK', headers: {} @@ -155,12 +153,8 @@ describe('Home', () => { mockedMegalodon.mockImplementation(() => mockClient) const statuses = await store.dispatch('Home/fetchTimeline') - expect(statuses).toEqual([ - status1 - ]) - expect(store.state.Home.timeline).toEqual([ - status1 - ]) + expect(statuses).toEqual([status1]) + expect(store.state.Home.timeline).toEqual([status1]) }) }) @@ -184,9 +178,7 @@ describe('Home', () => { get: (_path: string, _params: object) => { return new Promise>(resolve => { const res: Response<[Status]> = { - data: [ - status2 - ], + data: [status2], status: 200, statusText: 'OK', headers: {} @@ -198,10 +190,7 @@ describe('Home', () => { mockedMegalodon.mockImplementation(() => mockClient) await store.dispatch('Home/lazyFetchTimeline', { id: 20 }) expect(store.state.Home.lazyLoading).toEqual(false) - expect(store.state.Home.timeline).toEqual([ - status1, - status2 - ]) + expect(store.state.Home.timeline).toEqual([status1, status2]) }) }) }) diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts index a7dd8089..c2a158e2 100644 --- a/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts @@ -7,7 +7,7 @@ import Mentions from '~/src/renderer/store/TimelineSpace/Contents/Mentions' jest.mock('megalodon') const account: Account = { - id: 1, + id: '1', username: 'h3poteto', acct: 'h3poteto@pleroma.io', display_name: 'h3poteto', @@ -29,7 +29,7 @@ const account: Account = { } const status: Status = { - id: 1, + id: '1', uri: 'http://example.com', url: 'http://example.com', account: account, @@ -62,7 +62,7 @@ const status: Status = { const mention: Notification = { account: account, created_at: '2019-03-26T21:40:32', - id: 1, + id: '1', status: status, type: 'mention' } @@ -70,7 +70,7 @@ const mention: Notification = { const reblog: Notification = { account: account, created_at: '2019-03-26T21:40:32', - id: 2, + id: '2', status: status, type: 'reblog' } @@ -78,7 +78,7 @@ const reblog: Notification = { const favourite: Notification = { account: account, created_at: '2019-03-26T21:40:32', - id: 3, + id: '3', status: status, type: 'favourite' } @@ -86,7 +86,7 @@ const favourite: Notification = { const follow: Notification = { account: account, created_at: '2019-03-26T21:40:32', - id: 4, + id: '4', status: null, type: 'follow' } @@ -142,12 +142,7 @@ describe('Mentions', () => { get: (_path: string, _params: object) => { return new Promise>(resolve => { const res: Response = { - data: [ - mention, - reblog, - favourite, - follow - ], + data: [mention, reblog, favourite, follow], status: 200, statusText: 'OK', headers: {} @@ -159,12 +154,7 @@ describe('Mentions', () => { mockedMegalodon.mockImplementation(() => mockClient) await store.dispatch('Mentions/fetchMentions') - expect(store.state.Mentions.mentions).toEqual([ - mention, - reblog, - favourite, - follow - ]) + expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow]) }) }) @@ -193,10 +183,7 @@ describe('Mentions', () => { return { lazyLoading: false, heading: true, - mentions: [ - mention, - reblog - ], + mentions: [mention, reblog], unreadMentions: [], filter: '' } @@ -207,10 +194,7 @@ describe('Mentions', () => { get: (_path: string, _params: object) => { return new Promise>(resolve => { const res: Response = { - data: [ - favourite, - follow - ], + data: [favourite, follow], status: 200, statusText: 'OK', headers: {} @@ -222,12 +206,7 @@ describe('Mentions', () => { mockedMegalodon.mockImplementation(() => mockClient) await store.dispatch('Mentions/lazyFetchMentions', { id: 1 }) - expect(store.state.Mentions.mentions).toEqual([ - mention, - reblog, - favourite, - follow - ]) + expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow]) expect(store.state.Mentions.lazyLoading).toEqual(false) }) }) @@ -239,12 +218,7 @@ describe('Mentions', () => { return { lazyLoading: false, heading: true, - mentions: [ - mention, - favourite, - reblog, - follow - ], + mentions: [mention, favourite, reblog, follow], unreadMentions: [], filter: '' } @@ -252,9 +226,7 @@ describe('Mentions', () => { }) it('should return only mentions', () => { const mentions = store.getters['Mentions/mentions'] - expect(mentions).toEqual([ - mention - ]) + expect(mentions).toEqual([mention]) }) }) }) diff --git a/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts b/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts index fc26aa2e..df591bea 100644 --- a/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts @@ -7,7 +7,7 @@ import HeaderMenu, { HeaderMenuState } from '~/src/renderer/store/TimelineSpace/ jest.mock('megalodon') const list: List = { - id: 1, + id: '1', title: 'example' } diff --git a/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts b/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts index 67ae6446..6efd0d03 100644 --- a/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts @@ -7,7 +7,7 @@ import AddListMember, { AddListMemberState } from '@/store/TimelineSpace/Modals/ jest.mock('megalodon') const account: Account = { - id: 1, + id: '1', username: 'h3poteto', acct: 'h3poteto@pleroma.io', display_name: 'h3poteto', @@ -83,9 +83,7 @@ describe('AddListMember', () => { get: () => { return new Promise>(resolve => { const res: Response = { - data: [ - account - ], + data: [account], status: 200, statusText: 'OK', headers: {} @@ -97,9 +95,7 @@ describe('AddListMember', () => { mockedMegalodon.mockImplementation(() => mockClient) await store.dispatch('AddListMember/search', 'akira') - expect(store.state.AddListMember.accounts).toEqual([ - account - ]) + expect(store.state.AddListMember.accounts).toEqual([account]) }) }) diff --git a/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts b/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts index 843e95c0..0b347067 100644 --- a/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts @@ -7,7 +7,7 @@ import ListMembership, { ListMembershipState } from '@/store/TimelineSpace/Modal jest.mock('megalodon') const account: Account = { - id: 1, + id: '1', username: 'h3poteto', acct: 'h3poteto@pleroma.io', display_name: 'h3poteto', @@ -29,12 +29,12 @@ const account: Account = { } const list1: List = { - id: 1, + id: '1', title: 'list1' } const list2: List = { - id: 2, + id: '2', title: 'list2' } @@ -86,10 +86,7 @@ describe('ListMembership', () => { get: (_path: string, _params: object) => { return new Promise>(resolve => { const res: Response = { - data: [ - list1, - list2 - ], + data: [list1, list2], status: 200, statusText: 'OK', headers: {} @@ -100,9 +97,9 @@ describe('ListMembership', () => { } mockedMegalodon.mockImplementation(() => mockClient) await store.dispatch('ListMembership/fetchListMembership', { - id: 5 + id: '5' }) - expect(store.state.ListMembership.belongToLists).toEqual([1, 2]) + expect(store.state.ListMembership.belongToLists).toEqual(['1', '2']) }) }) @@ -112,10 +109,7 @@ describe('ListMembership', () => { get: (_path: string, _params: object) => { return new Promise>(resolve => { const res: Response = { - data: [ - list1, - list2 - ], + data: [list1, list2], status: 200, statusText: 'OK', headers: {} @@ -126,10 +120,7 @@ describe('ListMembership', () => { } mockedMegalodon.mockImplementation(() => mockClient) await store.dispatch('ListMembership/fetchLists') - expect(store.state.ListMembership.lists).toEqual([ - list1, - list2 - ]) + expect(store.state.ListMembership.lists).toEqual([list1, list2]) }) }) @@ -140,9 +131,7 @@ describe('ListMembership', () => { modalOpen: false, account: account, lists: [], - belongToLists: [ - list2 - ] + belongToLists: [list2] } } }) diff --git a/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts b/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts index 300c388a..08dc9137 100644 --- a/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts +++ b/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts @@ -9,12 +9,12 @@ import LocalTag from '~/src/types/localTag' jest.mock('megalodon') const list1: List = { - id: 1, + id: '1', title: 'example1' } const list2: List = { - id: 2, + id: '2', title: 'example2' } diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts index 2a4b2dfd..8abb77c5 100644 --- a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts +++ b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts @@ -2,7 +2,7 @@ import { Account, Status, Application } from 'megalodon' import Home, { HomeState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Home' const account: Account = { - id: 1, + id: '1', username: 'h3poteto', acct: 'h3poteto@pleroma.io', display_name: 'h3poteto', @@ -23,7 +23,7 @@ const account: Account = { bot: false } const status1: Status = { - id: 1, + id: '1', uri: 'http://example.com', url: 'http://example.com', account: account, @@ -53,7 +53,7 @@ const status1: Status = { pinned: null } const status2: Status = { - id: 2, + id: '2', uri: 'http://example.com', url: 'http://example.com', account: account, @@ -212,7 +212,7 @@ describe('TimelineSpace/Contents/Home', () => { }) describe('message is reblogged', () => { const rebloggedStatus: Status = { - id: 3, + id: '3', uri: 'http://example.com', url: 'http://example.com', account: account, @@ -285,7 +285,7 @@ describe('TimelineSpace/Contents/Home', () => { describe('message is reblogged', () => { beforeEach(() => { const rebloggedStatus: Status = { - id: 3, + id: '3', uri: 'http://example.com', url: 'http://example.com', account: account, diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts index b9187204..628355b5 100644 --- a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts +++ b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts @@ -2,7 +2,7 @@ import { Account, Notification, Status, Application } from 'megalodon' import Mentions, { MentionsState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Mentions' const account1: Account = { - id: 1, + id: '1', username: 'h3poteto', acct: 'h3poteto@pleroma.io', display_name: 'h3poteto', @@ -24,7 +24,7 @@ const account1: Account = { } const account2: Account = { - id: 2, + id: '2', username: 'h3poteto', acct: 'h3poteto@mstdn.io', display_name: 'h3poteto', @@ -46,7 +46,7 @@ const account2: Account = { } const status: Status = { - id: 1, + id: '1', uri: 'http://example.com', url: 'http://example.com', account: account1, @@ -77,7 +77,7 @@ const status: Status = { } const notification1: Notification = { - id: 1, + id: '1', account: account2, status: status, type: 'favourite', @@ -85,7 +85,7 @@ const notification1: Notification = { } const notification2: Notification = { - id: 2, + id: '2', account: account2, status: status, type: 'reblog', diff --git a/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts b/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts index d1fadebb..b5560458 100644 --- a/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts +++ b/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts @@ -56,15 +56,15 @@ describe('TimelineSpace/Modals/Jump', () => { describe('updateListChannel', () => { it('should be updated', () => { const admin: List = { - id: 0, + id: '0', title: 'admin' } const engineer: List = { - id: 1, + id: '1', title: 'engineer' } const designer: List = { - id: 2, + id: '2', title: 'designer' } const channelList = [admin, engineer, designer] diff --git a/src/main/index.ts b/src/main/index.ts index 852bf44d..97277910 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -607,7 +607,7 @@ ipcMain.on('stop-public-streaming', () => { let listStreaming: StreamingManager | null = null type ListID = { - listID: number + listID: string } ipcMain.on('start-list-streaming', (event: Event, obj: ListID & StreamingSetting) => { diff --git a/src/renderer/components/TimelineSpace.vue b/src/renderer/components/TimelineSpace.vue index b82c8591..62a9fa30 100644 --- a/src/renderer/components/TimelineSpace.vue +++ b/src/renderer/components/TimelineSpace.vue @@ -116,7 +116,7 @@ export default { return false } this.$store.dispatch('TimelineSpace/Modals/NewToot/openModal') - this.$store.dispatch('TimelineSpace/Modals/NewToot/incrementMediaId') + this.$store.dispatch('TimelineSpace/Modals/NewToot/incrementMediaCount') this.$store.dispatch('TimelineSpace/Modals/NewToot/uploadImage', file).catch(() => { this.$message({ message: this.$t('message.attach_error'), diff --git a/src/renderer/components/TimelineSpace/Modals/NewToot.vue b/src/renderer/components/TimelineSpace/Modals/NewToot.vue index 8edc2b4c..57478ed8 100644 --- a/src/renderer/components/TimelineSpace/Modals/NewToot.vue +++ b/src/renderer/components/TimelineSpace/Modals/NewToot.vue @@ -208,7 +208,7 @@ export default { methods: { close() { this.filteredAccount = [] - this.$store.dispatch('TimelineSpace/Modals/NewToot/resetMediaId') + this.$store.dispatch('TimelineSpace/Modals/NewToot/resetMediaCount') this.$store.dispatch('TimelineSpace/Modals/NewToot/closeModal') }, async toot() { @@ -277,7 +277,7 @@ export default { this.updateImage(file) }, updateImage(file) { - this.$store.dispatch('TimelineSpace/Modals/NewToot/incrementMediaId') + this.$store.dispatch('TimelineSpace/Modals/NewToot/incrementMediaCount') this.$store.dispatch('TimelineSpace/Modals/NewToot/uploadImage', file).catch(() => { this.$message({ message: this.$t('message.attach_error'), diff --git a/src/renderer/store/Settings.ts b/src/renderer/store/Settings.ts index 651608a0..b511ac10 100644 --- a/src/renderer/store/Settings.ts +++ b/src/renderer/store/Settings.ts @@ -4,7 +4,7 @@ import { Module, MutationTree } from 'vuex' import { RootState } from '@/store' export interface SettingsState { - accountID: number | null + accountID: string | null } const state = (): SettingsState => ({ @@ -16,14 +16,14 @@ export const MUTATION_TYPES = { } const mutations: MutationTree = { - [MUTATION_TYPES.CHANGE_ACCOUNT_ID]: (state, id: number) => { + [MUTATION_TYPES.CHANGE_ACCOUNT_ID]: (state, id: string) => { state.accountID = id } } export interface SettingsModuleState extends SettingsState { - General: GeneralState, - Timeline: TimelineState, + General: GeneralState + Timeline: TimelineState } const Settings: Module = { diff --git a/src/renderer/store/TimelineSpace.ts b/src/renderer/store/TimelineSpace.ts index 259762fc..9d402b70 100644 --- a/src/renderer/store/TimelineSpace.ts +++ b/src/renderer/store/TimelineSpace.ts @@ -104,7 +104,7 @@ const mutations: MutationTree = { } const actions: ActionTree = { - initLoad: async ({ dispatch, commit }, accountId: number): Promise => { + initLoad: async ({ dispatch, commit }, accountId: string): Promise => { commit(MUTATION_TYPES.CHANGE_LOADING, true) dispatch('watchShortcutEvents') const account = await dispatch('localAccount', accountId).catch(_ => { diff --git a/src/renderer/store/TimelineSpace/Contents/Favourites.ts b/src/renderer/store/TimelineSpace/Contents/Favourites.ts index dcedadb8..c2be32b3 100644 --- a/src/renderer/store/TimelineSpace/Contents/Favourites.ts +++ b/src/renderer/store/TimelineSpace/Contents/Favourites.ts @@ -5,10 +5,10 @@ import { RootState } from '@/store' import LocalAccount from '~/src/types/localAccount' export interface FavouritesState { - favourites: Array, - lazyLoading: boolean, - filter: string, - maxId: number | null + favourites: Array + lazyLoading: boolean + filter: string + maxId: string | null } const state = (): FavouritesState => ({ @@ -36,7 +36,7 @@ const mutations: MutationTree = { state.favourites = state.favourites.concat(favourites) }, [MUTATION_TYPES.UPDATE_TOOT]: (state, message: Status) => { - state.favourites = state.favourites.map((toot) => { + state.favourites = state.favourites.map(toot => { if (toot.id === message.id) { return message } else if (toot.reblog !== null && toot.reblog.id === message.id) { @@ -52,7 +52,7 @@ const mutations: MutationTree = { }) }, [MUTATION_TYPES.DELETE_TOOT]: (state, message: Status) => { - state.favourites = state.favourites.filter((toot) => { + state.favourites = state.favourites.filter(toot => { if (toot.reblog !== null && toot.reblog.id === message.id) { return false } else { @@ -66,24 +66,21 @@ const mutations: MutationTree = { [MUTATION_TYPES.CHANGE_FILTER]: (state, filter: string) => { state.filter = filter }, - [MUTATION_TYPES.CHANGE_MAX_ID]: (state, id: number | null) => { + [MUTATION_TYPES.CHANGE_MAX_ID]: (state, id: string | null) => { state.maxId = id } } const actions: ActionTree = { fetchFavourites: async ({ commit }, account: LocalAccount): Promise> => { - const client = new Mastodon( - account.accessToken!, - account.baseURL + '/api/v1' - ) + const client = new Mastodon(account.accessToken!, account.baseURL + '/api/v1') const res: Response> = await client.get>('/favourites', { limit: 40 }) commit(MUTATION_TYPES.UPDATE_FAVOURITES, res.data) // Parse link header try { const link = parse(res.headers.link) if (link !== null) { - commit(MUTATION_TYPES.CHANGE_MAX_ID, parseInt(link.next.max_id)) + commit(MUTATION_TYPES.CHANGE_MAX_ID, link.next.max_id) } else { commit(MUTATION_TYPES.CHANGE_MAX_ID, null) } @@ -101,20 +98,16 @@ const actions: ActionTree = { 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 res: Response> = await client.get>('/favourites', { max_id: state.maxId, limit: 40 }) - .finally(() => { - commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, false) - }) + const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') + const res: Response> = await client.get>('/favourites', { max_id: state.maxId, limit: 40 }).finally(() => { + commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, false) + }) commit(MUTATION_TYPES.INSERT_FAVOURITES, res.data) // Parse link header try { const link = parse(res.headers.link) if (link !== null) { - commit(MUTATION_TYPES.CHANGE_MAX_ID, parseInt(link.next.max_id)) + commit(MUTATION_TYPES.CHANGE_MAX_ID, link.next.max_id) } else { commit(MUTATION_TYPES.CHANGE_MAX_ID, null) } diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts index 7c222418..b7c4d63f 100644 --- a/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts +++ b/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts @@ -22,11 +22,8 @@ const mutations: MutationTree = { } const actions: ActionTree = { - fetchMembers: async ({ commit, rootState }, listId: number): Promise> => { - const client = new Mastodon( - rootState.TimelineSpace.account.accessToken!, - rootState.TimelineSpace.account.baseURL + '/api/v1' - ) + fetchMembers: async ({ commit, rootState }, listId: string): Promise> => { + const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const res: Response> = await client.get>(`/lists/${listId}/accounts`, { limit: 0 }) @@ -34,10 +31,7 @@ const actions: ActionTree = { return res.data }, removeAccount: async ({ rootState }, remove: RemoveAccountFromList): Promise<{}> => { - 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.del<{}>(`/lists/${remove.listId}/accounts`, { account_ids: [remove.account.id] }) diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts index 3bf30031..c30214de 100644 --- a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts +++ b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts @@ -5,10 +5,10 @@ import { RootState } from '@/store' import { LoadPositionWithList } from '@/types/loadPosition' export interface ShowState { - timeline: Array, - unreadTimeline: Array, - lazyLoading: boolean, - heading: boolean, + timeline: Array + unreadTimeline: Array + lazyLoading: boolean + heading: boolean filter: string } @@ -48,22 +48,22 @@ const mutations: MutationTree = { [MUTATION_TYPES.UPDATE_TIMELINE]: (state, timeline: Array) => { state.timeline = timeline }, - [MUTATION_TYPES.MERGE_TIMELINE]: (state) => { + [MUTATION_TYPES.MERGE_TIMELINE]: state => { state.timeline = state.unreadTimeline.slice(0, 80).concat(state.timeline) state.unreadTimeline = [] }, [MUTATION_TYPES.INSERT_TIMELINE]: (state, messages: Array) => { state.timeline = state.timeline.concat(messages) }, - [MUTATION_TYPES.ARCHIVE_TIMELINE]: (state) => { + [MUTATION_TYPES.ARCHIVE_TIMELINE]: state => { state.timeline = state.timeline.slice(0, 40) }, - [MUTATION_TYPES.CLEAR_TIMELINE]: (state) => { + [MUTATION_TYPES.CLEAR_TIMELINE]: state => { state.timeline = [] state.unreadTimeline = [] }, [MUTATION_TYPES.UPDATE_TOOT]: (state, message: Status) => { - 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) { @@ -79,7 +79,7 @@ const mutations: MutationTree = { }) }, [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 { @@ -96,16 +96,13 @@ const mutations: MutationTree = { } const actions: ActionTree = { - fetchTimeline: async ({ commit, rootState }, listID: number): Promise> => { - const client = new Mastodon( - rootState.TimelineSpace.account.accessToken!, - rootState.TimelineSpace.account.baseURL + '/api/v1' - ) + fetchTimeline: async ({ commit, rootState }, listID: string): Promise> => { + const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const res: Response> = await client.get>(`/timelines/list/${listID}`, { limit: 40 }) commit(MUTATION_TYPES.UPDATE_TIMELINE, res.data) return res.data }, - startStreaming: ({ state, commit, rootState }, listID: number) => { + startStreaming: ({ state, commit, rootState }, listID: string) => { ipcRenderer.on('update-start-list-streaming', (_, update: Status) => { commit(MUTATION_TYPES.APPEND_TIMELINE, update) if (state.heading && Math.random() > 0.8) { @@ -113,7 +110,8 @@ const actions: ActionTree = { } }) // @ts-ignore - return new Promise((resolve, reject) => { // eslint-disable-line no-unused-vars + return new Promise((resolve, reject) => { + // eslint-disable-line no-unused-vars ipcRenderer.send('start-list-streaming', { listID: listID, account: rootState.TimelineSpace.account, @@ -137,11 +135,9 @@ const actions: ActionTree = { 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' - ) - return client.get>(`/timelines/list/${loadPosition.list_id}`, { max_id: loadPosition.status.id, limit: 40 }) + const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') + return client + .get>(`/timelines/list/${loadPosition.list_id}`, { max_id: loadPosition.status.id, limit: 40 }) .then(res => { commit(MUTATION_TYPES.INSERT_TIMELINE, res.data) return res.data diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts index 57341a81..c7c053a9 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts @@ -42,7 +42,7 @@ const mutations: MutationTree = { } const actions: ActionTree = { - fetchAccount: async ({ rootState }, accountID: number): Promise => { + fetchAccount: async ({ rootState }, accountID: string): Promise => { const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const res: Response = await client.get(`/accounts/${accountID}`) return res.data diff --git a/src/renderer/store/TimelineSpace/HeaderMenu.ts b/src/renderer/store/TimelineSpace/HeaderMenu.ts index 3c42a70e..d4a139a8 100644 --- a/src/renderer/store/TimelineSpace/HeaderMenu.ts +++ b/src/renderer/store/TimelineSpace/HeaderMenu.ts @@ -34,7 +34,7 @@ const mutations: MutationTree = { } const actions: ActionTree = { - fetchList: async ({ commit, rootState }, listID: number): Promise => { + fetchList: async ({ commit, rootState }, listID: string): Promise => { const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1') const res: Response = await client.get(`/lists/${listID}`) commit(MUTATION_TYPES.UPDATE_TITLE, `#${res.data.title}`) diff --git a/src/renderer/store/TimelineSpace/Modals/AddListMember.ts b/src/renderer/store/TimelineSpace/Modals/AddListMember.ts index b097fc2a..cc0d45da 100644 --- a/src/renderer/store/TimelineSpace/Modals/AddListMember.ts +++ b/src/renderer/store/TimelineSpace/Modals/AddListMember.ts @@ -3,9 +3,9 @@ import { Module, MutationTree, ActionTree } from 'vuex' import { RootState } from '@/store' export interface AddListMemberState { - modalOpen: boolean, - accounts: Array, - targetListId: number | null + modalOpen: boolean + accounts: Array + targetListId: string | null } const state = (): AddListMemberState => ({ @@ -27,7 +27,7 @@ const mutations: MutationTree = { [MUTATION_TYPES.UPDATE_ACCOUNTS]: (state, accounts: Array) => { state.accounts = accounts }, - [MUTATION_TYPES.SET_LIST_ID]: (state, id: number) => { + [MUTATION_TYPES.SET_LIST_ID]: (state, id: string) => { state.targetListId = id } } @@ -37,10 +37,7 @@ const actions: ActionTree = { commit(MUTATION_TYPES.CHANGE_MODAL, value) }, search: async ({ commit, rootState }, name: string): Promise> => { - 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> = await client.get>('/accounts/search', { q: name, following: true @@ -49,10 +46,7 @@ const actions: ActionTree = { return res.data }, add: async ({ state, rootState }, account: Account): Promise<{}> => { - 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<{}> = await client.post<{}>(`/lists/${state.targetListId}/accounts`, { account_ids: [account.id] }) diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot.ts b/src/renderer/store/TimelineSpace/Modals/NewToot.ts index 9cc024ff..9e9ccc9c 100644 --- a/src/renderer/store/TimelineSpace/Modals/NewToot.ts +++ b/src/renderer/store/TimelineSpace/Modals/NewToot.ts @@ -16,7 +16,7 @@ import { } from '@/errors/validations' type MediaDescription = { - id: number + id: string description: string } @@ -27,10 +27,10 @@ export interface NewTootState { replyToMessage: Status | null blockSubmit: boolean attachedMedias: Array - mediaDescriptions: { [key: number]: string | null } + mediaDescriptions: { [key: string]: string | null } visibility: number sensitive: boolean - attachedMediaId: number + attachedMediaCount: number pinedHashtag: boolean hashtags: Array loading: boolean @@ -50,7 +50,7 @@ const state = (): NewTootState => ({ mediaDescriptions: {}, visibility: Visibility.Public.value, sensitive: false, - attachedMediaId: 0, + attachedMediaCount: 0, pinedHashtag: false, hashtags: [], loading: false @@ -70,7 +70,7 @@ export const MUTATION_TYPES = { REMOVE_MEDIA_DESCRIPTION: 'removeMediaDescription', CHANGE_VISIBILITY_VALUE: 'changeVisibilityValue', CHANGE_SENSITIVE: 'changeSensitive', - UPDATE_MEDIA_ID: 'updateMediaId', + UPDATE_MEDIA_COUNT: 'updateMediaCount', CHANGE_PINED_HASHTAG: 'changePinedHashtag', UPDATE_HASHTAGS: 'updateHashtags', CHANGE_LOADING: 'changeLoading' @@ -107,7 +107,7 @@ const mutations: MutationTree = { [MUTATION_TYPES.CLEAR_MEDIA_DESCRIPTIONS]: state => { state.mediaDescriptions = {} }, - [MUTATION_TYPES.REMOVE_MEDIA_DESCRIPTION]: (state, id: number) => { + [MUTATION_TYPES.REMOVE_MEDIA_DESCRIPTION]: (state, id: string) => { const descriptions = state.mediaDescriptions delete descriptions[id] state.mediaDescriptions = descriptions @@ -124,8 +124,8 @@ const mutations: MutationTree = { [MUTATION_TYPES.CHANGE_SENSITIVE]: (state, value: boolean) => { state.sensitive = value }, - [MUTATION_TYPES.UPDATE_MEDIA_ID]: (state, value: number) => { - state.attachedMediaId = value + [MUTATION_TYPES.UPDATE_MEDIA_COUNT]: (state, count: number) => { + state.attachedMediaCount = count }, [MUTATION_TYPES.CHANGE_PINED_HASHTAG]: (state, value: boolean) => { state.pinedHashtag = value @@ -286,19 +286,19 @@ const actions: ActionTree = { throw err }) }, - incrementMediaId: ({ commit, state }) => { - commit(MUTATION_TYPES.UPDATE_MEDIA_ID, state.attachedMediaId + 1) + incrementMediaCount: ({ commit, state }) => { + commit(MUTATION_TYPES.UPDATE_MEDIA_COUNT, state.attachedMediaCount + 1) }, - decrementMediaId: ({ commit, state }) => { - commit(MUTATION_TYPES.UPDATE_MEDIA_ID, state.attachedMediaId - 1) + decrementMediaCount: ({ commit, state }) => { + commit(MUTATION_TYPES.UPDATE_MEDIA_COUNT, state.attachedMediaCount - 1) }, - resetMediaId: ({ commit }) => { - commit(MUTATION_TYPES.UPDATE_MEDIA_ID, 0) + resetMediaCount: ({ commit }) => { + commit(MUTATION_TYPES.UPDATE_MEDIA_COUNT, 0) }, removeMedia: ({ commit, dispatch }, media: Attachment) => { commit(MUTATION_TYPES.REMOVE_MEDIA, media) commit(MUTATION_TYPES.REMOVE_MEDIA_DESCRIPTION, media.id) - dispatch('decrementMediaId') + dispatch('decrementMediaCount') }, updateHashtags: ({ commit, state }, tags: Array) => { if (state.pinedHashtag && tags.length > 0) { diff --git a/src/renderer/types/loadPosition.ts b/src/renderer/types/loadPosition.ts index 19ff171b..9d832395 100644 --- a/src/renderer/types/loadPosition.ts +++ b/src/renderer/types/loadPosition.ts @@ -9,7 +9,7 @@ export interface LoadPositionWithAccount extends LoadPosition { } export interface LoadPositionWithList extends LoadPosition { - list_id: number + list_id: string } export interface LoadPositionWithTag extends LoadPosition { diff --git a/src/renderer/types/removeAccountFromList.ts b/src/renderer/types/removeAccountFromList.ts index 108da874..2530215f 100644 --- a/src/renderer/types/removeAccountFromList.ts +++ b/src/renderer/types/removeAccountFromList.ts @@ -1,6 +1,6 @@ import { Account } from 'megalodon' export interface RemoveAccountFromList { - account: Account, - listId: number + account: Account + listId: string } diff --git a/src/types/localAccount.ts b/src/types/localAccount.ts index 1eef2aff..71aa3a87 100644 --- a/src/types/localAccount.ts +++ b/src/types/localAccount.ts @@ -1,13 +1,13 @@ export default interface LocalAccount { - _id?: string, - baseURL: string, - domain: string, - clientId: string, - clientSecret: string, - accessToken: string | null, - refreshToken: string | null, - username: string | null, - accountId: number | null, - avatar: string | null, + _id?: string + baseURL: string + domain: string + clientId: string + clientSecret: string + accessToken: string | null + refreshToken: string | null + username: string | null + accountId: string | null + avatar: string | null order: number }