2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
2024-02-13 15:50:11 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
2023-07-27 05:31:52 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2023-05-19 11:52:15 +00:00
|
|
|
<MkSpacer :contentMax="700">
|
2023-05-14 01:21:56 +00:00
|
|
|
<div>
|
2023-01-06 04:40:17 +00:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 12:04:56 +00:00
|
|
|
<MkInput v-model="name">
|
|
|
|
<template #label>{{ i18n.ts.name }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkSelect v-model="src">
|
|
|
|
<template #label>{{ i18n.ts.antennaSource }}</template>
|
|
|
|
<option value="all">{{ i18n.ts._antennaSources.all }}</option>
|
|
|
|
<!--<option value="home">{{ i18n.ts._antennaSources.homeTimeline }}</option>-->
|
|
|
|
<option value="users">{{ i18n.ts._antennaSources.users }}</option>
|
|
|
|
<!--<option value="list">{{ i18n.ts._antennaSources.userList }}</option>-->
|
2023-09-22 07:52:43 +00:00
|
|
|
<option value="users_blacklist">{{ i18n.ts._antennaSources.userBlacklist }}</option>
|
2023-01-05 12:04:56 +00:00
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-if="src === 'list'" v-model="userListId">
|
|
|
|
<template #label>{{ i18n.ts.userList }}</template>
|
|
|
|
<option v-for="list in userLists" :key="list.id" :value="list.id">{{ list.name }}</option>
|
|
|
|
</MkSelect>
|
2023-09-22 07:52:43 +00:00
|
|
|
<MkTextarea v-else-if="src === 'users' || src === 'users_blacklist'" v-model="users">
|
2023-01-05 12:04:56 +00:00
|
|
|
<template #label>{{ i18n.ts.users }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ i18n.ts.addUser }}</button></template>
|
|
|
|
</MkTextarea>
|
|
|
|
<MkSwitch v-model="withReplies">{{ i18n.ts.withReplies }}</MkSwitch>
|
|
|
|
<MkTextarea v-model="keywords">
|
|
|
|
<template #label>{{ i18n.ts.antennaKeywords }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.antennaKeywordsDescription }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
<MkTextarea v-model="excludeKeywords">
|
|
|
|
<template #label>{{ i18n.ts.antennaExcludeKeywords }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.antennaKeywordsDescription }}</template>
|
|
|
|
</MkTextarea>
|
2023-10-16 06:06:00 +00:00
|
|
|
<MkSwitch v-model="localOnly">{{ i18n.ts.localOnly }}</MkSwitch>
|
2023-01-05 12:04:56 +00:00
|
|
|
<MkSwitch v-model="caseSensitive">{{ i18n.ts.caseSensitive }}</MkSwitch>
|
|
|
|
<MkSwitch v-model="withFile">{{ i18n.ts.withFileAntenna }}</MkSwitch>
|
|
|
|
<MkSwitch v-model="notify">{{ i18n.ts.notifyAntenna }}</MkSwitch>
|
|
|
|
</div>
|
2023-05-14 01:21:56 +00:00
|
|
|
<div :class="$style.actions">
|
2023-01-05 12:04:56 +00:00
|
|
|
<MkButton inline primary @click="saveAntenna()"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
|
|
|
<MkButton v-if="antenna.id != null" inline danger @click="deleteAntenna()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2023-01-05 12:04:56 +00:00
|
|
|
</MkSpacer>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { watch, ref } from 'vue';
|
2023-09-04 04:33:38 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-01-07 06:09:46 +00:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
2023-01-07 05:59:54 +00:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
const props = defineProps<{
|
2023-12-26 05:19:35 +00:00
|
|
|
antenna: Misskey.entities.Antenna
|
2022-05-25 07:37:15 +00:00
|
|
|
}>();
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'created'): void,
|
|
|
|
(ev: 'updated'): void,
|
|
|
|
(ev: 'deleted'): void,
|
|
|
|
}>();
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const name = ref<string>(props.antenna.name);
|
2023-12-26 05:19:35 +00:00
|
|
|
const src = ref<Misskey.entities.AntennasCreateRequest['src']>(props.antenna.src);
|
|
|
|
const userListId = ref<string | null>(props.antenna.userListId);
|
2023-12-07 05:42:09 +00:00
|
|
|
const users = ref<string>(props.antenna.users.join('\n'));
|
|
|
|
const keywords = ref<string>(props.antenna.keywords.map(x => x.join(' ')).join('\n'));
|
|
|
|
const excludeKeywords = ref<string>(props.antenna.excludeKeywords.map(x => x.join(' ')).join('\n'));
|
|
|
|
const caseSensitive = ref<boolean>(props.antenna.caseSensitive);
|
|
|
|
const localOnly = ref<boolean>(props.antenna.localOnly);
|
|
|
|
const withReplies = ref<boolean>(props.antenna.withReplies);
|
|
|
|
const withFile = ref<boolean>(props.antenna.withFile);
|
|
|
|
const notify = ref<boolean>(props.antenna.notify);
|
2023-12-26 05:19:35 +00:00
|
|
|
const userLists = ref<Misskey.entities.UserList[] | null>(null);
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
watch(() => src.value, async () => {
|
|
|
|
if (src.value === 'list' && userLists.value === null) {
|
2024-01-04 09:32:46 +00:00
|
|
|
userLists.value = await misskeyApi('users/lists/list');
|
2022-05-25 07:37:15 +00:00
|
|
|
}
|
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
async function saveAntenna() {
|
|
|
|
const antennaData = {
|
2023-12-07 05:42:09 +00:00
|
|
|
name: name.value,
|
|
|
|
src: src.value,
|
|
|
|
userListId: userListId.value,
|
|
|
|
withReplies: withReplies.value,
|
|
|
|
withFile: withFile.value,
|
|
|
|
notify: notify.value,
|
|
|
|
caseSensitive: caseSensitive.value,
|
|
|
|
localOnly: localOnly.value,
|
|
|
|
users: users.value.trim().split('\n').map(x => x.trim()),
|
|
|
|
keywords: keywords.value.trim().split('\n').map(x => x.trim().split(' ')),
|
|
|
|
excludeKeywords: excludeKeywords.value.trim().split('\n').map(x => x.trim().split(' ')),
|
2022-05-25 07:37:15 +00:00
|
|
|
};
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
if (props.antenna.id == null) {
|
|
|
|
await os.apiWithDialog('antennas/create', antennaData);
|
|
|
|
emit('created');
|
|
|
|
} else {
|
2023-12-26 05:19:35 +00:00
|
|
|
await os.apiWithDialog('antennas/update', { ...antennaData, antennaId: props.antenna.id });
|
2022-05-25 07:37:15 +00:00
|
|
|
emit('updated');
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
async function deleteAntenna() {
|
|
|
|
const { canceled } = await os.confirm({
|
|
|
|
type: 'warning',
|
2024-01-19 23:11:59 +00:00
|
|
|
text: i18n.tsx.removeAreYouSure({ x: props.antenna.name }),
|
2022-05-25 07:37:15 +00:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2024-01-04 09:32:46 +00:00
|
|
|
await misskeyApi('antennas/delete', {
|
2022-05-25 07:37:15 +00:00
|
|
|
antennaId: props.antenna.id,
|
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
os.success();
|
|
|
|
emit('deleted');
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-05-25 07:37:15 +00:00
|
|
|
function addUser() {
|
2024-02-02 07:49:09 +00:00
|
|
|
os.selectUser({ includeSelf: true }).then(user => {
|
2023-12-07 05:42:09 +00:00
|
|
|
users.value = users.value.trim();
|
|
|
|
users.value += '\n@' + Misskey.acct.toString(user as any);
|
|
|
|
users.value = users.value.trim();
|
2022-05-25 07:37:15 +00:00
|
|
|
});
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
</script>
|
|
|
|
|
2023-05-14 01:21:56 +00:00
|
|
|
<style lang="scss" module>
|
|
|
|
.actions {
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 24px 0;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
</style>
|