Skip to content

Commit

Permalink
fix(frontend): 連合なしの状態の読み書きができない問題 (misskey-dev#13777)
Browse files Browse the repository at this point in the history
* fix: 連合なしの状態の読み書きができない問題

* update changelog

* fix types: misskey-dev#13777 (comment)
  • Loading branch information
taiyme authored May 1, 2024
1 parent ef630df commit 9f66f22
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- Fix: ページのOGP URLが間違っているのを修正
- Fix: リバーシの対局を正しく共有できないことがある問題を修正
- Fix: 通知をグループ化している際に、人数が正常に表示されないことがある問題を修正
- Fix: 連合なしの状態の読み書きができない問題を修正

### Server
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
Expand Down
8 changes: 6 additions & 2 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const props = withDefaults(defineProps<{
initialVisibleUsers: () => [],
autofocus: true,
mock: false,
initialLocalOnly: undefined,
});
provide('mock', props.mock);
Expand Down Expand Up @@ -185,8 +186,8 @@ watch(showPreview, () => defaultStore.set('showPreview', showPreview.value));
const showAddMfmFunction = ref(defaultStore.state.enableQuickAddMfmFunction);
watch(showAddMfmFunction, () => defaultStore.set('enableQuickAddMfmFunction', showAddMfmFunction.value));
const cw = ref<string | null>(props.initialCw ?? null);
const localOnly = ref<boolean>(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) as typeof Misskey.noteVisibilities[number]);
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) {
props.initialVisibleUsers.forEach(pushVisibleUser);
Expand Down Expand Up @@ -518,6 +519,9 @@ async function toggleLocalOnly() {
}
localOnly.value = !localOnly.value;
if (defaultStore.state.rememberNoteVisibility) {
defaultStore.set('localOnly', localOnly.value);
}
}
async function toggleReactionAcceptance() {
Expand Down
6 changes: 4 additions & 2 deletions packages/frontend/src/components/MkPostFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as Misskey from 'misskey-js';
import MkModal from '@/components/MkModal.vue';
import MkPostForm from '@/components/MkPostForm.vue';
const props = defineProps<{
const props = withDefaults(defineProps<{
reply?: Misskey.entities.Note;
renote?: Misskey.entities.Note;
channel?: any; // TODO
Expand All @@ -31,7 +31,9 @@ const props = defineProps<{
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
}>();
}>(), {
initialLocalOnly: undefined,
});
const emit = defineEmits<{
(ev: 'closed'): void;
Expand Down
5 changes: 2 additions & 3 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,9 @@ export function getNoteMenu(props: {
};
}

type Visibility = 'public' | 'home' | 'followers' | 'specified';
type Visibility = (typeof Misskey.noteVisibilities)[number];

// defaultStore.state.visibilityがstringなためstringも受け付けている
function smallerVisibility(a: Visibility | string, b: Visibility | string): Visibility {
function smallerVisibility(a: Visibility, b: Visibility): Visibility {
if (a === 'specified' || b === 'specified') return 'specified';
if (a === 'followers' || b === 'followers') return 'followers';
if (a === 'home' || b === 'home') return 'home';
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const defaultStore = markRaw(new Storage('base', {
},
defaultNoteVisibility: {
where: 'account',
default: 'public',
default: 'public' as (typeof Misskey.noteVisibilities)[number],
},
defaultNoteLocalOnly: {
where: 'account',
Expand Down Expand Up @@ -150,7 +150,7 @@ export const defaultStore = markRaw(new Storage('base', {
},
visibility: {
where: 'deviceAccount',
default: 'public' as 'public' | 'home' | 'followers' | 'specified',
default: 'public' as (typeof Misskey.noteVisibilities)[number],
},
localOnly: {
where: 'deviceAccount',
Expand Down

0 comments on commit 9f66f22

Please sign in to comment.