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: bump to latest vue 3.4.19 #2607

Merged
merged 38 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6ced364
feat: bump to latest vue 3.4.19
userquin Feb 23, 2024
7b24fe0
chore: update account hover logic
userquin Feb 23, 2024
1b40f9c
chore: cleanup account hover
userquin Feb 23, 2024
e3f4707
chore: i18n wrapper
userquin Feb 23, 2024
e35b9e7
fix: generic wrapper for i18n
patak-dev Feb 23, 2024
c36655c
chore: add `d` and `n` to i18n wrapper
userquin Feb 23, 2024
380b2f0
chore: revert vscode settings
userquin Feb 23, 2024
605b0d7
fix: hydration missmatch in elk nav title link
userquin Feb 23, 2024
1b206f8
chore: revert isHydrated
userquin Feb 23, 2024
d49685f
chore: revert isHydrated
userquin Feb 23, 2024
be1b161
chore: fix filter text
userquin Feb 23, 2024
1ca7801
chore: revert isHydrated
userquin Feb 23, 2024
5443c4d
chore: revert isHydrated
userquin Feb 23, 2024
dd1243e
chore: revert isHydrated
userquin Feb 23, 2024
4fc72c3
chore: revert isHydrated
userquin Feb 23, 2024
4bd6998
chore: revert isHydrated
userquin Feb 23, 2024
a9a5c69
chore: revert isHydrated
userquin Feb 23, 2024
f8d799c
chore: revert isHydrated
userquin Feb 23, 2024
c466784
chore: revert isHydrated
userquin Feb 23, 2024
9a147d5
chore: revert isHydrated
userquin Feb 23, 2024
559bd58
chore: revert isHydrated
userquin Feb 23, 2024
e2eb772
chore: revert isHydrated
userquin Feb 23, 2024
b73bcb6
chore: revert isHydrated
userquin Feb 23, 2024
191d510
chore: revert isHydrated
userquin Feb 23, 2024
3ae30ef
chore: revert isHydrated
userquin Feb 23, 2024
5bf61ae
chore: revert isHydrated
userquin Feb 23, 2024
5c71e8f
chore: revert isHydrated
userquin Feb 23, 2024
790e739
chore: update i18n wrapper logic
userquin Feb 23, 2024
20be874
chore: revert isHydrated
userquin Feb 23, 2024
b29d202
chore: revert isHydrated
userquin Feb 23, 2024
2559198
chore: revert v-if and use v-show
userquin Feb 23, 2024
35bd896
chore: use setup i18n plugin for client and server
userquin Feb 23, 2024
e73d417
chore: revert shallow ref
userquin Feb 23, 2024
b52ec18
chore: remove isHydrated from tabs
userquin Feb 23, 2024
2c37b14
chore: use `$t` in public/index.vue page
userquin Feb 23, 2024
6f81091
chore: use `$t` in public/index.vue page
userquin Feb 23, 2024
5794a19
chore: change div wrapper with span and use newHandle to change account
userquin Feb 24, 2024
3e606f6
chore: remove isHydrated from notifications page
userquin Feb 24, 2024
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
57 changes: 49 additions & 8 deletions components/account/AccountHoverWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { fetchAccountByHandle } from '~/composables/cache'

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

