summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-02-26 20:21:54 +0900
committerGitHub <noreply@github.com>2023-02-26 20:21:54 +0900
commit02c8fd9de51b6a8471ab9a89f23bcfeaecd7626c (patch)
tree018a46cad9a19cc8cdfcff91442b343a637b56f8 /packages/frontend/src/scripts
parentMerge pull request #10058 from misskey-dev/develop (diff)
parentMerge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff)
downloadmisskey-02c8fd9de51b6a8471ab9a89f23bcfeaecd7626c.tar.gz
misskey-02c8fd9de51b6a8471ab9a89f23bcfeaecd7626c.tar.bz2
misskey-02c8fd9de51b6a8471ab9a89f23bcfeaecd7626c.zip
Merge pull request #10108 from misskey-dev/develop
* Add dialog to remove follower (#9718) * update PULL_REQUEST_TEMPLATE * 起動時にRedisの疎通確認を行う (#9832) * 起動時にRedisの疎通確認を行う * check:connectをstart内に移動 --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp> * Pass `--detectOpenHandles` to Jest (#9895) Co-authored-by: tamaina <tamaina@hotmail.co.jp> * enhance(client): MkUrlPreviewの閉じるボタンを見やすく (#9913) Co-authored-by: tamaina <tamaina@hotmail.co.jp> * test(backend): restore ap-request tests (#9997) Co-authored-by: tamaina <tamaina@hotmail.co.jp> * fix/refaftor(client): MkTime.vueの変更 (#10061) * fix(client): MkTime.timeにstringでもDateでない値が入った場合、?を表示 * fix(client): MkTimeを改良 * numberを許容 * falsyな値もとる * 不明 * ありません * fix * fix(server): notes/createで、fileIdsと見つかったファイルの数が異なる場合はエラーにする (#9911) * fix(server): notes/createで、fileIdsと見つかったファイルの数が異なる場合はエラーにする * NO_SUCH_FILE * Update codecov.yml * Update apple-touch-icon.png * デプロイされているプレビュー環境がない場合はプレビュー環境を削除しないようにする (#10062) * デプロイされているプレビュー環境がない場合はDestroy preview environmentを実行しないようにする * CIがない場合の処理追加 * enhance(client): improve clip menu ux * 未知のユーザーが deleteActor されたら処理をスキップする (#10067) * fix(client): Android ChromeでPWAとしてインストールできない問題を修正 (#10069) * fix(client): Android ChromeでPWAとしてインストールできない問題を修正 * 順番関係ある? * Windows環境でswcを使うと正常にビルドができない問題の修正 (#10074) * Update @swc/core to v1.3.36 * Update CHANGELOG.md * Update CHANGELOG.md * バックグラウンドで一定時間経過したらページネーションのアイテム更新をしない (#10053) * :art: * feat: 2つの検索画面の統合 (#9949) (#10038) * feat: 検索画面の UI を統一 * fix: エラーの修正 * add: changelog --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * enhance(client): ノートメニューからユーザーメニューを開けるように Resolve #10019 * enhance(client): renoteした際の表示を改善 Resolve #10078 * Update CHANGELOG.md * enhance(client): tweak contextmenu position calculation * :art: * :art: * feat: in-channel featured note Resolve #9938 * refactor(frontend): fix eslint error (#10084) * Simplify search.vue (remove dead code) (#10088) * Simplify search.vue This is already handled by the code above it, no need to handle it twice * Remove unused imports * Update about-misskey.vue * test(server): add validation test of api:notes/create (#10090) * fix(server): notes/createのバリデーションが効いていない Fix #10079 Co-Authored-By: mei23 <m@m544.net> * anyOf内にバリデーションを書いても最初の一つしかチェックされない * :v: * wip * wip * :v: * RequiredProp * Revert "RequiredProp" This reverts commit 74693900119a590263106fa3adefd008d69ce80c. * add api:notes/create * fix lint * text * :v: * improve readability --------- Co-authored-by: mei23 <m@m544.net> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * New Crowdin updates (#10059) * New translations ja-JP.yml (Japanese, Kansai) * New translations ja-JP.yml (Romanian) * New translations ja-JP.yml (French) * New translations ja-JP.yml (Spanish) * New translations ja-JP.yml (Arabic) * New translations ja-JP.yml (Czech) * New translations ja-JP.yml (German) * New translations ja-JP.yml (Italian) * New translations ja-JP.yml (Korean) * New translations ja-JP.yml (Polish) * New translations ja-JP.yml (Russian) * New translations ja-JP.yml (Slovak) * New translations ja-JP.yml (Ukrainian) * New translations ja-JP.yml (Chinese Simplified) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (English) * New translations ja-JP.yml (Vietnamese) * New translations ja-JP.yml (Indonesian) * New translations ja-JP.yml (Bengali) * New translations ja-JP.yml (Thai) * New translations ja-JP.yml (Japanese, Kansai) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (Chinese Traditional) * New translations ja-JP.yml (German) * New translations ja-JP.yml (English) * New translations ja-JP.yml (German) * New translations ja-JP.yml (Ukrainian) * New translations ja-JP.yml (Chinese Simplified) * New translations ja-JP.yml (English) * New translations ja-JP.yml (Ukrainian) * New translations ja-JP.yml (Ukrainian) * New translations ja-JP.yml (Ukrainian) * New translations ja-JP.yml (Chinese Simplified) * New translations ja-JP.yml (Japanese, Kansai) * New translations ja-JP.yml (Thai) * New translations ja-JP.yml (Thai) * New translations ja-JP.yml (Thai) * New translations ja-JP.yml (Spanish) * New translations ja-JP.yml (Spanish) * enhance(client): improve user menu ux * enhance(client): photoswipe 表示時に戻る操作をしても前の画面に戻らないように (#10098) * enhance(client): photoswipe 表示時に戻る操作をしても前の画面に戻らないように * add: changelog --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * enhance(client): メニューの「もっと」からインスタンス情報を見れるように * [Fix] fixed an typo in error message (#10102) * Update codecov.yml * Update CHANGELOG.md * fix(server): エラーのスタックトレースは返さないように Fix #10064 * [chore]Editorconfig: ymlに加えてyamlファイルに対しても同じ規約を適用する (#10081) * Added yaml file in addition to yml file, in editorconfig * Applied editorconfig for pnpm-workspace.yaml --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * update deps * ホームタイムラインの読み込みでクエリタイムアウトになるのを修正する (#10106) * refactor * New translations ja-JP.yml (French) (#10103) * Update CHANGELOG.md * 13.8.0 --------- Co-authored-by: atsuchan <83960488+atsu1125@users.noreply.github.com> Co-authored-by: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Co-authored-by: tamaina <tamaina@hotmail.co.jp> Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com> Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> Co-authored-by: xianon <xianon@hotmail.co.jp> Co-authored-by: kabo2468 <28654659+kabo2468@users.noreply.github.com> Co-authored-by: YS <47836716+yszkst@users.noreply.github.com> Co-authored-by: Khsmty <me@khsmty.com> Co-authored-by: Soni L <EnderMoneyMod@gmail.com> Co-authored-by: mei23 <m@m544.net> Co-authored-by: daima3629 <52790780+daima3629@users.noreply.github.com> Co-authored-by: Windymelt <1113940+windymelt@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/get-note-menu.ts130
-rw-r--r--packages/frontend/src/scripts/get-user-menu.ts87
-rw-r--r--packages/frontend/src/scripts/search.ts63
-rw-r--r--packages/frontend/src/scripts/use-document-visibility.ts19
4 files changed, 125 insertions, 174 deletions
diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts
index 9da7447bfd..9c0ff3d1b2 100644
--- a/packages/frontend/src/scripts/get-note-menu.ts
+++ b/packages/frontend/src/scripts/get-note-menu.ts
@@ -9,6 +9,7 @@ import copyToClipboard from '@/scripts/copy-to-clipboard';
import { url } from '@/config';
import { noteActions } from '@/store';
import { miLocalStorage } from '@/local-storage';
+import { getUserMenu } from '@/scripts/get-user-menu';
export function getNoteMenu(props: {
note: misskey.entities.Note;
@@ -99,66 +100,6 @@ export function getNoteMenu(props: {
});
}
- async function clip(): Promise<void> {
- const clips = await os.api('clips/list');
- os.popupMenu([{
- icon: 'ti ti-plus',
- text: i18n.ts.createNew,
- action: async () => {
- const { canceled, result } = await os.form(i18n.ts.createNewClip, {
- name: {
- type: 'string',
- label: i18n.ts.name,
- },
- description: {
- type: 'string',
- required: false,
- multiline: true,
- label: i18n.ts.description,
- },
- isPublic: {
- type: 'boolean',
- label: i18n.ts.public,
- default: false,
- },
- });
- if (canceled) return;
-
- const clip = await os.apiWithDialog('clips/create', result);
-
- claimAchievement('noteClipped1');
- os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: appearNote.id });
- },
- }, null, ...clips.map(clip => ({
- text: clip.name,
- action: () => {
- claimAchievement('noteClipped1');
- os.promiseDialog(
- os.api('clips/add-note', { clipId: clip.id, noteId: appearNote.id }),
- null,
- async (err) => {
- if (err.id === '734806c4-542c-463a-9311-15c512803965') {
- const confirm = await os.confirm({
- type: 'warning',
- text: i18n.t('confirmToUnclipAlreadyClippedNote', { name: clip.name }),
- });
- if (!confirm.canceled) {
- os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id });
- if (props.currentClipPage?.value.id === clip.id) props.isDeleted.value = true;
- }
- } else {
- os.alert({
- type: 'error',
- text: err.message + '\n' + err.id,
- });
- }
- },
- );
- },
- }))], props.menuButton.value, {
- }).then(focus);
- }
-
async function unclip(): Promise<void> {
os.apiWithDialog('clips/remove-note', { clipId: props.currentClipPage.value.id, noteId: appearNote.id });
props.isDeleted.value = true;
@@ -264,9 +205,67 @@ export function getNoteMenu(props: {
action: () => toggleFavorite(true),
}),
{
+ type: 'parent',
icon: 'ti ti-paperclip',
text: i18n.ts.clip,
- action: () => clip(),
+ children: async () => {
+ const clips = await os.api('clips/list');
+ return [{
+ icon: 'ti ti-plus',
+ text: i18n.ts.createNew,
+ action: async () => {
+ const { canceled, result } = await os.form(i18n.ts.createNewClip, {
+ name: {
+ type: 'string',
+ label: i18n.ts.name,
+ },
+ description: {
+ type: 'string',
+ required: false,
+ multiline: true,
+ label: i18n.ts.description,
+ },
+ isPublic: {
+ type: 'boolean',
+ label: i18n.ts.public,
+ default: false,
+ },
+ });
+ if (canceled) return;
+
+ const clip = await os.apiWithDialog('clips/create', result);
+
+ claimAchievement('noteClipped1');
+ os.apiWithDialog('clips/add-note', { clipId: clip.id, noteId: appearNote.id });
+ },
+ }, null, ...clips.map(clip => ({
+ text: clip.name,
+ action: () => {
+ claimAchievement('noteClipped1');
+ os.promiseDialog(
+ os.api('clips/add-note', { clipId: clip.id, noteId: appearNote.id }),
+ null,
+ async (err) => {
+ if (err.id === '734806c4-542c-463a-9311-15c512803965') {
+ const confirm = await os.confirm({
+ type: 'warning',
+ text: i18n.t('confirmToUnclipAlreadyClippedNote', { name: clip.name }),
+ });
+ if (!confirm.canceled) {
+ os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id });
+ if (props.currentClipPage?.value.id === clip.id) props.isDeleted.value = true;
+ }
+ } else {
+ os.alert({
+ type: 'error',
+ text: err.message + '\n' + err.id,
+ });
+ }
+ },
+ );
+ },
+ }))];
+ },
},
statePromise.then(state => state.isMutedThread ? {
icon: 'ti ti-message-off',
@@ -286,6 +285,15 @@ export function getNoteMenu(props: {
text: i18n.ts.pin,
action: () => togglePin(true),
} : undefined,
+ appearNote.userId !== $i.id ? {
+ type: 'parent',
+ icon: 'ti ti-user',
+ text: i18n.ts.user,
+ children: async () => {
+ const user = await os.api('users/show', { userId: appearNote.userId });
+ return getUserMenu(user);
+ },
+ } : undefined,
/*
...($i.isModerator || $i.isAdmin ? [
null,
diff --git a/packages/frontend/src/scripts/get-user-menu.ts b/packages/frontend/src/scripts/get-user-menu.ts
index 557b257f62..6c6baf8266 100644
--- a/packages/frontend/src/scripts/get-user-menu.ts
+++ b/packages/frontend/src/scripts/get-user-menu.ts
@@ -1,4 +1,5 @@
import { defineAsyncComponent } from 'vue';
+import * as misskey from 'misskey-js';
import { i18n } from '@/i18n';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import { host } from '@/config';
@@ -8,32 +9,9 @@ import { $i, iAmModerator } from '@/account';
import { mainRouter } from '@/router';
import { Router } from '@/nirax';
-export function getUserMenu(user, router: Router = mainRouter) {
+export function getUserMenu(user: misskey.entities.UserDetailed, router: Router = mainRouter) {
const meId = $i ? $i.id : null;
- async function pushList() {
- const t = i18n.ts.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく
- const lists = await os.api('users/lists/list');
- if (lists.length === 0) {
- os.alert({
- type: 'error',
- text: i18n.ts.youHaveNoLists,
- });
- return;
- }
- const { canceled, result: listId } = await os.select({
- title: t,
- items: lists.map(list => ({
- value: list.id, text: list.name,
- })),
- });
- if (canceled) return;
- os.apiWithDialog('users/lists/push', {
- listId: listId,
- userId: user.id,
- });
- }
-
async function toggleMute() {
if (user.isMuted) {
os.apiWithDialog('mute/delete', {
@@ -102,6 +80,8 @@ export function getUserMenu(user, router: Router = mainRouter) {
}
async function invalidateFollow() {
+ if (!await getConfirmed(i18n.ts.breakFollowConfirm)) return;
+
os.apiWithDialog('following/invalidate', {
userId: user.id,
}).then(() => {
@@ -113,7 +93,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
icon: 'ti ti-at',
text: i18n.ts.copyUsername,
action: () => {
- copyToClipboard(`@${user.username}@${user.host || host}`);
+ copyToClipboard(`@${user.username}@${user.host ?? host}`);
},
}, {
icon: 'ti ti-info-circle',
@@ -134,12 +114,43 @@ export function getUserMenu(user, router: Router = mainRouter) {
os.post({ specified: user });
},
}, null, {
+ type: 'parent',
icon: 'ti ti-list',
text: i18n.ts.addToList,
- action: pushList,
+ children: async () => {
+ const lists = await os.api('users/lists/list');
+
+ return lists.map(list => ({
+ text: list.name,
+ action: () => {
+ os.apiWithDialog('users/lists/push', {
+ listId: list.id,
+ userId: user.id,
+ });
+ },
+ }));
+ },
}] as any;
if ($i && meId !== user.id) {
+ if (iAmModerator) {
+ menu = menu.concat([{
+ type: 'parent',
+ icon: 'ti ti-badges',
+ text: i18n.ts.roles,
+ children: async () => {
+ const roles = await os.api('admin/roles/list');
+
+ return roles.filter(r => r.target === 'manual').map(r => ({
+ text: r.name,
+ action: () => {
+ os.apiWithDialog('admin/roles/assign', { roleId: r.id, userId: user.id });
+ },
+ }));
+ },
+ }]);
+ }
+
menu = menu.concat([null, {
icon: user.isMuted ? 'ti ti-eye' : 'ti ti-eye-off',
text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute,
@@ -163,30 +174,6 @@ export function getUserMenu(user, router: Router = mainRouter) {
text: i18n.ts.reportAbuse,
action: reportAbuse,
}]);
-
- if (iAmModerator) {
- menu = menu.concat([null, {
- icon: 'ti ti-user-exclamation',
- text: i18n.ts.moderation,
- action: () => {
- router.push('/user-info/' + user.id + '#moderation');
- },
- }, {
- icon: 'ti ti-badges',
- text: i18n.ts.roles,
- action: async () => {
- const roles = await os.api('admin/roles/list');
-
- const { canceled, result: roleId } = await os.select({
- title: i18n.ts._role.chooseRoleToAssign,
- items: roles.map(r => ({ text: r.name, value: r.id })),
- });
- if (canceled) return;
-
- await os.apiWithDialog('admin/roles/assign', { roleId, userId: user.id });
- },
- }]);
- }
}
if ($i && meId === user.id) {
diff --git a/packages/frontend/src/scripts/search.ts b/packages/frontend/src/scripts/search.ts
deleted file mode 100644
index 69f1586b77..0000000000
--- a/packages/frontend/src/scripts/search.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import * as os from '@/os';
-import { i18n } from '@/i18n';
-import { mainRouter } from '@/router';
-
-export async function search() {
- const { canceled, result: query } = await os.inputText({
- title: i18n.ts.search,
- });
- if (canceled || query == null || query === '') return;
-
- const q = query.trim();
-
- if (q.startsWith('@') && !q.includes(' ')) {
- mainRouter.push(`/${q}`);
- return;
- }
-
- if (q.startsWith('#')) {
- mainRouter.push(`/tags/${encodeURIComponent(q.substr(1))}`);
- return;
- }
-
- // like 2018/03/12
- if (/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(q.replace(/-/g, '/'))) {
- const date = new Date(q.replace(/-/g, '/'));
-
- // 日付しか指定されてない場合、例えば 2018/03/12 ならユーザーは
- // 2018/03/12 のコンテンツを「含む」結果になることを期待するはずなので
- // 23時間59分進める(そのままだと 2018/03/12 00:00:00 「まで」の
- // 結果になってしまい、2018/03/12 のコンテンツは含まれない)
- if (q.replace(/-/g, '/').match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/)) {
- date.setHours(23, 59, 59, 999);
- }
-
- // TODO
- //v.$root.$emit('warp', date);
- os.alert({
- icon: 'ti ti-history',
- iconOnly: true, autoClose: true,
- });
- return;
- }
-
- if (q.startsWith('https://')) {
- const promise = os.api('ap/show', {
- uri: q,
- });
-
- os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
-
- const res = await promise;
-
- if (res.type === 'User') {
- mainRouter.push(`/@${res.object.username}@${res.object.host}`);
- } else if (res.type === 'Note') {
- mainRouter.push(`/notes/${res.object.id}`);
- }
-
- return;
- }
-
- mainRouter.push(`/search?q=${encodeURIComponent(q)}`);
-}
diff --git a/packages/frontend/src/scripts/use-document-visibility.ts b/packages/frontend/src/scripts/use-document-visibility.ts
new file mode 100644
index 0000000000..47e91dd937
--- /dev/null
+++ b/packages/frontend/src/scripts/use-document-visibility.ts
@@ -0,0 +1,19 @@
+import { onMounted, onUnmounted, ref, Ref } from 'vue';
+
+export function useDocumentVisibility(): Ref<DocumentVisibilityState> {
+ const visibility = ref(document.visibilityState);
+
+ const onChange = (): void => {
+ visibility.value = document.visibilityState;
+ };
+
+ onMounted(() => {
+ document.addEventListener('visibilitychange', onChange);
+ });
+
+ onUnmounted(() => {
+ document.removeEventListener('visibilitychange', onChange);
+ });
+
+ return visibility;
+}