Skip to content

Commit

Permalink
Merge branch 'elk-zone:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mastoduy committed Oct 28, 2023
2 parents 05c5a5d + 5d09e7d commit 10f6090
Show file tree
Hide file tree
Showing 27 changed files with 3,016 additions and 2,886 deletions.
8 changes: 5 additions & 3 deletions components/account/AccountCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ cacheAccount(account)
overflow-hidden
:to="getAccountRoute(account)"
/>
<div h-full p1 shrink-0>
<AccountFollowButton :account="account" :context="relationshipContext" />
</div>
<slot>
<div h-full p1 shrink-0>
<AccountFollowButton :account="account" :context="relationshipContext" />
</div>
</slot>
</div>
</template>
68 changes: 68 additions & 0 deletions components/account/AccountFollowRequestButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
const { account, ...props } = defineProps<{
account: mastodon.v1.Account
relationship?: mastodon.v1.Relationship
}>()
const relationship = $computed(() => props.relationship || useRelationship(account).value)
const { client } = $(useMasto())
async function authorizeFollowRequest() {
relationship!.requestedBy = false
relationship!.followedBy = true
try {
const newRel = await client.v1.followRequests.authorize(account.id)
Object.assign(relationship!, newRel)
}
catch (err) {
console.error(err)
relationship!.requestedBy = true
relationship!.followedBy = false
}
}
async function rejectFollowRequest() {
relationship!.requestedBy = false
try {
const newRel = await client.v1.followRequests.reject(account.id)
Object.assign(relationship!, newRel)
}
catch (err) {
console.error(err)
relationship!.requestedBy = true
}
}
</script>

<template>
<div flex gap-4>
<template v-if="relationship?.requestedBy">
<CommonTooltip :content="$t('account.authorize')" no-auto-focus>
<button
type="button"
rounded-full text-sm p2 border-1
hover:text-green transition-colors
@click="authorizeFollowRequest"
>
<span block text-current i-ri:check-fill />
</button>
</CommonTooltip>
<CommonTooltip :content="$t('account.reject')" no-auto-focus>
<button
type="button"
rounded-full text-sm p2 border-1
hover:text-red transition-colors
@click="rejectFollowRequest"
>
<span block text-current i-ri:close-fill />
</button>
</CommonTooltip>
</template>
<template v-else>
<span text-secondary>
{{ relationship?.followedBy ? $t('account.authorized') : $t('account.rejected') }}
</span>
</template>
</div>
</template>
6 changes: 5 additions & 1 deletion components/account/AccountHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ const personalNoteMaxLength = 2000

