Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate bluesky api #18

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/account/AccountAvatar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
square?: boolean
}>()

Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountBigAvatar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

// Avatar with a background base achieving a 3px border to be used in status cards
// The border is used for Avatar on Avatar for reblogs and connecting replies

defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
square?: boolean
}>()
</script>
Expand Down
6 changes: 3 additions & 3 deletions components/account/AccountDisplayName.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

const { account, hideEmojis = false } = defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
hideEmojis?: boolean
}>()
</script>

<template>
<ContentRich
:content="getDisplayName(account, { rich: true })"
:content="getDisplayName(account)"
:emojis="account.emojis"
:hide-emojis="hideEmojis"
:markdown="false"
Expand Down
2 changes: 1 addition & 1 deletion components/account/AccountFollowButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleFollowAccount, useRelationship } from '~~/composables/masto/relationship'
import { toggleFollowAccount, useRelationship } from '~~/composables/bsky/relationship'

const { account, command, context, ...props } = defineProps<{
account: mastodon.v1.Account
Expand Down
4 changes: 2 additions & 2 deletions components/account/AccountHandle.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

const { account } = defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
}>()

const serverName = computed(() => getServerName(account))
Expand Down
28 changes: 14 additions & 14 deletions components/account/AccountHoverCard.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

const { account } = defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
}>()

const relationship = useRelationship(account)
// const relationship = useRelationship(account)
</script>

<template>
<div v-show="relationship" flex="~ col gap2" rounded min-w-90 max-w-120 z-100 overflow-hidden p-4>
<div flex="~ gap2" items-center>
<NuxtLink :to="getAccountRoute(account)" flex-auto rounded-full hover:bg-active transition-100 pe5 me-a>
<AccountInfo :account="account" :hover-card="true" />
</NuxtLink>
<AccountFollowButton text-sm :account="account" :relationship="relationship" />
</div>
<div v-if="account.note" max-h-100 overflow-y-auto>
<ContentRich text-4 text-secondary :content="account.note" :emojis="account.emojis" />
</div>
<AccountPostsFollowers text-sm :account="account" :is-hover-card="true" />
<!-- <div v-show="relationship" flex="~ col gap2" rounded min-w-90 max-w-120 z-100 overflow-hidden p-4> -->
<div flex="~ gap2" items-center>
<NuxtLink :to="getAccountRoute(account)" flex-auto rounded-full hover:bg-active transition-100 pe5 me-a>
<AccountInfo :account="account" :hover-card="true" />
</NuxtLink>
<!-- <AccountFollowButton text-sm :account="account" :relationship="relationship" /> -->
</div>
<div v-if="account.note" max-h-100 overflow-y-auto>
<ContentRich text-4 text-secondary :content="account.note" :emojis="account.emojis" />
</div>
<!-- <AccountPostsFollowers text-sm :account="account" :is-hover-card="true" /> -->
<!-- </div> -->
</template>
55 changes: 28 additions & 27 deletions components/account/AccountHoverWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
<script setup lang="ts">
import type { AppBskyActorDefs } from '@atproto/api'
import type { mastodon } from 'masto'

Check failure on line 3 in components/account/AccountHoverWrapper.vue

View workflow job for this annotation

GitHub Actions / ci

'mastodon' is defined but never used
import { fetchAccountByHandle } from '~/composables/cache'

Check failure on line 4 in components/account/AccountHoverWrapper.vue

View workflow job for this annotation

GitHub Actions / ci

'fetchAccountByHandle' is defined but never used

type WatcherType = [acc?: mastodon.v1.Account | null, h?: string, v?: boolean]
type WatcherType = [acc?: AppBskyActorDefs.ProfileView | null, h?: string, v?: boolean]

Check failure on line 6 in components/account/AccountHoverWrapper.vue

View workflow job for this annotation

GitHub Actions / ci

'WatcherType' is defined but never used. Allowed unused vars must match /^_/u

defineOptions({
inheritAttrs: false,
})

const props = defineProps<{
account?: mastodon.v1.Account | null
account?: AppBskyActorDefs.ProfileView | null
handle?: string
disabled?: boolean
}>()

