diff --git a/package.json b/package.json index c20dd0b0..1705c890 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "electron-serve": "^1.1.0", "electron-store": "^8.1.0", "emoji-mart": "^5.5.2", - "megalodon": "9.2.3", + "megalodon": "10.0.0", "parse-link-header": "^2.0.0", "react-blurhash": "^0.3.0", "react-hotkeys-hook": "^4.4.1", diff --git a/renderer/components/timelines/Notifications.tsx b/renderer/components/timelines/Notifications.tsx index 680b6689..58311f83 100644 --- a/renderer/components/timelines/Notifications.tsx +++ b/renderer/components/timelines/Notifications.tsx @@ -1,5 +1,5 @@ import { Account } from '@/db' -import generator, { Entity, MegalodonInterface, WebSocketInterface } from 'megalodon' +import { Entity, MegalodonInterface, WebSocketInterface } from 'megalodon' import { useEffect, useState, useCallback, useRef } from 'react' import { FormattedMessage, useIntl } from 'react-intl' import { Virtuoso } from 'react-virtuoso' @@ -42,10 +42,8 @@ export default function Notifications(props: Props) { setFilters(f) const res = await loadNotifications(props.client) setNotifications(res) - const instance = await props.client.getInstance() - const c = generator(props.account.sns, instance.data.urls.streaming_api, props.account.access_token, 'Whalebird') updateMarker(props.client) - streaming.current = c.userSocket() + streaming.current = await props.client.userStreaming() streaming.current.on('connect', () => { console.log('connected to notifications') }) diff --git a/renderer/components/timelines/Timeline.tsx b/renderer/components/timelines/Timeline.tsx index 4f23c6b4..65a305b9 100644 --- a/renderer/components/timelines/Timeline.tsx +++ b/renderer/components/timelines/Timeline.tsx @@ -1,5 +1,5 @@ import { Account } from '@/db' -import generator, { Entity, MegalodonInterface, WebSocketInterface } from 'megalodon' +import { Entity, MegalodonInterface, WebSocketInterface } from 'megalodon' import { useEffect, useState, useCallback, useRef } from 'react' import { Virtuoso } from 'react-virtuoso' import Status from './status/Status' @@ -57,27 +57,25 @@ export default function Timeline(props: Props) { setFilters(f) const res = await loadTimeline(props.timeline, props.client) setStatuses(res) - const instance = await props.client.getInstance() - const c = generator(props.account.sns, instance.data.urls.streaming_api, props.account.access_token, 'Whalebird') setList(null) switch (props.timeline) { case 'home': { - streaming.current = c.userSocket() + streaming.current = await props.client.userStreaming() break } case 'local': { - streaming.current = c.localSocket() + streaming.current = await props.client.localStreaming() break } case 'public': { - streaming.current = c.publicSocket() + streaming.current = await props.client.publicStreaming() break } default: { const match = props.timeline.match(/list_(\d+)/) if (match && match[1] && typeof match[1] === 'string') { const res = await props.client.getList(match[1]) - streaming.current = c.listSocket(match[1]) + streaming.current = await props.client.listStreaming(match[1]) setList(res.data) } break diff --git a/renderer/provider/accounts.tsx b/renderer/provider/accounts.tsx index ced8d61f..1c1efb50 100644 --- a/renderer/provider/accounts.tsx +++ b/renderer/provider/accounts.tsx @@ -62,7 +62,6 @@ export const AccountsProvider: React.FC = ({ children }) => { if (!account.id) return // Start user streaming for notification const client = generator(account.sns, account.url, account.access_token, 'Whalebird') - const instance = await client.getInstance() const notifications = (await client.getNotifications()).data try { const res = await client.getMarkers(['notifications']) @@ -79,8 +78,7 @@ export const AccountsProvider: React.FC = ({ children }) => { console.error(err) } - const ws = generator(account.sns, instance.data.urls.streaming_api, account.access_token, 'Whalebird') - const socket = ws.userSocket() + const socket = await client.userStreaming() streamings.current = Object.assign({}, streamings.current, { [account.id]: socket }) diff --git a/yarn.lock b/yarn.lock index da9a1def..523cb363 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2711,7 +2711,7 @@ __metadata: eslint: ^8.55.0 eslint-config-prettier: ^9.0.0 eslint-plugin-react: ^7.33.2 - megalodon: 9.2.3 + megalodon: 10.0.0 next: ^12.3.4 nextron: ^8.12.0 parse-link-header: ^2.0.0 @@ -6501,9 +6501,9 @@ __metadata: languageName: node linkType: hard -"megalodon@npm:9.2.3": - version: 9.2.3 - resolution: "megalodon@npm:9.2.3" +"megalodon@npm:10.0.0": + version: 10.0.0 + resolution: "megalodon@npm:10.0.0" dependencies: "@badgateway/oauth2-client": ^2.3.0 "@types/ws": ^8.5.10 @@ -6515,7 +6515,7 @@ __metadata: object-assign-deep: ^0.4.0 uuid: ^9.0.1 ws: 8.16.0 - checksum: 19a861b3b58f7bbdb6126a8981353e6fe650a2e0b302f1fc832982e7e9648749132ecb6f162408bb2c35f2601363e4adad2964f55d3076a6ae149b47f810dbdf + checksum: 668ec90e2b24d037b58c223acc0590185882ad901481276e4d48856241dfdc09bd6b9d2eee18e5e1ece3d0e0be74e00a792cec3113a999242fb08782b77d684f languageName: node linkType: hard