refactor: upgrade masto

This commit is contained in:
三咲智子 2023-01-10 14:10:20 +08:00
parent e1332345ad
commit caa02446c7
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
6 changed files with 34 additions and 25 deletions

View file

@ -67,11 +67,9 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
// Content Filter logic
const filterResult = $computed(() => status.filtered?.length ? status.filtered[0] : null)
const filter = $computed(() => filterResult?.filter as mastodon.v2.Filter)
const filter = $computed(() => filterResult?.filter)
// a bit of a hack due to Filter being different in v1 and v2
// clean up when masto.js supports explicit versions: https://github.com/neet/masto.js/issues/722
const filterPhrase = $computed(() => filter?.phrase || (filter as any)?.title)
const filterPhrase = $computed(() => filter?.title)
const isFiltered = $computed(() => filterPhrase && (props.context ? filter?.context.includes(props.context) : false))
const isSelfReply = $computed(() => status.inReplyToAccountId === status.account.id)

View file

@ -13,9 +13,7 @@ const isDetails = $computed(() => context === 'details')
const filterResult = $computed(() => status.filtered?.length ? status.filtered[0] : null)
const filter = $computed(() => filterResult?.filter)
// a bit of a hack due to Filter being different in v1 and v2
// clean up when masto.js supports explicit versions: https://github.com/neet/masto.js/issues/722
const filterPhrase = $computed(() => filter?.phrase || (filter as any)?.title)
const filterPhrase = $computed(() => filter?.title)
const isFiltered = $computed(() => filterPhrase && (context && context !== 'details' ? filter?.context.includes(context) : false))
</script>

View file

@ -1,5 +1,4 @@
import { Paginator } from 'masto'
import type { WsEvents, mastodon } from 'masto'
import type { Paginator, WsEvents, mastodon } from 'masto'
import type { PaginatorState } from '~/types'
export function usePaginator<T, P, U = T>(
@ -9,11 +8,10 @@ export function usePaginator<T, P, U = T>(
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
buffer = 10,
) {
// TODO: wait PR https://github.com/neet/masto.js/pull/801
// called `next` method will mutate the internal state of the variable, and we need its initial state after HMR
// called `next` method will mutate the internal state of the variable,
// and we need its initial state after HMR
// so clone it
// @ts-expect-error clone it
const paginator: Paginator<T[], P> = new Paginator(_paginator.http, _paginator.nextPath, _paginator.nextParams)
const paginator = _paginator.clone()
const state = ref<PaginatorState>(isMastoInitialised.value ? 'idle' : 'loading')
const items = ref<U[]>([])

View file

@ -267,7 +267,7 @@ export const useNotifications = () => {
return
const lastReadId = notifications[id]![1][0]
notifications[id]![1] = []
// @ts-expect-error https://github.com/neet/masto.js/pull/793
await masto.v1.markers.create({
notifications: { lastReadId },
})

View file

@ -52,7 +52,7 @@
"iso-639-1": "^2.1.15",
"js-yaml": "^4.1.0",
"lru-cache": "^7.14.1",
"masto": "^5.1.2",
"masto": "^5.2.0",
"pinia": "^2.0.28",
"shiki": "^0.12.1",
"shiki-es": "^0.1.2",

View file

@ -69,7 +69,7 @@ importers:
jsdom: ^20.0.3
lint-staged: ^13.1.0
lru-cache: ^7.14.1
masto: ^5.1.2
masto: ^5.2.0
nuxt: ^3.0.0
pinia: ^2.0.28
postcss-nested: ^6.0.0
@ -124,7 +124,7 @@ importers:
iso-639-1: 2.1.15
js-yaml: 4.1.0
lru-cache: 7.14.1
masto: 5.1.2
masto: 5.2.0
pinia: 2.0.28_typescript@4.9.4
shiki: 0.12.1
shiki-es: 0.1.2
@ -180,7 +180,7 @@ importers:
typescript: 4.9.4
unplugin-auto-import: 0.12.1_@vueuse+core@9.10.0
vite-plugin-inspect: 0.7.11
vite-plugin-pwa: 0.14.1
vite-plugin-pwa: 0.14.1_workbox-window@6.5.4
vitest: 0.26.2_jsdom@20.0.3
vue-tsc: 1.0.24_typescript@4.9.4
workbox-window: 6.5.4
@ -7483,12 +7483,12 @@ packages:
engines: {node: '>=6.0'}
dev: false
/isomorphic-ws/5.0.0_ws@8.11.0:
/isomorphic-ws/5.0.0_ws@8.12.0:
resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==}
peerDependencies:
ws: '*'
dependencies:
ws: 8.11.0
ws: 8.12.0
dev: false
/jake/10.8.5:
@ -7944,15 +7944,15 @@ packages:
resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==}
dev: true
/masto/5.1.2:
resolution: {integrity: sha512-nLhX0aHdb4ql4o2Afd81hm6dq/V6FZylEKed6VF099ZB0ZqkOZ54m+7yy1eSgPljmwrZbUgli5kXQ7nfloBkyg==}
/masto/5.2.0:
resolution: {integrity: sha512-71pKUdPZDuQSPJqRJSwsZ/QqvO/arOkdRyXEyOdeU9QukQ30OEW1M9BCGBp/b9Lbf6R7d9oCCdefmxXCSAzlFg==}
dependencies:
'@mastojs/ponyfills': 1.0.4
change-case: 4.1.2
eventemitter3: 5.0.0
isomorphic-ws: 5.0.0_ws@8.11.0
isomorphic-ws: 5.0.0_ws@8.12.0
semver: 7.3.8
ws: 8.11.0
ws: 8.12.0
transitivePeerDependencies:
- bufferutil
- encoding
@ -11822,10 +11822,11 @@ packages:
- supports-color
dev: true
/vite-plugin-pwa/0.14.1:
/vite-plugin-pwa/0.14.1_workbox-window@6.5.4:
resolution: {integrity: sha512-5zx7yhQ8RTLwV71+GA9YsQQ63ALKG8XXIMqRJDdZkR8ZYftFcRgnzM7wOWmQZ/DATspyhPih5wCdcZnAIsM+mA==}
peerDependencies:
vite: ^3.1.0 || ^4.0.0
workbox-window: ^6.5.4
dependencies:
'@rollup/plugin-replace': 5.0.1_rollup@3.9.1
debug: 4.3.4
@ -12472,6 +12473,20 @@ packages:
optional: true
utf-8-validate:
optional: true
dev: true
/ws/8.12.0:
resolution: {integrity: sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
dev: false
/ws/8.2.3:
resolution: {integrity: sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==}