refactor(frontend): 非推奨となったReactivity Transformを使わないように (#12539)
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
This commit is contained in:
@@ -68,7 +68,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, watch } from 'vue';
|
||||
import { computed, watch, ref } from 'vue';
|
||||
import MkPostForm from '@/components/MkPostForm.vue';
|
||||
import MkTimeline from '@/components/MkTimeline.vue';
|
||||
import XChannelFollowButton from '@/components/MkChannelFollowButton.vue';
|
||||
@@ -96,13 +96,13 @@ const props = defineProps<{
|
||||
channelId: string;
|
||||
}>();
|
||||
|
||||
let tab = $ref('overview');
|
||||
let channel = $ref(null);
|
||||
let favorited = $ref(false);
|
||||
let searchQuery = $ref('');
|
||||
let searchPagination = $ref();
|
||||
let searchKey = $ref('');
|
||||
const featuredPagination = $computed(() => ({
|
||||
const tab = ref('overview');
|
||||
const channel = ref(null);
|
||||
const favorited = ref(false);
|
||||
const searchQuery = ref('');
|
||||
const searchPagination = ref();
|
||||
const searchKey = ref('');
|
||||
const featuredPagination = computed(() => ({
|
||||
endpoint: 'notes/featured' as const,
|
||||
limit: 10,
|
||||
params: {
|
||||
@@ -111,30 +111,30 @@ const featuredPagination = $computed(() => ({
|
||||
}));
|
||||
|
||||
watch(() => props.channelId, async () => {
|
||||
channel = await os.api('channels/show', {
|
||||
channel.value = await os.api('channels/show', {
|
||||
channelId: props.channelId,
|
||||
});
|
||||
favorited = channel.isFavorited;
|
||||
if (favorited || channel.isFollowing) {
|
||||
tab = 'timeline';
|
||||
favorited.value = channel.value.isFavorited;
|
||||
if (favorited.value || channel.value.isFollowing) {
|
||||
tab.value = 'timeline';
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
function edit() {
|
||||
router.push(`/channels/${channel.id}/edit`);
|
||||
router.push(`/channels/${channel.value.id}/edit`);
|
||||
}
|
||||
|
||||
function openPostForm() {
|
||||
os.post({
|
||||
channel,
|
||||
channel: channel.value,
|
||||
});
|
||||
}
|
||||
|
||||
function favorite() {
|
||||
os.apiWithDialog('channels/favorite', {
|
||||
channelId: channel.id,
|
||||
channelId: channel.value.id,
|
||||
}).then(() => {
|
||||
favorited = true;
|
||||
favorited.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -145,38 +145,38 @@ async function unfavorite() {
|
||||
});
|
||||
if (confirm.canceled) return;
|
||||
os.apiWithDialog('channels/unfavorite', {
|
||||
channelId: channel.id,
|
||||
channelId: channel.value.id,
|
||||
}).then(() => {
|
||||
favorited = false;
|
||||
favorited.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
async function search() {
|
||||
const query = searchQuery.toString().trim();
|
||||
const query = searchQuery.value.toString().trim();
|
||||
|
||||
if (query == null) return;
|
||||
|
||||
searchPagination = {
|
||||
searchPagination.value = {
|
||||
endpoint: 'notes/search',
|
||||
limit: 10,
|
||||
params: {
|
||||
query: query,
|
||||
channelId: channel.id,
|
||||
channelId: channel.value.id,
|
||||
},
|
||||
};
|
||||
|
||||
searchKey = query;
|
||||
searchKey.value = query;
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => {
|
||||
if (channel && channel.userId) {
|
||||
const headerActions = computed(() => {
|
||||
if (channel.value && channel.value.userId) {
|
||||
const headerItems: PageHeaderItem[] = [];
|
||||
|
||||
headerItems.push({
|
||||
icon: 'ti ti-link',
|
||||
text: i18n.ts.copyUrl,
|
||||
handler: async (): Promise<void> => {
|
||||
copyToClipboard(`${url}/channels/${channel.id}`);
|
||||
copyToClipboard(`${url}/channels/${channel.value.id}`);
|
||||
os.success();
|
||||
},
|
||||
});
|
||||
@@ -187,15 +187,15 @@ const headerActions = $computed(() => {
|
||||
text: i18n.ts.share,
|
||||
handler: async (): Promise<void> => {
|
||||
navigator.share({
|
||||
title: channel.name,
|
||||
text: channel.description,
|
||||
url: `${url}/channels/${channel.id}`,
|
||||
title: channel.value.name,
|
||||
text: channel.value.description,
|
||||
url: `${url}/channels/${channel.value.id}`,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (($i && $i.id === channel.userId) || iAmModerator) {
|
||||
if (($i && $i.id === channel.value.userId) || iAmModerator) {
|
||||
headerItems.push({
|
||||
icon: 'ti ti-settings',
|
||||
text: i18n.ts.edit,
|
||||
@@ -209,7 +209,7 @@ const headerActions = $computed(() => {
|
||||
}
|
||||
});
|
||||
|
||||
const headerTabs = $computed(() => [{
|
||||
const headerTabs = computed(() => [{
|
||||
key: 'overview',
|
||||
title: i18n.ts.overview,
|
||||
icon: 'ti ti-info-circle',
|
||||
@@ -227,8 +227,8 @@ const headerTabs = $computed(() => [{
|
||||
icon: 'ti ti-search',
|
||||
}]);
|
||||
|
||||
definePageMetadata(computed(() => channel ? {
|
||||
title: channel.name,
|
||||
definePageMetadata(computed(() => channel.value ? {
|
||||
title: channel.value.name,
|
||||
icon: 'ti ti-device-tv',
|
||||
} : null));
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user