Skip to content

Commit

Permalink
refactor: remove visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Nov 24, 2024
1 parent 6ad3b54 commit 7cb8ad0
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 119 deletions.
36 changes: 0 additions & 36 deletions components/publish/PublishVisibilityPicker.vue

This file was deleted.

16 changes: 0 additions & 16 deletions components/publish/PublishWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const {
threadComposer?: ReturnType<typeof useThreadComposer>
placeholder?: string
inReplyToId?: string
inReplyToVisibility?: mastodon.v1.StatusVisibility
expanded?: boolean
dialogLabelledBy?: string
}>()
Expand Down Expand Up @@ -173,8 +172,6 @@ const isExceedingCharacterLimit = computed(() => {
const postLanguageDisplay = computed(() => languagesNameList.find(i => i.code === (draft.value.params.language || preferredLanguage.value))?.nativeName)
const isDM = computed(() => draft.value.params.visibility === 'direct')
async function handlePaste(evt: ClipboardEvent) {
const files = evt.clipboardData?.files
if (!files || files.length === 0)
Expand Down Expand Up @@ -301,7 +298,6 @@ function stopQuestionMarkPropagation(e: KeyboardEvent) {
:editor="editor" flex max-w-full
:class="{
'md:max-h-[calc(100vh-200px)] sm:max-h-[calc(100vh-400px)] max-h-35 of-y-auto overscroll-contain': shouldExpanded,
'py2 px3.5 bg-dm rounded-4 me--1 ms--1 mt--1': isDM,
}"
@keydown="stopQuestionMarkPropagation"
@keydown.esc.prevent="editor?.commands.blur()"
Expand Down Expand Up @@ -482,18 +478,6 @@ function stopQuestionMarkPropagation(e: KeyboardEvent) {
</button>
</CommonTooltip>

<PublishVisibilityPicker v-model="draft.params.visibility" :editing="!!draft.editingStatus">
<template #default="{ visibility }">
<button
:disabled="!!draft.editingStatus" :aria-label="$t('tooltip.change_content_visibility')"
btn-action-icon :class="{ 'w-12': !draft.editingStatus }"
>
<div :class="visibility.icon" />
<div v-if="!draft.editingStatus" i-ri:arrow-down-s-line text-sm text-secondary me--1 />
</button>
</template>
</PublishVisibilityPicker>

<PublishThreadTools :draft-item-index="draftItemIndex" :draft-key="draftKey" />

<CommonTooltip
Expand Down
4 changes: 0 additions & 4 deletions components/publish/PublishWidgetList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import type { DraftItem } from '~/types'
const {
Expand All @@ -9,13 +8,11 @@ const {
placeholder,
dialogLabelledBy,
inReplyToId,
inReplyToVisibility,
} = defineProps<{
draftKey: string
initial?: () => DraftItem
placeholder?: string
inReplyToId?: string
inReplyToVisibility?: mastodon.v1.StatusVisibility
expanded?: boolean
dialogLabelledBy?: string
}>()
Expand Down Expand Up @@ -44,7 +41,6 @@ function isFirstItem(index: number) {
:placeholder="placeholder"
:dialog-labelled-by="dialogLabelledBy"
:in-reply-to-id="isFirstItem(index) ? inReplyToId : undefined"
:in-reply-to-visibility="inReplyToVisibility"
/>
</template>
</template>
4 changes: 1 addition & 3 deletions components/status/StatusCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const timeago = useTimeAgo(() => status.value.createdAt, timeAgoOptions)
const isSelfReply = computed(() => status.value.inReplyToAccountId === status.value.account.id)
const collapseRebloggedBy = computed(() => rebloggedBy.value?.id === status.value.account.id)
const isDM = computed(() => status.value.visibility === 'direct')
const showUpperBorder = computed(() => props.newer && !directReply.value)
const showReplyTo = computed(() => !replyToMain.value && !directReply.value)
Expand Down Expand Up @@ -158,7 +157,6 @@ const forceShow = ref(false)
<AccountLockIndicator v-if="status.account.locked" me-2 />
<AccountBotIndicator v-if="status.account.bot" me-2 />
<div flex="~ gap1" items-center>
<StatusVisibilityIndicator v-if="status.visibility !== 'public'" :status="status" />
<div flex>
<CommonTooltip :content="createdAt">
<NuxtLink :title="status.createdAt" :href="statusRoute.href" @click.prevent="go($event)">
Expand All @@ -180,7 +178,7 @@ const forceShow = ref(false)
:context="context"
:is-preview="isPreview"
:in-notification="inNotification"
mb2 :class="{ 'mt-2 mb1': isDM }"
mb2
/>
<StatusActions v-if="actions !== false" v-show="!getPreferences(userSettings, 'zenMode')" :status="status" />
</div>
Expand Down
11 changes: 2 additions & 9 deletions components/status/StatusContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const { status, context } = defineProps<{
inNotification?: boolean
}>()
const isDM = computed(() => status.visibility === 'direct')
const isDetails = computed(() => context === 'details')
// Content Filter logic
Expand All @@ -34,15 +33,9 @@ const allowEmbeddedMedia = computed(() => status.card?.html && embeddedMediaPref
</script>

<template>
<div
space-y-3
:class="{
'py2 px3.5 bg-dm rounded-4 me--1': isDM,
'ms--3.5 mt--1 ms--1': isDM && context !== 'details',
}"
>
<div space-y-3>
<StatusBody v-if="(!isFiltered && isSensitiveNonSpoiler) || hideAllMedia" :status="status" :newer="newer" :with-action="!isDetails" :class="isDetails ? 'text-xl' : ''" />
<StatusSpoiler :enabled="hasSpoilerOrSensitiveMedia || isFiltered" :filter="isFiltered" :sensitive-non-spoiler="isSensitiveNonSpoiler || hideAllMedia" :is-d-m="isDM">
<StatusSpoiler :enabled="hasSpoilerOrSensitiveMedia || isFiltered" :filter="isFiltered" :sensitive-non-spoiler="isSensitiveNonSpoiler || hideAllMedia">
<template v-if="spoilerTextPresent" #spoiler>
<p>
<ContentRich :content="status.spoilerText" :emojis="status.emojis" :markdown="false" />
Expand Down
1 change: 0 additions & 1 deletion components/status/StatusDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ useHydratedHead({
<div aria-hidden="true">
&middot;
</div>
<StatusVisibilityIndicator :status="status" />
<div v-if="status.application?.name" aria-hidden="true">
&middot;
</div>
Expand Down
5 changes: 2 additions & 3 deletions components/status/StatusSpoiler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const props = defineProps<{
enabled?: boolean
filter?: boolean
isDM?: boolean
sensitiveNonSpoiler?: boolean
}>()
Expand Down Expand Up @@ -34,8 +33,8 @@ function getToggleText() {
<div class="content-rich" p="x-4 b-2.5" text-center text-secondary w-full border="~ base" border-0 border-b-dotted border-b-3 mt-2>
<slot name="spoiler" />
</div>
<div flex="~ gap-1 center" w-full :mb="isDM && !showContent ? '4' : ''" mt="-4.5">
<button btn-text px-2 py-1 rounded-lg :bg="isDM ? 'transparent' : 'base'" flex="~ center gap-2" :class="showContent ? '' : 'filter-saturate-0 hover:filter-saturate-100'" :aria-expanded="showContent" @click="toggleContent()">
<div flex="~ gap-1 center" w-full mb mt="-4.5">
<button btn-text px-2 py-1 rounded-lg bg-base flex="~ center gap-2" :class="showContent ? '' : 'filter-saturate-0 hover:filter-saturate-100'" :aria-expanded="showContent" @click="toggleContent()">
<div v-if="showContent" i-ri:eye-line />
<div v-else i-ri:eye-close-line />
{{ showContent ? $t('status.spoiler_show_less') : $t(getToggleText()) }}
Expand Down
15 changes: 0 additions & 15 deletions components/status/StatusVisibilityIndicator.vue

This file was deleted.

5 changes: 1 addition & 4 deletions composables/masto/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ export function useStatusActions(props: StatusActionsProps) {
status.value[countField] += status.value[action] ? 1 : -1
}

const canReblog = computed(() =>
status.value.visibility !== 'direct'
&& (status.value.visibility !== 'private' || status.value.account.id === currentUser.value?.account.id),
)
const canReblog = computed(() => true) // TODO: repost rules

const toggleReblog = () => toggleStatusAction(
'reblogged',
Expand Down
21 changes: 1 addition & 20 deletions composables/masto/statusDrafts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,12 @@ export const builtinDraftKeys = [
'home',
]

const ALL_VISIBILITY = ['public', 'unlisted', 'private', 'direct'] as const

function getDefaultVisibility(currentVisibility: mastodon.v1.StatusVisibility) {
// The default privacy only should be taken into account if it makes
// the post more private than the replying to post
const preferredVisibility = currentUser.value?.account.source.privacy || 'public'
return ALL_VISIBILITY.indexOf(currentVisibility)
> ALL_VISIBILITY.indexOf(preferredVisibility)
? currentVisibility
: preferredVisibility
}

export function getDefaultDraftItem(options: Partial<Mutable<mastodon.rest.v1.CreateStatusParams> & Omit<DraftItem, 'params'>> = {}): DraftItem {
const {
attachments = [],
initialText = '',
status,
inReplyToId,
visibility,
sensitive,
spoilerText,
language,
Expand All @@ -46,7 +33,6 @@ export function getDefaultDraftItem(options: Partial<Mutable<mastodon.rest.v1.Cr
status: status || '',
poll,
inReplyToId,
visibility: getDefaultVisibility(visibility || 'public'),
sensitive: sensitive ?? false,
spoilerText: spoilerText || '',
language: language || '', // auto inferred from current language on posting
Expand All @@ -59,7 +45,6 @@ export function getDefaultDraftItem(options: Partial<Mutable<mastodon.rest.v1.Cr
export async function getDraftFromStatus(status: mastodon.v1.Status): Promise<DraftItem> {
const info = {
status: await convertMastodonHTML(status.content),
visibility: status.visibility,
attachments: status.mediaAttachments,
sensitive: status.sensitive,
spoilerText: status.spoilerText,
Expand Down Expand Up @@ -104,7 +89,6 @@ export function getReplyDraft(status: mastodon.v1.Status) {
inReplyToId: status!.id,
sensitive: status.sensitive,
spoilerText: status.spoilerText,
visibility: status.visibility,
mentions: accountsToMention,
language: status.language,
})
Expand Down Expand Up @@ -176,10 +160,7 @@ export function mentionUser(account: mastodon.v1.Account) {
}

export function directMessageUser(account: mastodon.v1.Account) {
openPublishDialog('dialog', getDefaultDraftItem({
status: `@${account.acct} `,
visibility: 'direct',
}))
openPublishDialog('dialog', getDefaultDraftItem({ status: `@${account.acct} ` }))
}

export function clearEmptyDrafts() {
Expand Down
1 change: 0 additions & 1 deletion composables/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function useThreadComposer(draftKey: string, initial?: () => DraftItem) {
language: lastItem.params.language,
sensitive: lastItem.params.sensitive,
spoilerText: lastItem.params.spoilerText,
visibility: lastItem.params.visibility,
}))
}

Expand Down
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/[status].vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ onReactivated(() => {
<template v-if="!pendingContext">
<StatusCard
v-for="(comment, i) of context?.ancestors" :key="comment.id"
:status="comment" :actions="comment.visibility !== 'direct'" context="account"
:status="comment" context="account"
:has-older="true" :newer="context?.ancestors[i - 1]"
/>
</template>
Expand Down
3 changes: 0 additions & 3 deletions pages/intent/post.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
const router = useRouter()
const route = useRoute()
Expand All @@ -10,7 +8,6 @@ onMounted(async () => {
status: route.query.text as string,
sensitive: route.query.sensitive === 'true' || route.query.sensitive === null,
spoilerText: route.query.spoiler_text as string,
visibility: route.query.visibility as mastodon.v1.StatusVisibility,
language: route.query.language as string,
}), true)
// TODO: need a better idea 👀
Expand Down
2 changes: 0 additions & 2 deletions service-worker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ export interface Status {
account: MastoAccount
/** HTML-encoded status content. */
content: string
/** Visibility of this status. */
visibility: mastodon.v1.StatusVisibility
/** Is this status marked as sensitive content? */
sensitive: boolean
/** Subject or summary line, below which status content is collapsed until expanded. */
Expand Down
2 changes: 1 addition & 1 deletion types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type TranslateFn = ReturnType<typeof useI18n>['t']
export interface DraftItem {
editingStatus?: mastodon.v1.Status
initialText?: string
params: MarkNonNullable<Mutable<Omit<mastodon.rest.v1.CreateStatusParams, 'poll'>>, 'status' | 'language' | 'sensitive' | 'spoilerText' | 'visibility'> & { poll: Mutable<mastodon.rest.v1.CreateStatusParams['poll']> }
params: MarkNonNullable<Mutable<Omit<mastodon.rest.v1.CreateStatusParams, 'poll'>>, 'status' | 'language' | 'sensitive' | 'spoilerText'> & { poll: Mutable<mastodon.rest.v1.CreateStatusParams['poll']> }
attachments: mastodon.v1.MediaAttachment[]
lastUpdated: number
mentions?: string[]
Expand Down

0 comments on commit 7cb8ad0

Please sign in to comment.