const accountHover = ref()
const hovered = useElementHover(accountHover)

Check failure on line 19 in components/account/AccountHoverWrapper.vue

View workflow job for this annotation

GitHub Actions / ci

'hovered' is assigned a value but never used. Allowed unused vars must match /^_/u
const account = ref<mastodon.v1.Account | null | undefined>(props.account)
const account = ref<AppBskyActorDefs.ProfileView | null | undefined>(props.account)

watch(
() => [props.account, props.handle, hovered.value] satisfies WatcherType,
([newAccount, newHandle, newVisible], oldProps) => {
if (!newVisible || process.test)
return
// watch(
// () => [props.account, props.handle, hovered.value] satisfies WatcherType,
// ([newAccount, newHandle, newVisible], oldProps) => {
// if (!newVisible || process.test)
// return

if (newAccount) {
account.value = newAccount
return
}
// if (newAccount) {
// account.value = newAccount
// return
// }

if (newHandle) {
const [_oldAccount, oldHandle, _oldVisible] = oldProps ?? [undefined, undefined, false]
if (!oldHandle || newHandle !== oldHandle || !account.value) {
// new handle can be wrong: using server instead of webDomain
fetchAccountByHandle(newHandle).then((acc) => {
if (newHandle === props.handle)
account.value = acc
})
}
// if (newHandle) {
// const [_oldAccount, oldHandle, _oldVisible] = oldProps ?? [undefined, undefined, false]
// if (!oldHandle || newHandle !== oldHandle || !account.value) {
// // new handle can be wrong: using server instead of webDomain
// fetchAccountByHandle(newHandle).then((acc) => {
// if (newHandle === props.handle)
// account.value = acc
// })
// }

return
}
// return
// }

account.value = undefined
},
{ immediate: true, flush: 'post' },
)
// account.value = undefined
// },
// { immediate: true, flush: 'post' },
// )

const userSettings = useUserSettings()
</script>
Expand Down
6 changes: 3 additions & 3 deletions components/account/AccountInfo.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

defineOptions({
inheritAttrs: false,
})

const { account, as = 'div' } = defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
as?: string
hoverCard?: boolean
square?: boolean
Expand All @@ -28,7 +28,7 @@ const { account, as = 'div' } = defineProps<{
</div>
<AccountHandle :account="account" text-secondary-light />
<div self-start mt-1>
<AccountRolesIndicator v-if="account.roles?.length" :account="account" :limit="1" />
<!-- <AccountRolesIndicator v-if="account.roles?.length" :account="account" :limit="1" /> -->
</div>
</div>
</component>
Expand Down
2 changes: 1 addition & 1 deletion components/account/AccountMoreButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleBlockAccount, toggleBlockDomain, toggleMuteAccount } from '~~/composables/masto/relationship'
import { toggleBlockAccount, toggleBlockDomain, toggleMuteAccount } from '~~/composables/bsky/relationship'

const { account } = defineProps<{
account: mastodon.v1.Account
Expand Down
6 changes: 3 additions & 3 deletions components/account/AccountPostsFollowers.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
isHoverCard?: boolean
}>()

Expand All @@ -20,7 +20,7 @@ const userSettings = useUserSettings()
<template #default="{ isExactActive }">
<CommonLocalizedNumber
keypath="account.posts_count"
:count="account.statusesCount"
:count="0"
font-bold
:class="isExactActive ? 'text-primary' : 'text-base'"
/>
Expand Down
6 changes: 2 additions & 4 deletions components/command/CommandPanel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<script setup lang="ts">
import type { SearchResult as SearchResultType } from '/composables/bsky/searcbsky/serch'
import type { CommandScope, QueryResult, QueryResultItem } from '~/composables/command'
import type { SearchResult as SearchResultType } from '~/composables/masto/search'

const emit = defineEmits<{
(event: 'close'): void
}>()
const emit = defineEmits<(event: 'close') => void>()

const registry = useCommandRegistry()

