Compare commits

..

No commits in common. "e6d3693fb0d10098cdb7e47ff849ec078829e76c" and "bc7fd1fa467efdd0e6d565d756749b6af096f4df" have entirely different histories.

3 changed files with 49 additions and 61 deletions

View File

@ -12,7 +12,7 @@ import { GlobalEventService } from '@/core/GlobalEventService.js';
import * as Acct from '@/misc/acct.js';
import type { Packed } from '@/misc/json-schema.js';
import { DI } from '@/di-symbols.js';
import type { AntennasRepository, UserListMembershipsRepository, FollowingsRepository } from '@/models/_.js';
import type { AntennasRepository, UserListMembershipsRepository } from '@/models/_.js';
import { UtilityService } from '@/core/UtilityService.js';
import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
@ -37,9 +37,6 @@ export class AntennaService implements OnApplicationShutdown {
@Inject(DI.userListMembershipsRepository)
private userListMembershipsRepository: UserListMembershipsRepository,
@Inject(DI.followingsRepository)
private followingsRepository: FollowingsRepository,
private utilityService: UtilityService,
private globalEventService: GlobalEventService,
private fanoutTimelineService: FanoutTimelineService,
@ -114,22 +111,8 @@ export class AntennaService implements OnApplicationShutdown {
@bindThis
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; isBot: boolean; }): Promise<boolean> {
if (note.visibility === 'specified') {
if (note.userId !== antenna.userId) {
if (note.visibleUserIds == null) return false;
if (!note.visibleUserIds.includes(antenna.userId)) return false;
}
}
if (note.visibility === 'followers') {
const isFollowing = await this.followingsRepository.count({
where: {
followerId: antenna.userId,
followeeId: note.userId,
},
take: 1,
}).then(n => n > 0);
if (!isFollowing && antenna.userId !== note.userId) return false;
}
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') return false;
if (antenna.excludeBots && noteUser.isBot) return false;

View File

@ -6,25 +6,25 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<button
class="_button"
:class="[$style.root, { [$style.wait]: wait, [$style.active]: userDetailed.isFollowing || userDetailed.hasPendingFollowRequestFromYou, [$style.full]: full, [$style.large]: large }]"
:class="[$style.root, { [$style.wait]: wait, [$style.active]: isFollowing || hasPendingFollowRequestFromYou, [$style.full]: full, [$style.large]: large }]"
:disabled="wait"
@click="onClick"
>
<template v-if="!wait">
<template v-if="userDetailed.hasPendingFollowRequestFromYou && userDetailed.isLocked">
<template v-if="hasPendingFollowRequestFromYou && user.isLocked">
<span v-if="full" :class="$style.text">{{ i18n.ts.followRequestPending }}</span><i class="ti ti-hourglass-empty"></i>
</template>
<template v-else-if="userDetailed.hasPendingFollowRequestFromYou && !userDetailed.isLocked">
<template v-else-if="hasPendingFollowRequestFromYou && !user.isLocked">
<!-- つまりリモートフォローの場合 -->
<span v-if="full" :class="$style.text">{{ i18n.ts.processing }}</span><MkLoading :em="true" :colored="false"/>
</template>
<template v-else-if="userDetailed.isFollowing">
<span v-if="full" :class="$style.text">{{ i18n.ts.unfollow }}</span><i class="ti ti-minus"></i>
<template v-else-if="isFollowing">
<span v-if="full" :class="$style.text">{{ i18n.ts.youFollowing }}</span><i class="ti ti-minus"></i>
</template>
<template v-else-if="!userDetailed.isFollowing && userDetailed.isLocked">
<template v-else-if="!isFollowing && user.isLocked">
<span v-if="full" :class="$style.text">{{ i18n.ts.followRequest }}</span><i class="ti ti-plus"></i>
</template>
<template v-else-if="!userDetailed.isFollowing && !userDetailed.isLocked">
<template v-else-if="!isFollowing && !user.isLocked">
<span v-if="full" :class="$style.text">{{ i18n.ts.follow }}</span><i class="ti ti-plus"></i>
</template>
</template>
@ -48,7 +48,7 @@ import { $i } from '@/account.js';
import { defaultStore } from '@/store.js';
const props = withDefaults(defineProps<{
user: { id: string } & Partial<Misskey.entities.UserDetailed>,
user: Misskey.entities.UserDetailed,
full?: boolean,
large?: boolean,
}>(), {
@ -56,27 +56,26 @@ const props = withDefaults(defineProps<{
large: false,
});
const emit = defineEmits<
(_: 'update:user', value: Misskey.entities.UserDetailed) => void
>();
const emit = defineEmits<{
(_: 'update:user', value: Misskey.entities.UserDetailed): void
}>();
const userDetailed = ref<{ id: string } & Partial<Misskey.entities.UserDetailed>>(props.user);
const wait = ref(props.user.isLocked === undefined);
const isFollowing = ref(props.user.isFollowing);
const hasPendingFollowRequestFromYou = ref(props.user.hasPendingFollowRequestFromYou);
const wait = ref(false);
const connection = useStream().useChannel('main');
if (userDetailed.value.isLocked === undefined) {
if (props.user.isFollowing == null && $i) {
misskeyApi('users/show', {
userId: props.user.id,
})
.then(onFollowChange)
.then(() => {
wait.value = false;
});
.then(onFollowChange);
}
function onFollowChange(user: Misskey.entities.UserDetailed) {
if (user.id === props.user.id) {
userDetailed.value = user;
isFollowing.value = user.isFollowing;
hasPendingFollowRequestFromYou.value = user.hasPendingFollowRequestFromYou;
}
}
@ -86,10 +85,10 @@ async function onClick() {
wait.value = true;
try {
if (userDetailed.value.isFollowing) {
if (isFollowing.value) {
const { canceled } = await os.confirm({
type: 'warning',
text: i18n.tsx.unfollowConfirm({ name: (userDetailed.value.name || userDetailed.value.username) ?? i18n.ts.user }),
text: i18n.tsx.unfollowConfirm({ name: props.user.name || props.user.username }),
});
if (canceled) return;
@ -110,37 +109,37 @@ async function onClick() {
}
}
if (userDetailed.value.hasPendingFollowRequestFromYou) {
if (hasPendingFollowRequestFromYou.value) {
await misskeyApi('following/requests/cancel', {
userId: props.user.id,
});
userDetailed.value.hasPendingFollowRequestFromYou = false;
hasPendingFollowRequestFromYou.value = false;
} else {
await misskeyApi('following/create', {
userId: props.user.id,
withReplies: defaultStore.state.defaultWithReplies,
});
emit('update:user', {
...userDetailed.value,
...props.user,
withReplies: defaultStore.state.defaultWithReplies,
});
userDetailed.value.hasPendingFollowRequestFromYou = true;
hasPendingFollowRequestFromYou.value = true;
if ($i) {
claimAchievement('following1');
if ($i == null) return;
if ($i.followingCount >= 10) {
claimAchievement('following10');
}
if ($i.followingCount >= 50) {
claimAchievement('following50');
}
if ($i.followingCount >= 100) {
claimAchievement('following100');
}
if ($i.followingCount >= 300) {
claimAchievement('following300');
}
claimAchievement('following1');
if ($i.followingCount >= 10) {
claimAchievement('following10');
}
if ($i.followingCount >= 50) {
claimAchievement('following50');
}
if ($i.followingCount >= 100) {
claimAchievement('following100');
}
if ($i.followingCount >= 300) {
claimAchievement('following300');
}
}
}
@ -193,6 +192,14 @@ onBeforeUnmount(() => {
outline-offset: 2px;
}
&:hover {
//background: mix($primary, #fff, 20);
}
&:active {
//background: mix($primary, #fff, 40);
}
&.active {
color: var(--fgOnAccent);
background: var(--accent);

View File

@ -113,7 +113,6 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkA>
<template v-else-if="notification.type === 'follow'">
<span :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.youGotNewFollower }}</span>
<div v-if="full"><MkFollowButton :user="notification.user" :full="true"/></div>
</template>
<template v-else-if="notification.type === 'unfollow'">
<span :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.youGotUnFollower }}</span>
@ -172,7 +171,6 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import MkReactionIcon from '@/components/MkReactionIcon.vue';
import MkFollowButton from '@/components/MkFollowButton.vue';
import MkButton from '@/components/MkButton.vue';
import { getNoteSummary } from '@/scripts/get-note-summary.js';
import { notePage } from '@/filters/note.js';