feat: store defaultWithReplies in client store

This commit is contained in:
anatawa12 2023-10-16 16:43:50 +09:00
parent 0a2befa022
commit aa39b77616
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
4 changed files with 9 additions and 8 deletions

View File

@ -42,6 +42,7 @@ import { useStream } from '@/stream.js';
import { i18n } from '@/i18n.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { $i } from '@/account.js';
import { defaultStore } from "@/store.js";
const props = withDefaults(defineProps<{
user: Misskey.entities.UserDetailed,
@ -95,6 +96,7 @@ async function onClick() {
} else {
await os.api('following/create', {
userId: props.user.id,
withReplies: defaultStore.state.defaultWithReplies,
});
hasPendingFollowRequestFromYou = true;

View File

@ -14,6 +14,7 @@ import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import { mainRouter } from '@/router.js';
import { i18n } from '@/i18n.js';
import { defaultStore } from "@/store.js";
async function follow(user): Promise<void> {
const { canceled } = await os.confirm({
@ -28,6 +29,7 @@ async function follow(user): Promise<void> {
os.apiWithDialog('following/create', {
userId: user.id,
withReplies: defaultStore.state.defaultWithReplies,
});
}

View File

@ -203,7 +203,6 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
import { miLocalStorage } from '@/local-storage.js';
import { globalEvents } from '@/events';
import { claimAchievement } from '@/scripts/achievements.js';
import { $i } from "@/account.js";
const lang = ref(miLocalStorage.getItem('lang'));
const fontSize = ref(miLocalStorage.getItem('fontSize'));
@ -251,7 +250,7 @@ const mediaListWithOneImageAppearance = computed(defaultStore.makeGetterSetter('
const notificationPosition = computed(defaultStore.makeGetterSetter('notificationPosition'));
const notificationStackAxis = computed(defaultStore.makeGetterSetter('notificationStackAxis'));
const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn'));
const defaultWithReplies = ref($i!.defaultWithReplies); // TODO
const defaultWithReplies = computed(defaultStore.makeGetterSetter('defaultWithReplies'));
watch(lang, () => {
miLocalStorage.setItem('lang', lang.value as string);
@ -292,12 +291,6 @@ watch([
await reloadAsk();
});
watch([defaultWithReplies], async () => {
os.api('i/update', {
defaultWithReplies: defaultWithReplies.value,
});
});
const emojiIndexLangs = ['en-US'];
function downloadEmojiIndex(lang: string) {

View File

@ -361,6 +361,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: false,
},
defaultWithReplies: {
where: 'account',
default: false,
},
}));
// TODO: 他のタブと永続化されたstateを同期