nicolium: move more stuff around
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -2,7 +2,7 @@ import { createSelector } from 'reselect';
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { getHost } from '@/actions/instance';
|
||||
import { frontendConfigSchema } from '@/normalizers/frontend-config';
|
||||
import { frontendConfigSchema } from '@/schemas/frontend-config';
|
||||
import KVStore from '@/storage/kv-store';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
|
||||
|
||||
@ -10,11 +10,14 @@ import Stack from '@/components/ui/stack';
|
||||
import Text from '@/components/ui/text';
|
||||
import PlaceholderChatMessage from '@/features/placeholder/components/placeholder-chat-message';
|
||||
import { useRelationshipQuery } from '@/queries/accounts/use-relationship';
|
||||
import { useChatMessages, useMarkChatAsRead } from '@/queries/chats';
|
||||
import {
|
||||
useChatMessages,
|
||||
useMarkChatAsRead,
|
||||
type ChatMessage as ChatMessageEntity,
|
||||
} from '@/queries/chats';
|
||||
|
||||
import ChatMessage from './chat-message';
|
||||
|
||||
import type { ChatMessage as ChatMessageEntity } from '@/normalizers/chat-message';
|
||||
import type { Chat } from 'pl-api';
|
||||
|
||||
const messages = defineMessages({
|
||||
|
||||
@ -11,13 +11,12 @@ import Stack from '@/components/ui/stack';
|
||||
import Text from '@/components/ui/text';
|
||||
import { MediaGallery } from '@/features/ui/util/async-components';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { useDeleteChatMessage } from '@/queries/chats';
|
||||
import { useDeleteChatMessage, type ChatMessage as ChatMessageEntity } from '@/queries/chats';
|
||||
import { useModalsActions } from '@/stores/modals';
|
||||
import { stripHTML } from '@/utils/html';
|
||||
import { onlyEmoji } from '@/utils/rich-content';
|
||||
|
||||
import type { Menu as IMenu } from '@/components/dropdown-menu';
|
||||
import type { ChatMessage as ChatMessageEntity } from '@/normalizers/chat-message';
|
||||
import type { Chat } from 'pl-api';
|
||||
|
||||
const messages = defineMessages({
|
||||
|
||||
@ -5,7 +5,7 @@ import HStack from '@/components/ui/hstack';
|
||||
import Input from '@/components/ui/input';
|
||||
|
||||
import type { StreamfieldComponent } from '@/components/ui/streamfield';
|
||||
import type { CryptoAddress } from '@/normalizers/frontend-config';
|
||||
import type { CryptoAddress } from '@/schemas/frontend-config';
|
||||
|
||||
const messages = defineMessages({
|
||||
ticker: {
|
||||
|
||||
@ -5,7 +5,7 @@ import HStack from '@/components/ui/hstack';
|
||||
import Input from '@/components/ui/input';
|
||||
|
||||
import type { StreamfieldComponent } from '@/components/ui/streamfield';
|
||||
import type { FooterItem } from '@/normalizers/frontend-config';
|
||||
import type { FooterItem } from '@/schemas/frontend-config';
|
||||
|
||||
const messages = defineMessages({
|
||||
label: {
|
||||
|
||||
@ -7,7 +7,7 @@ import Input from '@/components/ui/input';
|
||||
import IconPicker from './icon-picker';
|
||||
|
||||
import type { StreamfieldComponent } from '@/components/ui/streamfield';
|
||||
import type { PromoPanelItem } from '@/normalizers/frontend-config';
|
||||
import type { PromoPanelItem } from '@/schemas/frontend-config';
|
||||
|
||||
const messages = defineMessages({
|
||||
icon: { id: 'frontend_config.promo_panel.meta_fields.icon_placeholder', defaultMessage: 'Icon' },
|
||||
|
||||
@ -7,7 +7,7 @@ import BackgroundShapes from '@/features/ui/components/background-shapes';
|
||||
import { useSystemTheme } from '@/hooks/use-system-theme';
|
||||
import { useThemeCss } from '@/hooks/use-theme-css';
|
||||
|
||||
import type { FrontendConfig } from '@/normalizers/frontend-config';
|
||||
import type { FrontendConfig } from '@/schemas/frontend-config';
|
||||
|
||||
interface ISitePreview {
|
||||
/** Raw pl-fe configuration. */
|
||||
|
||||
@ -3,7 +3,7 @@ import React from 'react';
|
||||
|
||||
import Toggle from '@/components/ui/toggle';
|
||||
|
||||
import type { Settings } from '@/schemas/pl-fe/settings';
|
||||
import type { Settings } from '@/schemas/frontend-settings';
|
||||
|
||||
interface ISettingToggle {
|
||||
/** Unique identifier for the Toggle. */
|
||||
|
||||
@ -6,7 +6,7 @@ import { generateAccent, generateThemeCss } from '@/utils/theme';
|
||||
|
||||
import { useFrontendConfig } from './use-frontend-config';
|
||||
|
||||
import type { FrontendConfig } from '@/normalizers/frontend-config';
|
||||
import type { FrontendConfig } from '@/schemas/frontend-config';
|
||||
|
||||
const DEFAULT_COLORS = {
|
||||
success: {
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
import type { ChatMessage as BaseChatMessage } from 'pl-api';
|
||||
|
||||
const normalizeChatMessage = (
|
||||
chatMessage: BaseChatMessage & { pending?: boolean; deleting?: boolean },
|
||||
) => ({
|
||||
type: 'message' as const,
|
||||
pending: false,
|
||||
deleting: false,
|
||||
...chatMessage,
|
||||
});
|
||||
|
||||
type ChatMessage = ReturnType<typeof normalizeChatMessage>;
|
||||
|
||||
export { normalizeChatMessage, type ChatMessage };
|
||||
@ -1,20 +0,0 @@
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
import type { Notification as BaseNotification, NotificationGroup } from 'pl-api';
|
||||
|
||||
const normalizeNotification = (notification: BaseNotification): NotificationGroup => ({
|
||||
...omit(notification, ['account', 'status', 'target']),
|
||||
group_key: notification.id,
|
||||
notifications_count: 1,
|
||||
most_recent_notification_id: notification.id,
|
||||
page_min_id: notification.id,
|
||||
page_max_id: notification.id,
|
||||
latest_page_notification_at: notification.created_at,
|
||||
sample_account_ids: [notification.account.id],
|
||||
// @ts-expect-error
|
||||
status_id: notification.status?.id,
|
||||
// @ts-expect-error
|
||||
target_id: notification.target?.id,
|
||||
});
|
||||
|
||||
export { normalizeNotification };
|
||||
@ -33,7 +33,7 @@ import {
|
||||
frontendConfigSchema,
|
||||
promoPanelItemSchema,
|
||||
type FrontendConfig,
|
||||
} from '@/normalizers/frontend-config';
|
||||
} from '@/schemas/frontend-config';
|
||||
import toast from '@/toast';
|
||||
|
||||
const messages = defineMessages({
|
||||
|
||||
@ -17,7 +17,7 @@ import { useAppDispatch } from '@/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { useFrontendConfig } from '@/hooks/use-frontend-config';
|
||||
import { normalizeColors } from '@/hooks/use-theme-css';
|
||||
import { frontendConfigSchema } from '@/normalizers/frontend-config';
|
||||
import { frontendConfigSchema } from '@/schemas/frontend-config';
|
||||
import toast from '@/toast';
|
||||
import { download } from '@/utils/download';
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ import { useClient } from '@/hooks/use-client';
|
||||
import { useFeatures } from '@/hooks/use-features';
|
||||
import { useLoggedIn } from '@/hooks/use-logged-in';
|
||||
import { useOwnAccount } from '@/hooks/use-own-account';
|
||||
import { type ChatMessage, normalizeChatMessage } from '@/normalizers/chat-message';
|
||||
import { reOrderChatListItems } from '@/utils/chats';
|
||||
import { flattenPages, updatePageItem } from '@/utils/queries';
|
||||
|
||||
@ -29,6 +28,17 @@ import { useRelationshipQuery } from './accounts/use-relationship';
|
||||
import { queryClient } from './client';
|
||||
import { queryKeys } from './keys';
|
||||
|
||||
const normalizeChatMessage = (
|
||||
chatMessage: BaseChatMessage & { pending?: boolean; deleting?: boolean },
|
||||
) => ({
|
||||
type: 'message' as const,
|
||||
pending: false,
|
||||
deleting: false,
|
||||
...chatMessage,
|
||||
});
|
||||
|
||||
type ChatMessage = ReturnType<typeof normalizeChatMessage>;
|
||||
|
||||
const useChatMessages = (chat: Chat) => {
|
||||
const client = useClient();
|
||||
const isBlocked = !!useRelationshipQuery(chat?.account.id).data?.blocked_by;
|
||||
@ -270,6 +280,7 @@ const useDeleteChatMessage = (chatId: string) => {
|
||||
};
|
||||
|
||||
export {
|
||||
normalizeChatMessage,
|
||||
useChat,
|
||||
useMarkChatAsRead,
|
||||
useCreateChatMessage,
|
||||
@ -277,4 +288,5 @@ export {
|
||||
useDeleteChatMessage,
|
||||
useChats,
|
||||
useChatMessages,
|
||||
type ChatMessage,
|
||||
};
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import type { MinifiedScrobble } from './accounts/account-scrobble';
|
||||
import type { ChatMessage } from './chats';
|
||||
import type { MinifiedGroupMember } from './groups/use-group-members';
|
||||
import type { FilterType } from './notifications/use-notifications';
|
||||
import type { DraftStatus } from './statuses/use-draft-statuses';
|
||||
@ -12,7 +13,6 @@ import type {
|
||||
MinifiedAdminReport,
|
||||
MinifiedConversation,
|
||||
} from './utils/minify-list';
|
||||
import type { ChatMessage } from '@/normalizers/chat-message';
|
||||
import type { DataTag, InfiniteData } from '@tanstack/react-query';
|
||||
import type {
|
||||
Account,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import 'intl-pluralrules';
|
||||
import omit from 'lodash/omit';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
@ -12,7 +13,6 @@ import { useAppDispatch } from '@/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { useClient } from '@/hooks/use-client';
|
||||
import { useLoggedIn } from '@/hooks/use-logged-in';
|
||||
import { normalizeNotification } from '@/normalizers/notification';
|
||||
import { appendFollowRequest } from '@/queries/accounts/use-follow-requests';
|
||||
import { queryClient } from '@/queries/client';
|
||||
import { makePaginatedResponseQueryOptions } from '@/queries/utils/make-paginated-response-query-options';
|
||||
@ -43,6 +43,21 @@ const FILTER_TYPES = {
|
||||
|
||||
type FilterType = keyof typeof FILTER_TYPES;
|
||||
|
||||
const normalizeNotification = (notification: Notification): NotificationGroup => ({
|
||||
...omit(notification, ['account', 'status', 'target']),
|
||||
group_key: notification.id,
|
||||
notifications_count: 1,
|
||||
most_recent_notification_id: notification.id,
|
||||
page_min_id: notification.id,
|
||||
page_max_id: notification.id,
|
||||
latest_page_notification_at: notification.created_at,
|
||||
sample_account_ids: [notification.account.id],
|
||||
// @ts-expect-error
|
||||
status_id: notification.status?.id,
|
||||
// @ts-expect-error
|
||||
target_id: notification.target?.id,
|
||||
});
|
||||
|
||||
const useActiveFilter = () =>
|
||||
useSettingsStore((state) => state.settings.notifications.quickFilter.active);
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
FRONTEND_CONFIG_REQUEST_FAIL,
|
||||
} from '../actions/frontend-config';
|
||||
|
||||
import type { FrontendConfig } from '@/normalizers/frontend-config';
|
||||
import type { FrontendConfig } from '@/schemas/frontend-config';
|
||||
import type { PleromaConfig } from 'pl-api';
|
||||
|
||||
const initialState: Partial<FrontendConfig> = {};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import trimStart from 'lodash/trimStart';
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { settingsSchema } from '@/schemas/pl-fe/settings';
|
||||
import { settingsSchema } from '@/schemas/frontend-settings';
|
||||
import { coerceObject, filteredArray } from '@/schemas/utils';
|
||||
|
||||
const promoPanelItemSchema = coerceObject({
|
||||
@ -2,7 +2,7 @@ import * as v from 'valibot';
|
||||
|
||||
import { locales } from '@/messages';
|
||||
|
||||
import { coerceObject } from '../utils';
|
||||
import { coerceObject } from './utils';
|
||||
|
||||
const skinToneSchema = v.picklist([1, 2, 3, 4, 5, 6]);
|
||||
|
||||
@ -4,7 +4,7 @@ import * as v from 'valibot';
|
||||
import { create } from 'zustand';
|
||||
import { mutative } from 'zustand-mutative';
|
||||
|
||||
import { settingsSchema, type Settings } from '@/schemas/pl-fe/settings';
|
||||
import { settingsSchema, type Settings } from '@/schemas/frontend-settings';
|
||||
import KVStore from '@/storage/kv-store';
|
||||
import toast from '@/toast';
|
||||
import {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import sumBy from 'lodash/sumBy';
|
||||
|
||||
import { normalizeChatMessage } from '@/normalizers/chat-message';
|
||||
import { normalizeChatMessage } from '@/queries/chats';
|
||||
import { queryClient } from '@/queries/client';
|
||||
import { queryKeys } from '@/queries/keys';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { Status } from '@/normalizers/status';
|
||||
import type { Settings } from '@/schemas/pl-fe/settings';
|
||||
import type { Settings } from '@/schemas/frontend-settings';
|
||||
|
||||
const shouldFilter = (
|
||||
status: Pick<Status, 'in_reply_to_id' | 'visibility' | 'reblog_id'>,
|
||||
|
||||
Reference in New Issue
Block a user