diff options
Diffstat (limited to 'packages/frontend-shared/js')
| -rw-r--r-- | packages/frontend-shared/js/config.ts | 1 | ||||
| -rw-r--r-- | packages/frontend-shared/js/const.ts | 11 | ||||
| -rw-r--r-- | packages/frontend-shared/js/embed-page.ts | 2 | ||||
| -rw-r--r-- | packages/frontend-shared/js/emojilist.ts | 4 | ||||
| -rw-r--r-- | packages/frontend-shared/js/i18n.ts | 1 | ||||
| -rw-r--r-- | packages/frontend-shared/js/scroll.ts | 17 |
6 files changed, 17 insertions, 19 deletions
diff --git a/packages/frontend-shared/js/config.ts b/packages/frontend-shared/js/config.ts index 9a23e0e7f3..4c739e6e64 100644 --- a/packages/frontend-shared/js/config.ts +++ b/packages/frontend-shared/js/config.ts @@ -12,6 +12,7 @@ const siteName = document.querySelector<HTMLMetaElement>('meta[property="og:site export const host = address.host; export const hostname = address.hostname; export const url = address.origin; +export const port = address.port; export const apiUrl = location.origin + '/api'; export const wsOrigin = location.origin; export const lang = localStorage.getItem('lang') ?? 'en-US'; diff --git a/packages/frontend-shared/js/const.ts b/packages/frontend-shared/js/const.ts index 0dac166749..22e4e36292 100644 --- a/packages/frontend-shared/js/const.ts +++ b/packages/frontend-shared/js/const.ts @@ -126,9 +126,11 @@ export const notificationTypes = [ 'receiveFollowRequest', 'followRequestAccepted', 'roleAssigned', + 'chatRoomInvitationReceived', 'achievementEarned', 'exportCompleted', 'login', + 'createToken', 'test', 'app', 'edited', @@ -172,15 +174,10 @@ export const ROLE_POLICIES = [ 'canImportFollowing', 'canImportMuting', 'canImportUserLists', + 'chatAvailability', ] as const; -// なんか動かない -//export const CURRENT_STICKY_TOP = Symbol('CURRENT_STICKY_TOP'); -//export const CURRENT_STICKY_BOTTOM = Symbol('CURRENT_STICKY_BOTTOM'); -export const CURRENT_STICKY_TOP = 'CURRENT_STICKY_TOP'; -export const CURRENT_STICKY_BOTTOM = 'CURRENT_STICKY_BOTTOM'; - -export const DEFAULT_SERVER_ERROR_IMAGE_URL = '/client-assets/status/error.png'; +export const DEFAULT_SERVER_ERROR_IMAGE_URL = '/client-assets/status/error.jpg'; export const DEFAULT_NOT_FOUND_IMAGE_URL = '/client-assets/status/missingpage.webp'; export const DEFAULT_INFO_IMAGE_URL = '/client-assets/status/nothinghere.png'; diff --git a/packages/frontend-shared/js/embed-page.ts b/packages/frontend-shared/js/embed-page.ts index d5555a98c3..2a9b7eb478 100644 --- a/packages/frontend-shared/js/embed-page.ts +++ b/packages/frontend-shared/js/embed-page.ts @@ -6,7 +6,7 @@ //#region Embed関連の定義 /** 埋め込みの対象となるエンティティ(/embed/xxx の xxx の部分と対応させる) */ -const embeddableEntities = [ +export const embeddableEntities = [ 'notes', 'user-timeline', 'clips', diff --git a/packages/frontend-shared/js/emojilist.ts b/packages/frontend-shared/js/emojilist.ts index bde30a864f..f8bbf39177 100644 --- a/packages/frontend-shared/js/emojilist.ts +++ b/packages/frontend-shared/js/emojilist.ts @@ -9,10 +9,10 @@ export type UnicodeEmojiDef = { name: string; char: string; category: typeof unicodeEmojiCategories[number]; -} +}; // initial converted from https://github.com/muan/emojilib/commit/242fe68be86ed6536843b83f7e32f376468b38fb -import _emojilist from './emojilist.json'; +import _emojilist from './emojilist.json' with { type: 'json' }; export const emojilist: UnicodeEmojiDef[] = _emojilist.map(x => ({ name: x[1] as string, diff --git a/packages/frontend-shared/js/i18n.ts b/packages/frontend-shared/js/i18n.ts index 18232691fa..480cfcd642 100644 --- a/packages/frontend-shared/js/i18n.ts +++ b/packages/frontend-shared/js/i18n.ts @@ -2,6 +2,7 @@ * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ + import type { ILocale, ParameterizedString } from '../../../locales/index.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/frontend-shared/js/scroll.ts b/packages/frontend-shared/js/scroll.ts index 4f2e9105c3..9057b896c6 100644 --- a/packages/frontend-shared/js/scroll.ts +++ b/packages/frontend-shared/js/scroll.ts @@ -38,7 +38,7 @@ export function getScrollPosition(el: HTMLElement | null): number { export function onScrollTop(el: HTMLElement, cb: (topVisible: boolean) => unknown, tolerance = 1, once = false) { // とりあえず評価してみる - const firstTopVisible = isTopVisible(el); + const firstTopVisible = isHeadVisible(el); if (el.isConnected && firstTopVisible) { cb(firstTopVisible); if (once) return null; @@ -53,7 +53,7 @@ export function onScrollTop(el: HTMLElement, cb: (topVisible: boolean) => unknow const onScroll = () => { if (!document.body.contains(el)) return; - const topVisible = isTopVisible(el, tolerance); + const topVisible = isHeadVisible(el, tolerance); if (topVisible !== prevTopVisible) { prevTopVisible = topVisible; cb(topVisible); @@ -71,7 +71,7 @@ export function onScrollBottom(el: HTMLElement, cb: () => unknown, tolerance = 1 const container = getScrollContainer(el); // とりあえず評価してみる - if (el.isConnected && isBottomVisible(el, tolerance, container)) { + if (el.isConnected && isTailVisible(el, tolerance, container)) { cb(); if (once) return null; } @@ -79,7 +79,7 @@ export function onScrollBottom(el: HTMLElement, cb: () => unknown, tolerance = 1 const containerOrWindow = container ?? window; const onScroll = () => { if (!document.body.contains(el)) return; - if (isBottomVisible(el, 1, container)) { + if (isTailVisible(el, 1, container)) { cb(); if (once) removeListener(); } @@ -93,7 +93,7 @@ export function onScrollBottom(el: HTMLElement, cb: () => unknown, tolerance = 1 return removeListener; } -export function scroll(el: HTMLElement, options: ScrollToOptions | undefined) { +export function scrollInContainer(el: HTMLElement, options: ScrollToOptions | undefined) { const container = getScrollContainer(el); if (container == null) { window.scroll(options); @@ -108,7 +108,7 @@ export function scroll(el: HTMLElement, options: ScrollToOptions | undefined) { * @param options Scroll options */ export function scrollToTop(el: HTMLElement, options: { behavior?: ScrollBehavior; } = {}) { - scroll(el, { top: 0, ...options }); + scrollInContainer(el, { top: 0, ...options }); } /** @@ -132,13 +132,12 @@ export function scrollToBottom( } } -export function isTopVisible(el: HTMLElement, tolerance = 1): boolean { +export function isHeadVisible(el: HTMLElement, tolerance = 1): boolean { const scrollTop = getScrollPosition(el); - if (_DEV_) console.log(scrollTop, tolerance, scrollTop <= tolerance); return scrollTop <= tolerance; } -export function isBottomVisible(el: HTMLElement, tolerance = 1, container = getScrollContainer(el)) { +export function isTailVisible(el: HTMLElement, tolerance = 1, container = getScrollContainer(el)) { if (container) return el.scrollHeight <= container.clientHeight + Math.abs(container.scrollTop) + tolerance; return el.scrollHeight <= window.innerHeight + window.scrollY + tolerance; } |