Merge remote-tracking branch 'misskey-dev/develop' into develop

# Conflicts:
#	package.json
This commit is contained in:
mattyatea 2023-09-15 14:49:25 +09:00
commit 5a06039153
451 changed files with 2638 additions and 2691 deletions

View file

@ -77,7 +77,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { } from 'vue';
import getPasswordStrength from 'syuilo-password-strength';
import { toUnicode } from 'punycode/';
import MkButton from './MkButton.vue';
import MkInput from './MkInput.vue';
@ -132,6 +131,30 @@ const shouldDisableSubmitting = $computed((): boolean => {
passwordRetypeState !== 'match';
});
function getPasswordStrength(source: string): number {
let strength = 0;
let power = 0.018;
//
if (/[a-zA-Z]/.test(source) && /[0-9]/.test(source)) {
power += 0.020;
}
//
if (/[a-z]/.test(source) && /[A-Z]/.test(source)) {
power += 0.015;
}
//
if (/[!\x22\#$%&@'()*+,-./_]/.test(source)) {
power += 0.02;
}
strength = power * source.length;
return Math.max(0, Math.min(1, strength));
}
function onChangeUsername(): void {
if (username === '') {
usernameState = null;

View file

@ -52,7 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<MkTextarea v-model="moderationNote" manualSave>
<template #label>Moderation note</template>
<template #label>{{ i18n.ts.moderationNote }}</template>
</MkTextarea>
<!--

View file

@ -96,7 +96,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="horizontal"><i class="ti ti-carousel-horizontal"></i> {{ i18n.ts.horizontal }}</option>
</MkRadios>
<MkButton @click="testNotification('client')">{{ i18n.ts._notification.checkNotificationBehavior }}</MkButton>
<MkButton @click="testNotification">{{ i18n.ts._notification.checkNotificationBehavior }}</MkButton>
</div>
</FormSection>
@ -176,6 +176,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { computed, ref, watch } from 'vue';
import * as Misskey from 'misskey-js';
import MkSwitch from '@/components/MkSwitch.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkRadios from '@/components/MkRadios.vue';
@ -192,7 +193,8 @@ import { unisonReload } from '@/scripts/unison-reload';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { miLocalStorage } from '@/local-storage';
import { testNotification } from '@/scripts/test-notification';
import { globalEvents } from '@/events';
import { claimAchievement } from '@/scripts/achievements';
const lang = ref(miLocalStorage.getItem('lang'));
const fontSize = ref(miLocalStorage.getItem('fontSize'));
@ -305,6 +307,32 @@ function removeEmojiIndex(lang: string) {
os.promiseDialog(main());
}
let smashCount = 0;
let smashTimer: number | null = null;
function testNotification(): void {
const notification: Misskey.entities.Notification = {
id: Math.random().toString(),
createdAt: new Date().toUTCString(),
isRead: false,
type: 'test',
};
globalEvents.emit('clientNotification', notification);
//
smashCount++;
if (smashCount >= 10) {
claimAchievement('smashTestNotificationButton');
smashCount = 0;
}
if (smashTimer) {
clearTimeout(smashTimer);
}
smashTimer = window.setTimeout(() => {
smashCount = 0;
}, 300);
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);

View file

@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</FormSection>
<FormSection>
<div class="_gaps_m">
<FormLink @click="testNotification('server')">{{ i18n.ts._notification.sendTestNotification }}</FormLink>
<FormLink @click="testNotification">{{ i18n.ts._notification.sendTestNotification }}</FormLink>
</div>
</FormSection>
<FormSection>
@ -46,7 +46,6 @@ import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import MkPushNotificationAllowButton from '@/components/MkPushNotificationAllowButton.vue';
import { notificationTypes } from '@/const';
import { testNotification } from '@/scripts/test-notification';
let allowButton = $shallowRef<InstanceType<typeof MkPushNotificationAllowButton>>();
let pushRegistrationInServer = $computed(() => allowButton?.pushRegistrationInServer);
@ -89,6 +88,10 @@ function onChangeSendReadMessage(v: boolean) {
});
}
function testNotification(): void {
os.api('notifications/test-notification');
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);

View file

@ -57,10 +57,10 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<div v-if="iAmModerator" class="moderationNote">
<MkTextarea v-if="editModerationNote || (moderationNote != null && moderationNote !== '')" v-model="moderationNote" manualSave>
<template #label>Moderation note</template>
<template #label>{{ i18n.ts.moderationNote }}</template>
</MkTextarea>
<div v-else>
<MkButton small @click="editModerationNote = true">Add moderation note</MkButton>
<MkButton small @click="editModerationNote = true">{{ i18n.ts.addModerationNote }}</MkButton>
</div>
</div>
<div v-if="isEditingMemo || memoDraft" class="memo" :class="{'no-memo': !memoDraft}">
@ -143,7 +143,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { defineAsyncComponent, computed, onMounted, onUnmounted, nextTick, watch } from 'vue';
import calcAge from 's-age';
import * as Misskey from 'misskey-js';
import MkNote from '@/components/MkNote.vue';
import MkFollowButton from '@/components/MkFollowButton.vue';
@ -167,6 +166,21 @@ import MkNotes from '@/components/MkNotes.vue';
import { api } from '@/os';
import { isFfVisibleForMe } from '@/scripts/isFfVisibleForMe';
function calcAge(birthdate: string): number {
const date = new Date(birthdate);
const now = new Date();
let yearDiff = now.getFullYear() - date.getFullYear();
const monthDiff = now.getMonth() - date.getMonth();
const pastDate = now.getDate() < date.getDate();
if (monthDiff < 0 || (monthDiff === 0 && pastDate)) {
yearDiff--;
}
return yearDiff;
}
const XPhotos = defineAsyncComponent(() => import('./index.photos.vue'));
const XActivity = defineAsyncComponent(() => import('./index.activity.vue'));

View file

@ -81,6 +81,7 @@ export const ACHIEVEMENT_TYPES = [
'setNameToSyuilo',
'cookieClicked',
'brainDiver',
'smashTestNotificationButton',
] as const;
export const ACHIEVEMENT_BADGES = {
@ -454,6 +455,11 @@ export const ACHIEVEMENT_BADGES = {
bg: 'linear-gradient(0deg, rgb(144, 224, 255), rgb(255, 168, 252))',
frame: 'bronze',
},
'smashTestNotificationButton': {
img: '/fluent-emoji/1f514.png',
bg: 'linear-gradient(0deg, rgb(187 183 59), rgb(255 143 77))',
frame: 'bronze',
},
/* @see <https://github.com/misskey-dev/misskey/pull/10365#discussion_r1155511107>
} as const satisfies Record<typeof ACHIEVEMENT_TYPES[number], {
img: string;

View file

@ -1,34 +0,0 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as Misskey from 'misskey-js';
import * as os from '@/os';
import { globalEvents } from '@/events';
/**
*
*
* - `client`
* - `server`
*
* @param type
*/
export function testNotification(type: 'client' | 'server'): void {
const notification: Misskey.entities.Notification = {
id: Math.random().toString(),
createdAt: new Date().toUTCString(),
isRead: false,
type: 'test',
};
switch (type) {
case 'server':
os.api('notifications/test-notification');
break;
case 'client':
globalEvents.emit('clientNotification', notification);
break;
}
}