enhance: Implement the toggle to (or not to) close push notifications when notifications or messages are read (#9219)
* create file * wip * fix * wip * tabun dekita * ✌️ * implement subscribe push notification button to tutorial * check-exists→show-registration * add column sendReadMessage * fix migration file * sw api * change PushNotificationService * wip * ✌️ * fix tutorial footer flex
This commit is contained in:
parent
96dda253b0
commit
4ecc42744c
14 changed files with 483 additions and 106 deletions
|
|
@ -6,6 +6,18 @@
|
|||
<FormLink class="_formBlock" @click="readAllUnreadNotes">{{ i18n.ts.markAsReadAllUnreadNotes }}</FormLink>
|
||||
<FormLink class="_formBlock" @click="readAllMessagingMessages">{{ i18n.ts.markAsReadAllTalkMessages }}</FormLink>
|
||||
</FormSection>
|
||||
<FormSection>
|
||||
<template #label>{{ i18n.ts.pushNotification }}</template>
|
||||
<MkPushNotificationAllowButton ref="allowButton" />
|
||||
<FormSwitch class="_formBlock" :disabled="!pushRegistrationInServer" :model-value="sendReadMessage" @update:modelValue="onChangeSendReadMessage">
|
||||
<template #label>{{ i18n.ts.sendPushNotificationReadMessage }}</template>
|
||||
<template #caption>
|
||||
<I18n :src="i18n.ts.sendPushNotificationReadMessageCaption">
|
||||
<template #emptyPushNotificationMessage>{{ i18n.ts._notification.emptyPushNotificationMessage }}</template>
|
||||
</I18n>
|
||||
</template>
|
||||
</FormSwitch>
|
||||
</FormSection>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -15,10 +27,16 @@ import { notificationTypes } from 'misskey-js';
|
|||
import FormButton from '@/components/MkButton.vue';
|
||||
import FormLink from '@/components/form/link.vue';
|
||||
import FormSection from '@/components/form/section.vue';
|
||||
import FormSwitch from '@/components/form/switch.vue';
|
||||
import * as os from '@/os';
|
||||
import { $i } from '@/account';
|
||||
import { i18n } from '@/i18n';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
|
||||
|
||||
let allowButton = $ref<InstanceType<typeof MkPushNotificationAllowButton>>();
|
||||
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
|
||||
let sendReadMessage = $computed(() => pushRegistrationInServer?.sendReadMessage || false);
|
||||
|
||||
async function readAllUnreadNotes() {
|
||||
await os.api('i/read-all-unread-notes');
|
||||
|
|
@ -49,6 +67,18 @@ function configure() {
|
|||
}, 'closed');
|
||||
}
|
||||
|
||||
function onChangeSendReadMessage(v: boolean) {
|
||||
if (!pushRegistrationInServer) return;
|
||||
|
||||
os.apiWithDialog('sw/update-registration', {
|
||||
endpoint: pushRegistrationInServer.endpoint,
|
||||
sendReadMessage: v,
|
||||
}).then(res => {
|
||||
if (!allowButton) return;
|
||||
allowButton.pushRegistrationInServer = res;
|
||||
});
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => []);
|
||||
|
||||
const headerTabs = $computed(() => []);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,17 @@
|
|||
<template>
|
||||
<div class="_card tbkwesmv">
|
||||
<div class="_title"><i class="fas fa-info-circle"></i> {{ i18n.ts._tutorial.title }}</div>
|
||||
<div class="_card">
|
||||
<div :class="$style.title" class="_title">
|
||||
<div :class="$style.titleText"><i class="fas fa-info-circle"></i> {{ i18n.ts._tutorial.title }}</div>
|
||||
<div :class="$style.step">
|
||||
<button class="_button" :class="$style.stepArrow" :disabled="tutorial === 0" @click="tutorial--">
|
||||
<i class="fas fa-chevron-left"></i>
|
||||
</button>
|
||||
<span :class="$style.stepNumber">{{ tutorial + 1 }} / {{ tutorialsNumber }}</span>
|
||||
<button class="_button" :class="$style.stepArrow" :disabled="tutorial === tutorialsNumber - 1" @click="tutorial++">
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tutorial === 0" class="_content">
|
||||
<div>{{ i18n.ts._tutorial.step1_1 }}</div>
|
||||
<div>{{ i18n.ts._tutorial.step1_2 }}</div>
|
||||
|
|
@ -15,7 +26,7 @@
|
|||
<div>{{ i18n.ts._tutorial.step3_1 }}</div>
|
||||
<div>{{ i18n.ts._tutorial.step3_2 }}</div>
|
||||
<div>{{ i18n.ts._tutorial.step3_3 }}</div>
|
||||
<small>{{ i18n.ts._tutorial.step3_4 }}</small>
|
||||
<small :class="$style.small">{{ i18n.ts._tutorial.step3_4 }}</small>
|
||||
</div>
|
||||
<div v-else-if="tutorial === 3" class="_content">
|
||||
<div>{{ i18n.ts._tutorial.step4_1 }}</div>
|
||||
|
|
@ -32,7 +43,7 @@
|
|||
</template>
|
||||
</I18n>
|
||||
<div>{{ i18n.ts._tutorial.step5_3 }}</div>
|
||||
<small>{{ i18n.ts._tutorial.step5_4 }}</small>
|
||||
<small :class="$style.small">{{ i18n.ts._tutorial.step5_4 }}</small>
|
||||
</div>
|
||||
<div v-else-if="tutorial === 5" class="_content">
|
||||
<div>{{ i18n.ts._tutorial.step6_1 }}</div>
|
||||
|
|
@ -48,19 +59,20 @@
|
|||
</I18n>
|
||||
<div>{{ i18n.ts._tutorial.step7_3 }}</div>
|
||||
</div>
|
||||
<div v-else-if="tutorial === 7" class="_content">
|
||||
<div>{{ i18n.ts._tutorial.step8_1 }}</div>
|
||||
<div>{{ i18n.ts._tutorial.step8_2 }}</div>
|
||||
<small :class="$style.small">{{ i18n.ts._tutorial.step8_3 }}</small>
|
||||
</div>
|
||||
|
||||
<div class="_footer navigation">
|
||||
<div class="step">
|
||||
<button class="arrow _button" :disabled="tutorial === 0" @click="tutorial--">
|
||||
<i class="fas fa-chevron-left"></i>
|
||||
</button>
|
||||
<span>{{ tutorial + 1 }} / 7</span>
|
||||
<button class="arrow _button" :disabled="tutorial === 6" @click="tutorial++">
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<MkButton v-if="tutorial === 6" class="ok" primary @click="tutorial = -1"><i class="fas fa-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
||||
<MkButton v-else class="ok" primary @click="tutorial++"><i class="fas fa-check"></i> {{ i18n.ts.next }}</MkButton>
|
||||
<div class="_footer" :class="$style.footer">
|
||||
<template v-if="tutorial === tutorialsNumber - 1">
|
||||
<MkPushNotificationAllowButton :class="$style.footerItem" primary show-only-to-register @click="tutorial = -1" />
|
||||
<MkButton :class="$style.footerItem" :primary="false" @click="tutorial = -1">{{ i18n.ts.noThankYou }}</MkButton>
|
||||
</template>
|
||||
<template v-else>
|
||||
<MkButton :class="$style.footerItem" primary @click="tutorial++"><i class="fas fa-check"></i> {{ i18n.ts.next }}</MkButton>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -68,53 +80,63 @@
|
|||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
|
||||
import { defaultStore } from '@/store';
|
||||
import { i18n } from '@/i18n';
|
||||
|
||||
const tutorialsNumber = 8;
|
||||
|
||||
const tutorial = computed({
|
||||
get() { return defaultStore.reactiveState.tutorial.value || 0; },
|
||||
set(value) { defaultStore.set('tutorial', value); },
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tbkwesmv {
|
||||
> ._content {
|
||||
> small {
|
||||
opacity: 0.7;
|
||||
<style lang="scss" module>
|
||||
.small {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
&Text {
|
||||
margin: 4px 0;
|
||||
padding-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.step {
|
||||
margin-left: auto;
|
||||
|
||||
&Arrow {
|
||||
padding: 4px;
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
&:first-child {
|
||||
padding-right: 8px;
|
||||
}
|
||||
&:last-child {
|
||||
padding-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
> .navigation {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: baseline;
|
||||
&Number {
|
||||
font-weight: normal;
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
> .step {
|
||||
> .arrow {
|
||||
padding: 4px;
|
||||
.footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
justify-content: right;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
padding-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
> span {
|
||||
margin: 0 4px;
|
||||
}
|
||||
}
|
||||
|
||||
> .ok {
|
||||
margin-left: auto;
|
||||
}
|
||||
&Item {
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue