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:
zyoshoka
2023-12-07 14:42:09 +09:00
committed by GitHub
parent e42c91dee7
commit 406b4bdbe7
277 changed files with 3353 additions and 3441 deletions

View File

@@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import { onMounted, shallowRef } from 'vue';
import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
@@ -26,7 +26,7 @@ const props = defineProps<{
isStacked: boolean;
}>();
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
const timeline = shallowRef<InstanceType<typeof MkTimeline>>();
onMounted(() => {
if (props.column.antennaId == null) {

View File

@@ -19,6 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { shallowRef } from 'vue';
import * as Misskey from 'misskey-js';
import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
@@ -32,8 +33,8 @@ const props = defineProps<{
isStacked: boolean;
}>();
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
let channel = $shallowRef<Misskey.entities.Channel>();
const timeline = shallowRef<InstanceType<typeof MkTimeline>>();
const channel = shallowRef<Misskey.entities.Channel>();
if (props.column.channelId == null) {
setChannel();
@@ -58,14 +59,14 @@ async function setChannel() {
}
async function post() {
if (!channel || channel.id !== props.column.channelId) {
channel = await os.api('channels/show', {
if (!channel.value || channel.value.id !== props.column.channelId) {
channel.value = await os.api('channels/show', {
channelId: props.column.channelId,
});
}
os.post({
channel,
channel: channel.value,
});
}

View File

@@ -42,7 +42,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onBeforeUnmount, onMounted, provide, watch } from 'vue';
import { onBeforeUnmount, onMounted, provide, watch, shallowRef, ref, computed } from 'vue';
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn, Column } from './deck-store';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
@@ -67,16 +67,16 @@ const emit = defineEmits<{
(ev: 'headerWheel', ctx: WheelEvent): void;
}>();
let body = $shallowRef<HTMLDivElement | null>();
const body = shallowRef<HTMLDivElement | null>();
let dragging = $ref(false);
watch($$(dragging), v => os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd'));
const dragging = ref(false);
watch(dragging, v => os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd'));
let draghover = $ref(false);
let dropready = $ref(false);
const draghover = ref(false);
const dropready = ref(false);
const isMainColumn = $computed(() => props.column.type === 'main');
const active = $computed(() => props.column.active !== false);
const isMainColumn = computed(() => props.column.type === 'main');
const active = computed(() => props.column.active !== false);
onMounted(() => {
os.deckGlobalEvents.on('column.dragStart', onOtherDragStart);
@@ -89,11 +89,11 @@ onBeforeUnmount(() => {
});
function onOtherDragStart() {
dropready = true;
dropready.value = true;
}
function onOtherDragEnd() {
dropready = false;
dropready.value = false;
}
function toggleActive() {
@@ -208,8 +208,8 @@ function onContextmenu(ev: MouseEvent) {
}
function goTop() {
if (body) {
body.scrollTo({
if (body.value) {
body.value.scrollTo({
top: 0,
behavior: 'smooth',
});
@@ -223,17 +223,17 @@ function onDragstart(ev) {
// Chromeのバグで、Dragstartハンドラ内ですぐにDOMを変更する(=リアクティブなプロパティを変更する)とDragが終了してしまう
// SEE: https://stackoverflow.com/questions/19639969/html5-dragend-event-firing-immediately
window.setTimeout(() => {
dragging = true;
dragging.value = true;
}, 10);
}
function onDragend(ev) {
dragging = false;
dragging.value = false;
}
function onDragover(ev) {
// 自分自身がドラッグされている場合
if (dragging) {
if (dragging.value) {
// 自分自身にはドロップさせない
ev.dataTransfer.dropEffect = 'none';
} else {
@@ -241,16 +241,16 @@ function onDragover(ev) {
ev.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none';
if (isDeckColumn) draghover = true;
if (isDeckColumn) draghover.value = true;
}
}
function onDragleave() {
draghover = false;
draghover.value = false;
}
function onDrop(ev) {
draghover = false;
draghover.value = false;
os.deckGlobalEvents.emit('column.dragEnd');
const id = ev.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_);

View File

@@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { } from 'vue';
import { ref } from 'vue';
import XColumn from './column.vue';
import { Column } from './deck-store.js';
import MkNotes from '@/components/MkNotes.vue';
@@ -30,11 +30,11 @@ const pagination = {
},
};
const tlComponent: InstanceType<typeof MkNotes> = $ref();
const tlComponent = ref<InstanceType<typeof MkNotes>>();
function reloadTimeline() {
return new Promise<void>((res) => {
tlComponent.pagingComponent?.reload().then(() => {
tlComponent.value.pagingComponent?.reload().then(() => {
res();
});
});

View File

@@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { watch } from 'vue';
import { watch, shallowRef, ref } from 'vue';
import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store';
import MkTimeline from '@/components/MkTimeline.vue';
@@ -26,14 +26,14 @@ const props = defineProps<{
isStacked: boolean;
}>();
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
const withRenotes = $ref(props.column.withRenotes ?? true);
const timeline = shallowRef<InstanceType<typeof MkTimeline>>();
const withRenotes = ref(props.column.withRenotes ?? true);
if (props.column.listId == null) {
setList();
}
watch($$(withRenotes), v => {
watch(withRenotes, v => {
updateColumn(props.column.id, {
withRenotes: v,
});
@@ -72,7 +72,7 @@ const menu = [
{
type: 'switch',
text: i18n.ts.showRenotes,
ref: $$(withRenotes),
ref: withRenotes,
},
];
</script>

View File

@@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { ComputedRef, provide, shallowRef } from 'vue';
import { ComputedRef, provide, shallowRef, ref } from 'vue';
import XColumn from './column.vue';
import { deckStore, Column } from '@/ui/deck/deck-store.js';
import * as os from '@/os.js';
@@ -35,11 +35,11 @@ defineProps<{
}>();
const contents = shallowRef<HTMLElement>();
let pageMetadata = $ref<null | ComputedRef<PageMetadata>>();
const pageMetadata = ref<null | ComputedRef<PageMetadata>>();
provide('router', mainRouter);
provideMetadataReceiver((info) => {
pageMetadata = info;
pageMetadata.value = info;
});
/*

View File

@@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { } from 'vue';
import { ref } from 'vue';
import XColumn from './column.vue';
import { Column } from './deck-store.js';
import MkNotes from '@/components/MkNotes.vue';
@@ -22,11 +22,11 @@ defineProps<{
isStacked: boolean;
}>();
const tlComponent: InstanceType<typeof MkNotes> = $ref();
const tlComponent = ref<InstanceType<typeof MkNotes>>();
function reloadTimeline() {
return new Promise<void>((res) => {
tlComponent.pagingComponent?.reload().then(() => {
tlComponent.value.pagingComponent?.reload().then(() => {
res();
});
});

View File

@@ -12,7 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { defineAsyncComponent } from 'vue';
import { defineAsyncComponent, shallowRef } from 'vue';
import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
import XNotifications from '@/components/MkNotifications.vue';
@@ -24,7 +24,7 @@ const props = defineProps<{
isStacked: boolean;
}>();
let notificationsComponent = $shallowRef<InstanceType<typeof XNotifications>>();
const notificationsComponent = shallowRef<InstanceType<typeof XNotifications>>();
function func() {
os.popup(defineAsyncComponent(() => import('@/components/MkNotificationSelectWindow.vue')), {

View File

@@ -14,7 +14,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import { onMounted, shallowRef } from 'vue';
import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
@@ -26,7 +26,7 @@ const props = defineProps<{
isStacked: boolean;
}>();
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
const timeline = shallowRef<InstanceType<typeof MkTimeline>>();
onMounted(() => {
if (props.column.roleId == null) {

View File

@@ -33,7 +33,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onMounted, watch } from 'vue';
import { onMounted, watch, ref, shallowRef } from 'vue';
import XColumn from './column.vue';
import { removeColumn, updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
@@ -47,28 +47,28 @@ const props = defineProps<{
isStacked: boolean;
}>();
let disabled = $ref(false);
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
const disabled = ref(false);
const timeline = shallowRef<InstanceType<typeof MkTimeline>>();
const isLocalTimelineAvailable = (($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable));
const isGlobalTimelineAvailable = (($i == null && instance.policies.gtlAvailable) || ($i != null && $i.policies.gtlAvailable));
const withRenotes = $ref(props.column.withRenotes ?? true);
const withReplies = $ref(props.column.withReplies ?? false);
const onlyFiles = $ref(props.column.onlyFiles ?? false);
const withRenotes = ref(props.column.withRenotes ?? true);
const withReplies = ref(props.column.withReplies ?? false);
const onlyFiles = ref(props.column.onlyFiles ?? false);
watch($$(withRenotes), v => {
watch(withRenotes, v => {
updateColumn(props.column.id, {
withRenotes: v,
});
});
watch($$(withReplies), v => {
watch(withReplies, v => {
updateColumn(props.column.id, {
withReplies: v,
});
});
watch($$(onlyFiles), v => {
watch(onlyFiles, v => {
updateColumn(props.column.id, {
onlyFiles: v,
});
@@ -78,7 +78,7 @@ onMounted(() => {
if (props.column.tl == null) {
setType();
} else if ($i) {
disabled = (
disabled.value = (
(!((instance.policies.ltlAvailable) || ($i.policies.ltlAvailable)) && ['local', 'social'].includes(props.column.tl)) ||
(!((instance.policies.gtlAvailable) || ($i.policies.gtlAvailable)) && ['global'].includes(props.column.tl)));
}
@@ -115,17 +115,17 @@ const menu = [{
}, {
type: 'switch',
text: i18n.ts.showRenotes,
ref: $$(withRenotes),
ref: withRenotes,
}, props.column.tl === 'local' || props.column.tl === 'social' ? {
type: 'switch',
text: i18n.ts.showRepliesToOthersInTimeline,
ref: $$(withReplies),
disabled: $$(onlyFiles),
ref: withReplies,
disabled: onlyFiles,
} : undefined, {
type: 'switch',
text: i18n.ts.fileAttachedOnly,
ref: $$(onlyFiles),
disabled: props.column.tl === 'local' || props.column.tl === 'social' ? $$(withReplies) : false,
ref: onlyFiles,
disabled: props.column.tl === 'local' || props.column.tl === 'social' ? withReplies : false,
}];
</script>

View File

@@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { } from 'vue';
import { ref } from 'vue';
import XColumn from './column.vue';
import { addColumnWidget, Column, removeColumnWidget, setColumnWidgets, updateColumnWidget } from './deck-store.js';
import XWidgets from '@/components/MkWidgets.vue';
@@ -26,7 +26,7 @@ const props = defineProps<{
isStacked: boolean;
}>();
let edit = $ref(false);
const edit = ref(false);
function addWidget(widget) {
addColumnWidget(props.column.id, widget);
@@ -45,7 +45,7 @@ function updateWidgets(widgets) {
}
function func() {
edit = !edit;
edit.value = !edit.value;
}
const menu = [{