diff options
| author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2023-03-06 07:51:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-06 07:51:17 +0100 |
| commit | 5651353c2756e6580a819c7d4f1f5ad41553abbe (patch) | |
| tree | 7055c10a2af3734be765508e1212aa9c23ec34ee /packages/frontend/src/scripts | |
| parent | Merge branch 'develop' into mkusername-empty (diff) | |
| parent | [ci skip] chore(client): showNoteActionsOnlyHover変更時にリロードダ... (diff) | |
| download | misskey-5651353c2756e6580a819c7d4f1f5ad41553abbe.tar.gz misskey-5651353c2756e6580a819c7d4f1f5ad41553abbe.tar.bz2 misskey-5651353c2756e6580a819c7d4f1f5ad41553abbe.zip | |
Merge branch 'develop' into mkusername-empty
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/get-user-menu.ts | 98 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/hotkey.ts | 6 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/keycode.ts | 15 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/media-proxy.ts | 18 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/page-metadata.ts | 1 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/sound.ts | 21 |
6 files changed, 89 insertions, 70 deletions
diff --git a/packages/frontend/src/scripts/get-user-menu.ts b/packages/frontend/src/scripts/get-user-menu.ts index 69d0ed085d..5170ca4c8c 100644 --- a/packages/frontend/src/scripts/get-user-menu.ts +++ b/packages/frontend/src/scripts/get-user-menu.ts @@ -12,29 +12,6 @@ import { Router } from '@/nirax'; 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', { @@ -137,12 +114,67 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router 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: async () => { + const { canceled, result: period } = await os.select({ + title: i18n.ts.period, + items: [{ + value: 'indefinitely', text: i18n.ts.indefinitely, + }, { + value: 'oneHour', text: i18n.ts.oneHour, + }, { + value: 'oneDay', text: i18n.ts.oneDay, + }, { + value: 'oneWeek', text: i18n.ts.oneWeek, + }, { + value: 'oneMonth', text: i18n.ts.oneMonth, + }], + default: 'indefinitely', + }); + if (canceled) return; + + const expiresAt = period === 'indefinitely' ? null + : period === 'oneHour' ? Date.now() + (1000 * 60 * 60) + : period === 'oneDay' ? Date.now() + (1000 * 60 * 60 * 24) + : period === 'oneWeek' ? Date.now() + (1000 * 60 * 60 * 24 * 7) + : period === 'oneMonth' ? Date.now() + (1000 * 60 * 60 * 24 * 30) + : null; + + os.apiWithDialog('admin/roles/assign', { roleId: r.id, userId: user.id, expiresAt }); + }, + })); + }, + }]); + } + menu = menu.concat([null, { icon: user.isMuted ? 'ti ti-eye' : 'ti ti-eye-off', text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute, @@ -166,24 +198,6 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router text: i18n.ts.reportAbuse, action: reportAbuse, }]); - - if (iAmModerator) { - menu = menu.concat([null, { - 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/hotkey.ts b/packages/frontend/src/scripts/hotkey.ts index 4a0ded637d..b7238016c6 100644 --- a/packages/frontend/src/scripts/hotkey.ts +++ b/packages/frontend/src/scripts/hotkey.ts @@ -53,10 +53,10 @@ const parseKeymap = (keymap: Keymap) => Object.entries(keymap).map(([patterns, c return result; }); -const ignoreElemens = ['input', 'textarea']; +const ignoreElements = ['input', 'textarea']; function match(ev: KeyboardEvent, patterns: Action['patterns']): boolean { - const key = ev.code.toLowerCase(); + const key = ev.key.toLowerCase(); return patterns.some(pattern => pattern.which.includes(key) && pattern.ctrl === ev.ctrlKey && pattern.shift === ev.shiftKey && @@ -70,7 +70,7 @@ export const makeHotkey = (keymap: Keymap) => { return (ev: KeyboardEvent) => { if (document.activeElement) { - if (ignoreElemens.some(el => document.activeElement!.matches(el))) return; + if (ignoreElements.some(el => document.activeElement!.matches(el))) return; if (document.activeElement.attributes['contenteditable']) return; } diff --git a/packages/frontend/src/scripts/keycode.ts b/packages/frontend/src/scripts/keycode.ts index 69f6a82803..35813edbd5 100644 --- a/packages/frontend/src/scripts/keycode.ts +++ b/packages/frontend/src/scripts/keycode.ts @@ -16,18 +16,3 @@ export const aliases = { 'right': 'ArrowRight', 'plus': ['NumpadAdd', 'Semicolon'], }; - -/*! -* Programmatically add the following -*/ - -// lower case chars -for (let i = 97; i < 123; i++) { - const char = String.fromCharCode(i); - aliases[char] = `Key${char.toUpperCase()}`; -} - -// numbers -for (let i = 0; i < 10; i++) { - aliases[i] = [`Numpad${i}`, `Digit${i}`]; -} diff --git a/packages/frontend/src/scripts/media-proxy.ts b/packages/frontend/src/scripts/media-proxy.ts index 274e96e0a1..2fe5bdcf8f 100644 --- a/packages/frontend/src/scripts/media-proxy.ts +++ b/packages/frontend/src/scripts/media-proxy.ts @@ -1,20 +1,20 @@ -import { query, appendQuery } from '@/scripts/url'; +import { query } from '@/scripts/url'; import { url } from '@/config'; import { instance } from '@/instance'; -export function getProxiedImageUrl(imageUrl: string, type?: 'preview'): string { - if (imageUrl.startsWith(instance.mediaProxy + '/') || imageUrl.startsWith('/proxy/')) { - // もう既にproxyっぽそうだったらsearchParams付けるだけ - return appendQuery(imageUrl, query({ - fallback: '1', - ...(type ? { [type]: '1' } : {}), - })); +export function getProxiedImageUrl(imageUrl: string, type?: 'preview', mustOrigin: boolean = false): string { + const localProxy = `${url}/proxy`; + + if (imageUrl.startsWith(instance.mediaProxy + '/') || imageUrl.startsWith('/proxy/') || imageUrl.startsWith(localProxy + '/')) { + // もう既にproxyっぽそうだったらurlを取り出す + imageUrl = (new URL(imageUrl)).searchParams.get('url') ?? imageUrl; } - return `${instance.mediaProxy}/image.webp?${query({ + return `${mustOrigin ? localProxy : instance.mediaProxy}/image.webp?${query({ url: imageUrl, fallback: '1', ...(type ? { [type]: '1' } : {}), + ...(mustOrigin ? { origin: '1' } : {}), })}`; } diff --git a/packages/frontend/src/scripts/page-metadata.ts b/packages/frontend/src/scripts/page-metadata.ts index 0db8369f9d..8810e26960 100644 --- a/packages/frontend/src/scripts/page-metadata.ts +++ b/packages/frontend/src/scripts/page-metadata.ts @@ -10,7 +10,6 @@ export type PageMetadata = { icon?: string | null; avatar?: misskey.entities.User | null; userName?: misskey.entities.User | null; - bg?: string; }; export function definePageMetadata(metadata: PageMetadata | null | Ref<PageMetadata | null> | ComputedRef<PageMetadata | null>): void { diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts index 9d1f603235..b08982facb 100644 --- a/packages/frontend/src/scripts/sound.ts +++ b/packages/frontend/src/scripts/sound.ts @@ -4,6 +4,27 @@ const cache = new Map<string, HTMLAudioElement>(); export const soundsTypes = [ null, + 'syuilo/n-aec', + 'syuilo/n-aec-4va', + 'syuilo/n-aec-4vb', + 'syuilo/n-aec-8va', + 'syuilo/n-aec-8vb', + 'syuilo/n-cea', + 'syuilo/n-cea-4va', + 'syuilo/n-cea-4vb', + 'syuilo/n-cea-8va', + 'syuilo/n-cea-8vb', + 'syuilo/n-eca', + 'syuilo/n-eca-4va', + 'syuilo/n-eca-4vb', + 'syuilo/n-eca-8va', + 'syuilo/n-eca-8vb', + 'syuilo/n-ea', + 'syuilo/n-ea-4va', + 'syuilo/n-ea-4vb', + 'syuilo/n-ea-8va', + 'syuilo/n-ea-8vb', + 'syuilo/n-ea-harmony', 'syuilo/up', 'syuilo/down', 'syuilo/pope1', |