diff --git a/src/store/app/rtc.ts b/src/store/app/rtc.ts index e6bf4b053..2a5302e0c 100644 --- a/src/store/app/rtc.ts +++ b/src/store/app/rtc.ts @@ -46,16 +46,15 @@ const useAppRtcPinia = defineStore('app/rtc', () => { } /** マイクミュート */ - const isMicMuted = ref(false) const muteLocalStream = () => { if (!localStreamManager.value) return localStreamManager.value.mute() - isMicMuted.value = true + rtcSettings.isMute.value = true } const unmuteLocalStream = () => { if (!localStreamManager.value) return localStreamManager.value.unmute() - isMicMuted.value = false + rtcSettings.isMute.value = false } /** 現在発話しているユーザーを判定するsetIntervalのID */ @@ -283,7 +282,7 @@ const useAppRtcPinia = defineStore('app/rtc', () => { setUserVolume(userId, 0.5) }) - if (isMicMuted.value) { + if (rtcSettings.isMute.value) { mute() } else { unmute() @@ -352,7 +351,7 @@ const useAppRtcPinia = defineStore('app/rtc', () => { return { isCurrentDevice, - isMicMuted, + isMicMuted: rtcSettings.isMute, talkingUsersState, startQall, endQall, diff --git a/src/store/app/rtcSettings.ts b/src/store/app/rtcSettings.ts index 0b1d7cca4..ced6a3227 100644 --- a/src/store/app/rtcSettings.ts +++ b/src/store/app/rtcSettings.ts @@ -19,6 +19,7 @@ type State = { voicePitch: number voiceRate: number voiceVolume: number + isMute: boolean } const useRtcSettingsPinia = defineStore('app/rtcSettings', () => { @@ -33,12 +34,13 @@ const useRtcSettingsPinia = defineStore('app/rtcSettings', () => { voiceName: '', voicePitch: 1, voiceRate: 1.2, - voiceVolume: 1 + voiceVolume: 1, + isMute: false } const [state, restoring, restoringPromise] = useIndexedDbValue( 'store/app/rtcSettings', - 2, + 3, { // migrate from vuex 1: async getStore => { @@ -64,6 +66,12 @@ const useRtcSettingsPinia = defineStore('app/rtcSettings', () => { delete state?.isNoiseReductionEnabled const setReq = store.put(state, key) await promisifyRequest(setReq) + }, + + 3: async getStore => { + const store = getStore() + const setReq = store.put({ isMute: false }, key) + await promisifyRequest(setReq) } }, initialValue