Skip to content

Commit

Permalink
ローカルのみオプションを削除 (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakura913 authored Jul 27, 2024
1 parent eb38b36 commit 1dc0d25
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 155 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG_yojo.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
### Release Date

### General
-
- 連合過激派によってローカルのみ投稿機能は削除されました

### Client
-
Expand Down
12 changes: 2 additions & 10 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export const paramDef = {
type: 'string', format: 'misskey:id',
} },
cw: { type: 'string', nullable: true, minLength: 1, maxLength: 100 },
localOnly: { type: 'boolean', default: false },
reactionAcceptance: { type: 'string', nullable: true, enum: [null, 'likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote'], default: null },
disableRightClick: { type: 'boolean', default: false },
noExtractMentions: { type: 'boolean', default: false },
Expand Down Expand Up @@ -364,14 +363,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}

let channel: MiChannel | null = null;
if (ps.channelId != null) {
channel = await this.channelsRepository.findOneBy({ id: ps.channelId, isArchived: false });

if (channel == null) {
throw new ApiError(meta.errors.noSuchChannel);
}
}
const channel: MiChannel | null = null;

// 投稿を作成
try {
Expand All @@ -393,7 +385,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
metadata: ps.event.metadata ?? {},
} : undefined,
cw: ps.cw,
localOnly: ps.localOnly,
localOnly: false,
reactionAcceptance: ps.reactionAcceptance,
disableRightClick: ps.disableRightClick,
visibility: ps.visibility,
Expand Down
2 changes: 0 additions & 2 deletions packages/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21727,8 +21727,6 @@ export type operations = {
visibility?: 'public' | 'home' | 'followers' | 'specified';
visibleUserIds?: string[];
cw?: string | null;
/** @default false */
localOnly?: boolean;
/**
* @default null
* @enum {string|null}
Expand Down
72 changes: 1 addition & 71 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<span :class="$style.headerRightButtonText">{{ channel.name }}</span>
</button>
</template>
<button v-click-anime v-tooltip="i18n.ts._visibility.disableFederation" class="_button" :class="[$style.headerRightItem, { [$style.danger]: localOnly }]" :disabled="channel != null || visibility === 'specified'" @click="toggleLocalOnly">
<span v-if="!localOnly"><i class="ti ti-rocket"></i></span>
<span v-else><i class="ti ti-rocket-off"></i></span>
</button>
<button v-click-anime v-tooltip="i18n.ts.reactionAcceptance" class="_button" :class="[$style.headerRightItem, { [$style.danger]: reactionAcceptance === 'likeOnly' }]" @click="toggleReactionAcceptance">
<span v-if="reactionAcceptance === 'likeOnly'"><i class="ti ti-heart"></i></span>
<span v-else-if="reactionAcceptance === 'likeOnlyForRemote'"><i class="ti ti-heart-plus"></i></span>
Expand Down Expand Up @@ -151,7 +147,6 @@ const props = withDefaults(defineProps<{
initialCw?: string;
initialVisibility?: (typeof Misskey.noteVisibilities)[number];
initialFiles?: Misskey.entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: Misskey.entities.UserDetailed[];
initialNote?: Misskey.entities.Note;
instant?: boolean;
Expand All @@ -164,7 +159,6 @@ const props = withDefaults(defineProps<{
initialVisibleUsers: () => [],
autofocus: true,
mock: false,
initialLocalOnly: undefined,
});

provide('mock', props.mock);
Expand Down Expand Up @@ -202,7 +196,6 @@ watch(showProfilePreview, () => defaultStore.set('showProfilePreview', showProfi
const showAddMfmFunction = ref(defaultStore.state.enableQuickAddMfmFunction);
watch(showAddMfmFunction, () => defaultStore.set('enableQuickAddMfmFunction', showAddMfmFunction.value));
const cw = ref<string | null>(props.initialCw ?? null);
const localOnly = ref(props.initialLocalOnly ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly));
const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility));
const visibleUsers = ref<Misskey.entities.UserDetailed[]>([]);
if (props.initialVisibleUsers) {
Expand Down Expand Up @@ -341,11 +334,6 @@ if ($i.isSilenced && visibility.value === 'public') {
visibility.value = 'home';
}

if (props.channel) {
visibility.value = 'public';
localOnly.value = true; // TODO: チャンネルが連合するようになった折には消す
}

// 公開以外へのリプライ時は元の公開範囲を引き継ぐ
if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visibility)) {
if (props.reply.visibility === 'home' && visibility.value === 'followers') {
Expand Down Expand Up @@ -393,7 +381,6 @@ function watchForDraft() {
watch(event, () => saveDraft());
watch(files, () => saveDraft(), { deep: true });
watch(visibility, () => saveDraft());
watch(localOnly, () => saveDraft());
}

function checkMissingMention() {
Expand Down Expand Up @@ -497,16 +484,9 @@ function upload(file: File, name?: string): void {
}

function setVisibility() {
if (props.channel) {
visibility.value = 'public';
localOnly.value = true; // TODO: チャンネルが連合するようになった折には消す
return;
}

os.popup(defineAsyncComponent(() => import('@/components/MkVisibilityPicker.vue')), {
currentVisibility: visibility.value,
isSilenced: $i.isSilenced,
localOnly: localOnly.value,
src: visibilityButton.value,
...(props.reply ? { isReplyVisibilitySpecified: props.reply.visibility === 'specified' } : {}),
}, {
Expand All @@ -519,51 +499,6 @@ function setVisibility() {
}, 'closed');
}

async function toggleLocalOnly() {
if (props.channel) {
visibility.value = 'public';
localOnly.value = true; // TODO: チャンネルが連合するようになった折には消す
return;
}

const neverShowInfo = miLocalStorage.getItem('neverShowLocalOnlyInfo');

if (!localOnly.value && neverShowInfo !== 'true') {
const confirm = await os.actions({
type: 'question',
title: i18n.ts.disableFederationConfirm,
text: i18n.ts.disableFederationConfirmWarn,
actions: [
{
value: 'yes' as const,
text: i18n.ts.disableFederationOk,
primary: true,
},
{
value: 'neverShow' as const,
text: `${i18n.ts.disableFederationOk} (${i18n.ts.neverShow})`,
danger: true,
},
{
value: 'no' as const,
text: i18n.ts.cancel,
},
],
});
if (confirm.canceled) return;
if (confirm.result === 'no') return;

if (confirm.result === 'neverShow') {
miLocalStorage.setItem('neverShowLocalOnlyInfo', 'true');
}
}

localOnly.value = !localOnly.value;
if (defaultStore.state.rememberNoteVisibility) {
defaultStore.set('localOnly', localOnly.value);
}
}

async function toggleReactionAcceptance() {
const select = await os.select({
title: i18n.ts.reactionAcceptance,
Expand Down Expand Up @@ -620,7 +555,6 @@ function onKeydown(ev: KeyboardEvent) {
else if (ev.ctrlKey && ev.shiftKey && (visibility.value === 'public')) visibility.value = 'home';
else if (ev.ctrlKey && ev.shiftKey && (visibility.value === 'home')) visibility.value = 'followers';
else if (ev.ctrlKey && ev.shiftKey && (visibility.value === 'followers')) visibility.value = 'specified';
if ((ev.ctrlKey || ev.metaKey) && ev.altKey) localOnly.value = !localOnly.value;
}

if (ev.key === 'Escape') emit('esc');
Expand Down Expand Up @@ -752,7 +686,6 @@ function saveDraft() {
cw: cw.value,
disableRightClick: disableRightClick.value,
visibility: visibility.value,
localOnly: localOnly.value,
files: files.value,
poll: poll.value,
event: event.value,
Expand Down Expand Up @@ -833,7 +766,6 @@ async function post(ev?: MouseEvent) {
poll: poll.value,
event: event.value,
cw: useCw.value ? cw.value ?? '' : null,
localOnly: localOnly.value,
visibility: visibility.value,
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(u => u.id) : undefined,
reactionAcceptance: reactionAcceptance.value,
Expand Down Expand Up @@ -956,7 +888,7 @@ function cancel() {
}

function insertMention() {
os.selectUser({ localOnly: localOnly.value, includeSelf: true }).then(user => {
os.selectUser({ localOnly: false, includeSelf: true }).then(user => {
insertTextAtCursor(textareaEl.value, '@' + Misskey.acct.toString(user) + ' ');
});
}
Expand Down Expand Up @@ -1063,7 +995,6 @@ onMounted(() => {
cw.value = draft.data.cw;
disableRightClick.value = draft.data.disableRightClick;
visibility.value = draft.data.visibility;
localOnly.value = draft.data.localOnly;
files.value = (draft.data.files || []).filter(draftFile => draftFile);
if (draft.data.poll) {
poll.value = draft.data.poll;
Expand Down Expand Up @@ -1103,7 +1034,6 @@ onMounted(() => {
};
}
visibility.value = init.visibility;
localOnly.value = init.localOnly ?? false;
quoteId.value = init.renote ? init.renote.id : null;
disableRightClick.value = init.disableRightClick != null;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/frontend/src/components/MkPostFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ const props = withDefaults(defineProps<{
initialCw?: string;
initialVisibility?: (typeof Misskey.noteVisibilities)[number];
initialFiles?: Misskey.entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: Misskey.entities.UserDetailed[];
initialNote?: Misskey.entities.Note;
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
updateMode?: boolean;
}>(), {
initialLocalOnly: undefined,
});

const emit = defineEmits<{
Expand Down
Loading

0 comments on commit 1dc0d25

Please sign in to comment.