<template>
<div flex flex-col>
<div v-if="relationship?.requestedBy" p-4 flex justify-between items-center bg-card>
<span text-primary font-bold>{{ $t('account.requested', [account.displayName]) }}</span>
<AccountFollowRequestButton :account="account" :relationship="relationship" />
</div>
<component :is="hasHeader ? 'button' : 'div'" border="b base" z-1 @click="hasHeader ? previewHeader() : undefined">
<img h-50 height="200" w-full object-cover :src="account.header" :alt="t('account.profile_description', [account.username])">
</component>
<div p4 mt--18 flex flex-col gap-4>
<div relative>
<div flex justify-between>
<button shrink-0 :class="{ 'rounded-full': !isSelf, 'squircle': isSelf }" p1 bg-base border-bg-base z-2 @click="previewAvatar">
<button shrink-0 h-full :class="{ 'rounded-full': !isSelf, 'squircle': isSelf }" p1 bg-base border-bg-base z-2 @click="previewAvatar">
<AccountAvatar :square="isSelf" :account="account" hover:opacity-90 transition-opacity w-28 h-28 />
</button>
<div inset-ie-0 flex="~ wrap row-reverse" gap-2 items-center pt18 justify-start>
Expand Down
2 changes: 1 addition & 1 deletion components/common/CommonPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ defineExpose({ createEntry, removeEntry, updateEntry })
</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' ? endMessage : 'common.end_of_list') }}
{{ t(typeof endMessage === 'string' && items.length <= 0 ? endMessage : 'common.end_of_list') }}
</div>
</slot>
<div v-else-if="state === 'error'" p5 text-secondary>
Expand Down
4 changes: 4 additions & 0 deletions components/magickeys/MagickeysKeyboardShortcuts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const shortcutItemGroups: ShortcutItemGroup[] = [
{
name: t('magic_keys.groups.actions.title'),
items: [
{
description: t('magic_keys.groups.actions.search'),
shortcut: { keys: [modifierKeyName, 'k'], isSequence: false },
},
{
description: t('magic_keys.groups.actions.command_mode'),
shortcut: { keys: [modifierKeyName, '/'], isSequence: false },
Expand Down
35 changes: 22 additions & 13 deletions components/notification/NotificationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ const { notification } = defineProps<{
</NuxtLink>
</template>
<template v-else-if="notification.type === 'admin.sign_up'">
<div flex p4 items-center bg-shaded>
<div i-ri:user-add-line text-xl me-2 color-purple />
<AccountDisplayName
:account="notification.account"
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
<span>{{ $t("notification.signed_up") }}</span>
</div>
<NuxtLink :to="getAccountRoute(notification.account)">
<div flex p4 items-center bg-shaded>
<div i-ri:user-add-line text-xl me-2 color-purple />
<AccountDisplayName
:account="notification.account"
text-purple me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
<span>{{ $t("notification.signed_up") }}</span>
</div>
</NuxtLink>
</template>
<template v-else-if="notification.type === 'admin.report'">
<NuxtLink :to="getReportRoute(notification.report?.id!)">
Expand All @@ -58,12 +60,19 @@ const { notification } = defineProps<{
</NuxtLink>
</template>
<template v-else-if="notification.type === 'follow_request'">
<div flex ms-4 items-center class="-top-2.5" absolute inset-ie-2 px-2>
<div i-ri:user-shared-fill text-xl me-1 />
<AccountInlineInfo :account="notification.account" me1 />
<div flex px-3 py-2>
<div i-ri-user-shared-line text-xl me-3 color-blue />
<AccountDisplayName
:account="notification.account"
text-primary me-1 font-bold line-clamp-1 ws-pre-wrap break-all
/>
<span me-1 ws-nowrap>
{{ $t('notification.request_to_follow') }}
</span>
</div>
<!-- TODO: accept request -->
<AccountCard :account="notification.account" />
<AccountCard p="s-2 e-4 b-2" hover-card :account="notification.account">
<AccountFollowRequestButton :account="notification.account" />
</AccountCard>
</template>
<template v-else-if="notification.type === 'update'">
<StatusCard :status="notification.status!" :in-notification="true" :actions="false">
Expand Down
14 changes: 12 additions & 2 deletions components/notification/NotificationPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ const virtualScroller = false // TODO: fix flickering issue with virtual scroll
const groupCapacity = Number.MAX_VALUE // No limit
const includeNotificationTypes: mastodon.v1.NotificationType[] = ['update', 'mention', 'poll', 'status']
function includeNotificationsForStatusCard({ type, status }: mastodon.v1.Notification) {
// Exclude update, mention, pool and status notifications without the status entry:
// no makes sense to include them
// Those notifications will be shown using StatusCard SFC:
// check NotificationCard SFC L68 and L81 => :status="notification.status!"
return status || !includeNotificationTypes.includes(type)
}
// Group by type (and status when applicable)
function groupId(item: mastodon.v1.Notification): string {
// If the update is related to an status, group notifications from the same account (boost + favorite the same status)
Expand Down Expand Up @@ -108,9 +118,9 @@ function groupItems(items: mastodon.v1.Notification[]): NotificationSlot[] {
results.push(...group)
}
for (const item of items) {
for (const item of items.filter(includeNotificationsForStatusCard)) {
const itemId = groupId(item)
// Finalize group if it already has too many notifications
// Finalize the group if it already has too many notifications
if (currentGroupId !== itemId || currentGroup.length >= groupCapacity)
processGroup()
Expand Down
2 changes: 1 addition & 1 deletion components/publish/PublishWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ onDeactivated(() => {
<EditorContent
:editor="editor"
flex max-w-full
:class="shouldExpanded ? 'min-h-30 max-h-[calc(100vh-400px)] xl:max-h-35 of-y-auto overscroll-contain' : ''"
:class="shouldExpanded ? 'min-h-30 md:max-h-[calc(100vh-200px)] sm:max-h-[calc(100vh-400px)] max-h-35 of-y-auto overscroll-contain' : ''"
@keydown="stopQuestionMarkPropagation"
/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions composables/content-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ function filterHref() {
if (href.startsWith('/') || href.startsWith('.'))
return href

href = href.replace(/&amp;/g, '&')

let url
try {
url = new URL(href)
Expand Down
7 changes: 6 additions & 1 deletion composables/masto/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export async function translateText(text: string, from: string | null | undefine
error: '',
text: '',
})
const regex = /<a[^>]*>.*?<\/a>/g
try {
const response = await ($fetch as any)(config.public.translateApi, {
method: 'POST',
Expand All @@ -77,7 +78,11 @@ export async function translateText(text: string, from: string | null | undefine
},
}) as TranslationResponse
status.success = true
status.text = response.translatedText
// replace the translated links with the original
status.text = response.translatedText.replace(regex, (match) => {
const tagLink = regex.exec(text)
return tagLink ? tagLink[0] : match
})
}
catch (err) {
// TODO: improve type
Expand Down
2 changes: 1 addition & 1 deletion composables/tiptap/suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import TiptapMentionList from '~/components/tiptap/TiptapMentionList.vue'
import TiptapHashtagList from '~/components/tiptap/TiptapHashtagList.vue'
import TiptapEmojiList from '~/components/tiptap/TiptapEmojiList.vue'

export { Emoji }
export type { Emoji }

export type CustomEmoji = (mastodon.v1.CustomEmoji & { custom: true })
export function isCustomEmoji(emoji: CustomEmoji | Emoji): emoji is CustomEmoji {
Expand Down
5 changes: 5 additions & 0 deletions config/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ const locales: LocaleObjectData[] = [
file: 'de-DE.json',
name: 'Deutsch',
},
{
code: 'hu-HU',
file: 'hu-HU.json',
name: 'Magyar',
},
{
code: 'zh-CN',
file: 'zh-CN.json',
Expand Down
2 changes: 1 addition & 1 deletion locales/cs-CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"follow_requested": "Požádáno o sledování",
"followers": "Sledující",
"followers_count": "{0} sledujících",
"following": "Sleduje",
"following": "Sleduji",
"following_count": "{0} sleduje",
"follows_you": "Sleduje vás",
"go_to_profile": "Jít na profil",
Expand Down
6 changes: 6 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"route_loaded": "Page {0} loaded"
},
"account": {
"authorize": "Authorize to follow",
"authorized": "You have Authorized the request",
"avatar_description": "{0}'s avatar",
"blocked_by": "You're blocked by this user.",
"blocked_domains": "Blocked domains",
Expand Down Expand Up @@ -36,7 +38,10 @@
"profile_description": "{0}'s profile header",
"profile_personal_note": "Personal Note",
"profile_unavailable": "Profile unavailable",
"reject": "Reject to follow",
"rejected": "You have rejected the request",
"request_follow": "Request to follow",
"requested": "{0} has requested to follow you",
"unblock": "Unblock",
"unfollow": "Unfollow",
"unmute": "Unmute",
Expand Down Expand Up @@ -213,6 +218,7 @@
"command_mode": "Command mode",
"compose": "Compose",
"favourite": "Favourite",
"search": "Search",
"title": "Actions"
},
"media": {
Expand Down
16 changes: 15 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"unfollow": "Dejar de seguir",
"unmute": "Dejar de silenciar",
"view_other_followers": "Puede que no se muestren los seguidores de otras instancias.",
"view_other_following": "Puede que no se muestren los seguidos de otras instancias."
"view_other_following": "Puede que no se muestren los seguidos de otras instancias.",
"withdraw_follow_request": "Retirar solitud de seguimiento"
},
"action": {
"apply": "Aplicar",
Expand Down Expand Up @@ -246,6 +247,7 @@
"pin_on_profile": "Fijar en tu perfil",
"remove_personal_note": "Eliminar nota personal de {0}",
"report_account": "Reportar a {0}",
"share_account": "Compartir {0}",
"share_post": "Compartir esta publicación",
"show_favourited_and_boosted_by": "Mostrar quien marcó como favorita y quien retooteó",
"show_reblogs": "Mostrar retoots de {0}",
Expand Down Expand Up @@ -603,8 +605,20 @@
"list": "Lista",
"media": "Multimedia",
"news": "Noticias",
"notifications_admin": {
"report": "Informes",
"sign_up": "Inscripciones"
},
"notifications_all": "Todas",
"notifications_favourite": "Favoritas",
"notifications_follow": "Te siguieron",
"notifications_follow_request": "Solicitudes de seguimiento",
"notifications_mention": "Menciones",
"notifications_more_tooltip": "Filtrar notificaciones por tipo",
"notifications_poll": "Encuestas",
"notifications_reblog": "Retoots",
"notifications_status": "Publicaciones",
"notifications_update": "Actualizaciones",
"posts": "Publicaciones",
"posts_with_replies": "Publicaciones y respuestas"
},
Expand Down
Loading

0 comments on commit 10f6090

Please sign in to comment.