Expand Down
27 changes: 8 additions & 19 deletions components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts" generic="T, O, U = T">
import type { AppBskyFeedGetFeed } from '@atproto/api'
import type { mastodon } from 'masto'
// @ts-expect-error missing types
import { DynamicScroller } from 'vue-virtual-scroller'
Expand All @@ -6,14 +7,14 @@

const {
paginator,
stream,

Check failure on line 10 in components/common/CommonPaginator.vue

View workflow job for this annotation

GitHub Actions / ci

'stream' is assigned a value but never used. Allowed unused vars must match /^_/u
eventType,

Check failure on line 11 in components/common/CommonPaginator.vue

View workflow job for this annotation

GitHub Actions / ci

'eventType' is assigned a value but never used. Allowed unused vars must match /^_/u
keyProp = 'id',
keyProp = 'uri',
virtualScroller = false,
preprocess,
endMessage = true,

Check failure on line 15 in components/common/CommonPaginator.vue

View workflow job for this annotation

GitHub Actions / ci

'endMessage' is assigned a value but never used. Allowed unused vars must match /^_/u
} = defineProps<{
paginator: mastodon.Paginator<T[], O>
paginator: AppBskyFeedGetFeed.OutputSchema
keyProp?: keyof T
virtualScroller?: boolean
stream?: mastodon.streaming.Subscription
Expand Down Expand Up @@ -42,13 +43,14 @@
done: (props: { items: U[] }) => void
}>()

const { t } = useI18n()
// const { t } = useI18n()
const nuxtApp = useNuxtApp()

const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, toRef(() => stream), eventType, preprocess)
// const { items, prevItems, update, state, endAnchor, error } = usePaginator(paginator, toRef(() => stream), eventType, preprocess)
const items = ref(paginator.feed.map(item => item.post))

nuxtApp.hook('nimbus-logo:click', () => {
update()
// update()
nuxtApp.$scrollToTop()
})

Expand All @@ -72,13 +74,12 @@

<template>
<div>
<slot v-if="prevItems.length" name="updater" v-bind="{ number: prevItems.length, update }" />
<slot name="items" :items="items as U[]">
<template v-if="virtualScroller">
<DynamicScroller
v-slot="{ item, active, index }"
:items="items"
:min-item-size="200"
:min-item-size="30"
:key-field="keyProp"
page-mode
>
Expand All @@ -105,17 +106,5 @@
/>
</template>
</slot>
<div ref="endAnchor" />
<slot v-if="state === 'loading'" name="loading">
<TimelineSkeleton />
</slot>
<slot v-else-if="state === 'done' && endMessage !== false" name="done" :items="items as U[]">
<div p5 text-secondary italic text-center>
{{ t(typeof endMessage === 'string' && items.length <= 0 ? endMessage : 'common.end_of_list') }}
</div>
</slot>
<div v-else-if="state === 'error'" p5 text-secondary>
{{ t('common.error') }}: {{ error }}
</div>
</div>
</template>
6 changes: 2 additions & 4 deletions components/report/ReportModal.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleBlockAccount, toggleFollowAccount, toggleMuteAccount, useRelationship } from '~~/composables/masto/relationship'
import { toggleBlockAccount, toggleFollowAccount, toggleMuteAccount, useRelationship } from '~~/composables/bsky/relationship'

const { account, status } = defineProps<{
account: mastodon.v1.Account
status?: mastodon.v1.Status
}>()

const emit = defineEmits<{
(event: 'close'): void
}>()
const emit = defineEmits<(event: 'close') => void>()

const { client } = useMasto()

Expand Down
2 changes: 1 addition & 1 deletion components/search/SearchResult.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { SearchResult } from '~/composables/masto/search'
import type { SearchResult } from '~/composables/bsky/search'

defineProps<{
result: SearchResult
Expand Down
4 changes: 2 additions & 2 deletions components/status/StatusAccountDetails.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { AppBskyActorDefs } from '@atproto/api'

const { account, link = true } = defineProps<{
account: mastodon.v1.Account
account: AppBskyActorDefs.ProfileView
link?: boolean
}>()

Expand Down
Loading
Loading