Skip to content

Commit

Permalink
無印でも下書きが動くように
Browse files Browse the repository at this point in the history
  • Loading branch information
nakkaa committed May 2, 2024
1 parent 1ad5fd8 commit e366b58
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 298 deletions.
14 changes: 0 additions & 14 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4960,10 +4960,6 @@ export interface Locale extends ILocale {
* 下書き
*/
"drafts": string;
/**
* 下書きの保存に関する動作
*/
"draftSavingBehavior": string;
/**
* 下書きとして保存
*/
Expand Down Expand Up @@ -9920,16 +9916,6 @@ export interface Locale extends ILocale {
*/
"loop": string;
};
"_draftSavingBehavior": {
/**
* 自動的に保存する
*/
"auto": string;
/**
* 都度確認する
*/
"manual": string;
};
}
declare const locales: {
[lang: string]: Locale;
Expand Down
12 changes: 0 additions & 12 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,6 @@ noDescription: "説明文はありません"
alwaysConfirmFollow: "フォローの際常に確認する"
inquiry: "お問い合わせ"
drafts: "下書き"
draftSavingBehavior: "下書きの保存に関する動作"
saveAsDraft: "下書きとして保存"
draftOverwriteConfirm: "下書きを適用すると現在入力されている内容はリセットされます。よろしいですか?"

Expand Down Expand Up @@ -2623,7 +2622,6 @@ _offlineScreen:
title: "オフライン - サーバーに接続できません"
header: "サーバーに接続できません"

<<<<<<< HEAD
_urlPreviewSetting:
title: "URLプレビューの設定"
enable: "URLプレビューを有効にする"
Expand All @@ -2643,14 +2641,4 @@ _mediaControls:
pip: "ピクチャインピクチャ"
playbackRate: "再生速度"
loop: "ループ再生"
=======
_hideReactionCount:
none: "非表示にしない"
self: "自分のノートのみ"
others: "自分以外のノートのみ"
all: "全てのノート"

_draftSavingBehavior:
auto: "自動的に保存する"
manual: "都度確認する"
>>>>>>> 03d1c493a2 (feat: 下書き機能 (#144))
75 changes: 11 additions & 64 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<button v-tooltip="i18n.ts.hashtags" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: withHashtags }]" @click="withHashtags = !withHashtags"><i class="ti ti-hash"></i></button>
<button v-if="postFormActions.length > 0" v-tooltip="i18n.ts.plugins" class="_button" :class="$style.footerButton" @click="showActions"><i class="ti ti-plug"></i></button>
<button v-tooltip="i18n.ts.emoji" :class="['_button', $style.footerButton]" @click="insertEmoji"><i class="ti ti-mood-happy"></i></button>
<button v-tooltip="i18n.ts.saveAsDraft" :class="['_button', $style.footerButton]" @click="saveDraft(false)"><i class="ti ti-note"></i></button>
<button v-if="showAddMfmFunction" v-tooltip="i18n.ts.addMfmFunction" :class="['_button', $style.footerButton]" @click="insertMfmFunction"><i class="ti ti-palette"></i></button>
</div>
<div :class="$style.footerRight">
Expand Down Expand Up @@ -260,7 +261,6 @@ const canPost = computed((): boolean => {
props.renote != null ||
(props.reply != null && quoteId.value != null)
) &&
(scheduledNoteDelete.value ? scheduledNoteDelete.value.isValid : true) &&
(1 <= textLength.value || 1 <= files.value.length || !!poll.value || !!renote.value) &&
(textLength.value <= maxTextLength.value) &&
(!poll.value || poll.value.choices.length >= 2);
Expand All @@ -269,53 +269,6 @@ const canPost = computed((): boolean => {
const withHashtags = computed(defaultStore.makeGetterSetter('postFormWithHashtags'));
const hashtags = computed(defaultStore.makeGetterSetter('postFormHashtags'));

const bottomItemActionDef: Record<keyof typeof bottomItemDef, {
hide?: boolean;
active?: any;
action?: any;
}> = reactive({
attachFile: {
action: chooseFileFrom,
},
poll: {
active: poll,
action: togglePoll,
},
scheduledNoteDelete: {
active: scheduledNoteDelete,
action: toggleScheduledNoteDelete,
},
useCw: {
active: useCw,
action: () => useCw.value = !useCw.value,
},
mention: {
action: insertMention,
},
hashtags: {
active: withHashtags,
action: () => withHashtags.value = !withHashtags.value,
},
plugins: {
hide: postFormActions.length === 0,
action: showActions,
},
emoji: {
action: insertEmoji,
},
addMfmFunction: {
hide: computed(() => !showAddMfmFunction.value),
action: insertMfmFunction,
},
clearPost: {
action: clear,
},
saveAsDraft: {
action: () => saveDraft(false),
},
});

>>>>>>> 03d1c493a2 (feat: 下書き機能 (#144))
watch(text, () => {
checkMissingMention();
}, { immediate: true });
Expand Down Expand Up @@ -723,8 +676,6 @@ function onDrop(ev: DragEvent): void {
async function saveDraft(auto = true) {
if (props.instant || props.mock) return;

if (auto && defaultStore.state.draftSavingBehavior !== 'auto') return;

if (!auto) {
// 手動での保存の場合は自動保存したものを削除した上で保存
await noteDrafts.remove(draftType.value, $i.id, 'default', draftAuxId.value as string);
Expand All @@ -738,7 +689,6 @@ async function saveDraft(auto = true) {
localOnly: localOnly.value,
files: files.value,
poll: poll.value,
scheduledNoteDelete: scheduledNoteDelete.value,
}, draftAuxId.value as string);

if (!auto) {
Expand Down Expand Up @@ -801,9 +751,6 @@ async function applyDraft(draft: noteDrafts.NoteDraft, native = false) {
if (draft.data.poll) {
poll.value = draft.data.poll;
}
if (draft.data.scheduledNoteDelete) {
scheduledNoteDelete.value = draft.data.scheduledNoteDelete;
}
}

async function post(ev?: MouseEvent) {
Expand Down Expand Up @@ -980,15 +927,15 @@ function cancel() {
}

async function closed() {
if (defaultStore.state.draftSavingBehavior === 'manual' && (text.value !== '' || files.value.length > 0)) {
os.confirm({
type: 'question',
text: i18n.ts.saveConfirm,
}).then(({ canceled }) => {
if (canceled) return;
saveDraft(false);
});
}
// if (text.value !== '' || files.value.length > 0) {
// os.confirm({
// type: 'question',
// text: i18n.ts.saveConfirm,
// }).then(({ canceled }) => {
// if (canceled) return;
// saveDraft(false);
// });
// }
}

function insertMention() {
Expand Down Expand Up @@ -1075,7 +1022,7 @@ onMounted(() => {
await noteDrafts.migrate($i.id);

// 書きかけの投稿を復元
if (!props.instant && !props.mention && !props.specified && !props.mock && !defaultStore.state.disableNoteDrafting) {
if (!props.instant && !props.mention && !props.specified && !props.mock) {
const draft = await noteDrafts.get(draftType.value, $i.id, 'default', draftAuxId.value as string);
if (draft) applyDraft(draft, true);
}
Expand Down
154 changes: 0 additions & 154 deletions packages/frontend/src/pages/settings/post-form.vue

This file was deleted.

2 changes: 0 additions & 2 deletions packages/frontend/src/scripts/note-drafts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Misskey from 'misskey-js';
import type { PollEditorModelValue } from '@/components/MkPollEditor.vue';
import type { DeleteScheduleEditorModelValue } from '@/components/MkDeleteScheduleEditor.vue';
import { miLocalStorage } from '@/local-storage.js';
import { get as idbGet, set as idbSet } from '@/scripts/idb-proxy.js';

Expand All @@ -17,7 +16,6 @@ export type NoteDraft = {
localOnly: boolean;
files: Misskey.entities.DriveFile[];
poll: PollEditorModelValue | null;
scheduledNoteDelete: DeleteScheduleEditorModelValue | null;
};
};

Expand Down
Loading

0 comments on commit e366b58

Please sign in to comment.