defineOptions({
inheritAttrs: false,
Expand All @@ -11,16 +14,54 @@ const props = defineProps<{
disabled?: boolean
}>()

const account = computed(() => props.account || (props.handle ? useAccountByHandle(props.handle!) : undefined))
const hoverCard = ref()
const targetIsVisible = ref(false)
const account = ref<mastodon.v1.Account | null | undefined>(props.account)

useIntersectionObserver(
hoverCard,
([{ intersectionRatio }]) => {
targetIsVisible.value = intersectionRatio <= 0.75
},
)
watch(
() => [props.account, props.handle, targetIsVisible.value] satisfies WatcherType,
([newAccount, newHandle, newVisible], oldProps) => {
if (newAccount) {
account.value = newAccount
return
}

if (!newVisible)
return

if (newHandle) {
const [_oldAccount, oldHandle, _oldVisible] = oldProps ?? [undefined, undefined, false]
if (!oldHandle || newHandle !== oldHandle || !account.value) {
fetchAccountByHandle(newHandle).then((acc) => {
if (acc.acct === props.handle)
account.value = acc
})
}

return
}

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

const userSettings = useUserSettings()
</script>

<template>
<VMenu v-if="!disabled && account && !getPreferences(userSettings, 'hideAccountHoverCard')" placement="bottom-start" :delay="{ show: 500, hide: 100 }" v-bind="$attrs" :close-on-content-click="false">
<slot />
<template #popper>
<AccountHoverCard v-if="account" :account="account" />
</template>
</VMenu>
<slot v-else />
<div ref="hoverCard">
<VMenu v-if="!disabled && account && !getPreferences(userSettings, 'hideAccountHoverCard')" placement="bottom-start" :delay="{ show: 500, hide: 100 }" v-bind="$attrs" :close-on-content-click="false">
<slot />
<template #popper>
<AccountHoverCard v-if="account" :account="account" />
</template>
</VMenu>
<slot v-else />
</div>
</template>
6 changes: 3 additions & 3 deletions components/account/AccountTabs.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
import type { CommonRouteTabOption } from '../common/CommonRouteTabs.vue'
import type { CommonRouteTabOption } from '~/types'

const { t } = useI18n()
const route = useRoute()

const server = computedEager(() => route.params.server as string)
const account = computedEager(() => route.params.account as string)
const server = computed(() => route.params.server as string)
const account = computed(() => route.params.account as string)

const tabs = computed<CommonRouteTabOption[]>(() => [
{
Expand Down
4 changes: 2 additions & 2 deletions components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ defineExpose({ createEntry, removeEntry, updateEntry })
</template>
<template v-else>
<slot
v-for="item, index of items"
v-bind="{ key: item[keyProp as keyof U] }"
v-for="(item, index) of items"
v-bind="{ key: (item as U)[keyProp as keyof U] }"
:item="item as U"
:older="items[index + 1] as U"
:newer="items[index - 1] as U"
Expand Down
20 changes: 2 additions & 18 deletions components/common/CommonRouteTabs.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { RouteLocationRaw } from 'vue-router'
import type { CommonRouteTabMoreOption, CommonRouteTabOption } from '~/types'

const { options, command, replace, preventScrollTop = false, moreOptions } = defineProps<{
options: CommonRouteTabOption[]
Expand All @@ -10,22 +10,6 @@ const { options, command, replace, preventScrollTop = false, moreOptions } = def
}>()

const { t } = useI18n()

export interface CommonRouteTabOption {
to: RouteLocationRaw
display: string
disabled?: boolean
name?: string
icon?: string
hide?: boolean
match?: boolean
}
export interface CommonRouteTabMoreOption {
options: CommonRouteTabOption[]
icon?: string
tooltip?: string
match?: boolean
}
const router = useRouter()

useCommands(() => command
Expand Down Expand Up @@ -60,7 +44,7 @@ useCommands(() => command
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center text-secondary-light op50>{{ option.display }}</span>
</div>
</template>
<template v-if="moreOptions?.options?.length">
<template v-if="isHydrated && moreOptions?.options?.length">
<CommonDropdown placement="bottom" flex cursor-pointer mx-1.25rem>
<CommonTooltip placement="top" :content="moreOptions.tooltip || t('action.more')">
<button
Expand Down
1 change: 1 addition & 0 deletions components/common/CommonTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defineProps<Props>()

<template>
<VTooltip
v-if="isHydrated"
v-bind="$attrs"
auto-hide
>
Expand Down
4 changes: 2 additions & 2 deletions components/magickeys/MagickeysKeyboardShortcuts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ShortcutItemGroup {
const isMac = useIsMac()
const modifierKeyName = computed(() => isMac.value ? '⌘' : 'Ctrl')

const shortcutItemGroups: ShortcutItemGroup[] = [
const shortcutItemGroups = computed<ShortcutItemGroup[]>(() => [
{
name: t('magic_keys.groups.navigation.title'),
items: [
Expand Down Expand Up @@ -79,7 +79,7 @@ const shortcutItemGroups: ShortcutItemGroup[] = [
name: t('magic_keys.groups.media.title'),
items: [],
},
]
])
</script>

<template>
Expand Down
4 changes: 0 additions & 4 deletions composables/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ export async function fetchAccountByHandle(acct: string): Promise<mastodon.v1.Ac
return account
}

export function useAccountByHandle(acct: string) {
return useAsyncState(() => fetchAccountByHandle(acct), null).state
}

export function useAccountById(id?: string | null) {
return useAsyncState(() => fetchAccountById(id), null).state
}
Expand Down
2 changes: 1 addition & 1 deletion composables/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function usePaginator<T, P, U = T>(
// so clone it
const paginator = _paginator.clone()

const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
const state = shallowRef<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
userquin marked this conversation as resolved.
Show resolved Hide resolved
const items = ref<U[]>([])
const nextItems = ref<U[]>([])
const prevItems = ref<T[]>([])
Expand Down
24 changes: 12 additions & 12 deletions composables/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,20 +362,20 @@ export function useUserLocalStorage<T extends object>(key: string, initial: () =
// Backward compatibility, respect webDomain in acct
// In previous versions, acct was username@server instead of username@webDomain
// for example: [email protected] instead of [email protected]
// if (!all.value[id]) { // TODO: add back this condition in the future
const [username, webDomain] = id.split('@')
const server = currentServer.value
if (webDomain && server && server !== webDomain) {
const oldId = `${username}@${server}`
const outdatedSettings = all.value[oldId]
if (outdatedSettings) {
const newAllValue = { ...all.value, [id]: outdatedSettings }
delete newAllValue[oldId]
all.value = newAllValue
if (!all.value[id]) {
const [username, webDomain] = id.split('@')
const server = currentServer.value
if (webDomain && server && server !== webDomain) {
const oldId = `${username}@${server}`
const outdatedSettings = all.value[oldId]
if (outdatedSettings) {
const newAllValue = { ...all.value, [id]: outdatedSettings }
delete newAllValue[oldId]
all.value = newAllValue
}
}
all.value[id] = Object.assign(initial(), all.value[id] || {})
}
// }
all.value[id] = Object.assign(initial(), all.value[id] || {})
return all.value[id]
})
})
Expand Down
21 changes: 20 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineNuxtConfig({
tsConfig: {
exclude: ['../service-worker'],
vueCompilerOptions: {
target: 3.3,
target: 3.4,
},
},
},
Expand Down Expand Up @@ -75,6 +75,11 @@ export default defineNuxtConfig({
'./composables/settings',
'./composables/tiptap/index.ts',
],
imports: [{
name: 'useI18n',
from: '~/utils/i18n',
priority: 100,
}],
injectAtEnd: true,
},
vite: {
Expand All @@ -86,6 +91,20 @@ export default defineNuxtConfig({
build: {
target: 'esnext',
},
optimizeDeps: {
include: [
'@tiptap/vue-3', 'string-length', 'vue-virtual-scroller', 'emoji-mart', 'iso-639-1',
'@tiptap/extension-placeholder', '@tiptap/extension-document', '@tiptap/extension-paragraph',
'@tiptap/extension-text', '@tiptap/extension-mention', '@tiptap/extension-hard-break',
'@tiptap/extension-bold', '@tiptap/extension-italic', '@tiptap/extension-code',
'@tiptap/extension-history', 'prosemirror-state', 'browser-fs-access', 'blurhash',
'@vueuse/integrations/useFocusTrap', '@tiptap/extension-code-block', 'prosemirror-highlight',
'@tiptap/core', 'tippy.js', 'prosemirror-highlight/shiki', '@fnando/sparkline',
'@vueuse/gesture', 'github-reserved-names', 'file-saver', 'slimeform', 'vue-advanced-cropper',
'workbox-window', 'workbox-precaching', 'workbox-routing', 'workbox-cacheable-response',
'workbox-strategies', 'workbox-expiration',
],
},
Comment on lines +94 to +107
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably remove the ones that would be detected by the scanner, but I think it is ok for now to include all of these 👍🏼

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some dependencies only detected when matching the case: for example, github-reserved-names and file-saver when visiting the settings > users and about pages

When visiting a new page and found a new entry in the console I just add them to the list.

imagen

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect 👍🏼

},
postcss: {
plugins: {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
"[email protected]": "patches/[email protected]"
}
},
"resolutions": {
"vue": "^3.4.19"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
Expand Down
4 changes: 2 additions & 2 deletions pages/[[server]]/@[account]/[status].vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ definePageMeta({
})

const route = useRoute()
const id = computedEager(() => route.params.status as string)
const id = computed(() => route.params.status as string)
const main = ref<ComponentPublicInstance | null>(null)

const { data: status, pending, refresh: refreshStatus } = useAsyncData(
Expand Down Expand Up @@ -71,7 +71,7 @@ onReactivated(() => {
<div xl:mt-4 mb="50vh" border="b base">
<template v-if="!pendingContext">
<StatusCard
v-for="comment, i of context?.ancestors" :key="comment.id"
v-for="(comment, i) of context?.ancestors" :key="comment.id"
:status="comment" :actions="comment.visibility !== 'direct'" context="account"
:has-older="true" :newer="context?.ancestors[i - 1]"
/>
Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ definePageMeta({
})

const params = useRoute().params
const accountName = computedEager(() => toShortHandle(params.account as string))
const accountName = computed(() => toShortHandle(params.account as string))

const { t } = useI18n()

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/index/followers.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
const { t } = useI18n()
const params = useRoute().params
const handle = computedEager(() => params.account as string)
const handle = computed(() => params.account as string)

definePageMeta({ name: 'account-followers' })

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/index/following.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
const { t } = useI18n()
const params = useRoute().params
const handle = computedEager(() => params.account as string)
const handle = computed(() => params.account as string)

definePageMeta({ name: 'account-following' })

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { mastodon } from 'masto'

const params = useRoute().params
const handle = computedEager(() => params.account as string)
const handle = computed(() => params.account as string)

definePageMeta({ name: 'account-index' })

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/index/media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ definePageMeta({ name: 'account-media' })

const { t } = useI18n()
const params = useRoute().params
const handle = computedEager(() => params.account as string)
const handle = computed(() => params.account as string)

const account = await fetchAccountByHandle(handle.value)

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/index/with_replies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ definePageMeta({ name: 'account-replies' })

const { t } = useI18n()
const params = useRoute().params
const handle = computedEager(() => params.account as string)
const handle = computed(() => params.account as string)

const account = await fetchAccountByHandle(handle.value)

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/explore.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { CommonRouteTabOption } from '~/components/common/CommonRouteTabs.vue'
import type { CommonRouteTabOption } from '~/types'

const { t } = useI18n()

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/explore/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ useHydratedHead({
<p>{{ $t('tooltip.explore_posts_intro') }}</p>
</CommonAlert>
<!-- TODO: Tabs for trending statuses, tags, and links -->
<TimelinePaginator :paginator="paginator" context="public" />
<TimelinePaginator v-if="isHydrated" :paginator="paginator" context="public" />
</template>
6 changes: 3 additions & 3 deletions pages/[[server]]/list/[list]/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { CommonRouteTabOption } from '~/components/common/CommonRouteTabs.vue'
import type { CommonRouteTabOption } from '~/types'

definePageMeta({
middleware: 'auth',
Expand All @@ -17,15 +17,15 @@ const tabs = computed<CommonRouteTabOption[]>(() => [
name: 'list',
params: { server: server.value, list: list.value },
},
display: t('tab.posts'),
display: isHydrated.value ? t('tab.posts') : '',
userquin marked this conversation as resolved.
Show resolved Hide resolved
icon: 'i-ri:list-unordered',
},
{
to: {
name: 'list-accounts',
params: { server: server.value, list: list.value },
},
display: t('tab.accounts'),
display: isHydrated.value ? t('tab.accounts') : '',
icon: 'i-ri:user-line',
},
],
Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/list/[list]/index/accounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ definePageMeta({
})

const params = useRoute().params
const listId = computedEager(() => params.list as string)
const listId = computed(() => params.list as string)

const paginator = useMastoClient().v1.lists.$select(listId.value).accounts.list()
</script>
Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/list/[list]/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ definePageMeta({
})

const params = useRoute().params
const listId = computedEager(() => params.list as string)
const listId = computed(() => params.list as string)

const client = useMastoClient()

Expand Down
Loading
Loading