Clean frontend files

This commit is contained in:
Romaric Mourgues
2023-04-18 11:22:14 +02:00
parent 1d83a583dc
commit 0ff1cc97d4
547 changed files with 1271 additions and 27036 deletions
@@ -1,6 +1,6 @@
import WebSocketService from '../../global/services/websocket-service';
import Logger from '../../global/framework/logger-service';
import UsersService from 'app/features/users/services/current-user-service';
import UsersService from '@features/users/services/current-user-service';
const logger = Logger.getLogger('OnlineUsersRealtimeAPI');
export type GetUserRequestType = string;
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { CompanyType } from 'app/features/companies/types/company';
import { UserPreferencesType, UserType } from 'app/features/users/types/user';
import { CompanyType } from '@features/companies/types/company';
import { UserPreferencesType, UserType } from '@features/users/types/user';
import Api from '../../global/framework/api-service';
import { TdriveService } from '../../global/framework/registry-decorator-service';
import { WebsocketRoom } from '../../global/types/websocket-types';
@@ -1,7 +1,7 @@
import Api from '../../global/framework/api-service';
import { NotificationType } from 'app/features/users/types/notification-types';
import { NotificationType } from '@features/users/types/notification-types';
import { TdriveService } from '../../global/framework/registry-decorator-service';
import { WebsocketRoom } from 'app/features/global/types/websocket-types';
import { WebsocketRoom } from '@features/global/types/websocket-types';
@TdriveService('UserNotificationAPIClientService')
class UserNotificationAPIClient {
@@ -29,15 +29,15 @@ class UserNotificationAPIClient {
async acknowledge(notification: NotificationType): Promise<void> {
const { message_id, channel_id, company_id, thread_id, workspace_id } = notification;
await Api.post<{ message_id: string, thread_id: string, channel_id: string, workspace_id: string}, boolean>(
`/internal/services/notifications/v1/badges/${company_id}/acknowledge`,
{
channel_id,
workspace_id,
thread_id,
message_id,
}
);
await Api.post<
{ message_id: string; thread_id: string; channel_id: string; workspace_id: string },
boolean
>(`/internal/services/notifications/v1/badges/${company_id}/acknowledge`, {
channel_id,
workspace_id,
thread_id,
message_id,
});
}
}
@@ -1,13 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useRef } from 'react';
import LoginService from 'app/features/auth/login-service';
import UserAPIClient from 'app/features/users/api/user-api-client';
import LoginService from '@features/auth/login-service';
import UserAPIClient from '@features/users/api/user-api-client';
import { useRecoilState } from 'recoil';
import { CurrentUserState } from '../state/atoms/current-user';
import { useRealtimeRoom } from 'app/features/global/hooks/use-realtime';
import Languages from 'app/features/global/services/languages-service';
import ConfiguratorsManager from 'app/deprecated/Configurators/ConfiguratorsManager.js';
import { RealtimeApplicationEvent } from 'app/features/global/types/realtime-types';
import { useRealtimeRoom } from '@features/global/hooks/use-realtime';
import Languages from '@features/global/services/languages-service';
import ConfiguratorsManager from '@deprecated/Configurators/ConfiguratorsManager.js';
import { RealtimeApplicationEvent } from '@features/global/types/realtime-types';
import { useSetUserList } from './use-user-list';
export const useCurrentUser = () => {
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useGlobalEffect } from 'app/features/global/hooks/use-global-effect';
import { useRealtimeRoom } from 'app/features/global/hooks/use-realtime';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import { useGlobalEffect } from '@features/global/hooks/use-global-effect';
import { useRealtimeRoom } from '@features/global/hooks/use-realtime';
import useRouterCompany from '@features/router/hooks/use-router-company';
import _ from 'lodash';
import { useRecoilCallback, useRecoilState, useRecoilValue } from 'recoil';
import userNotificationApiClient from '../api/user-notification-api-client';
@@ -13,12 +13,12 @@ import {
NotificationsWorkspaceBadgesSelector,
} from '../state/atoms/notifications';
import { NotificationType } from '../types/notification-types';
import ElectronService from 'app/features/global/framework/electron-service';
import windowState from 'app/features/global/utils/window';
import ElectronService from '@features/global/framework/electron-service';
import windowState from '@features/global/utils/window';
import RouterService, { ClientStateType } from '../../router/services/router-service';
import { pushDesktopNotification } from '../services/push-desktop-notification';
import { RouterState } from 'app/features/router/state/atoms/router';
import { useCurrentUser } from 'app/features/users/hooks/use-current-user';
import { RouterState } from '@features/router/state/atoms/router';
import { useCurrentUser } from '@features/users/hooks/use-current-user';
export let removeBadgesNow: (type: 'company' | 'workspace' | 'channel', id: string) => void = () =>
undefined;
@@ -4,8 +4,8 @@
import { useCallback, useEffect } from 'react';
import { useRecoilState } from 'recoil';
import Logger from 'app/features/global/framework/logger-service';
import { useRealtimeRoom } from 'app/features/global/hooks/use-realtime';
import Logger from '@features/global/framework/logger-service';
import { useRealtimeRoom } from '@features/global/hooks/use-realtime';
import { OnlineUsersState, OnlineUserType } from '../state/atoms/online-users';
import useWebSocket from '../../global/hooks/use-websocket';
import {
@@ -14,7 +14,7 @@ import {
RealtimeUpdateMessageType,
} from '../../../features/users/api/online-user-realtime-api-client';
import JWTStorage from '../../auth/jwt-storage-service';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import useRouterCompany from '@features/router/hooks/use-router-company';
const logger = Logger.getLogger('useOnlineUsers');
@@ -1,13 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useState } from 'react';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import { UserType } from 'app/features/users/types/user';
import useRouterCompany from '@features/router/hooks/use-router-company';
import { UserType } from '@features/users/types/user';
import { getCurrentUserList, setUserList, useSetUserList, useUserList } from './use-user-list';
import UserAPIClient, { SearchContextType } from '../api/user-api-client';
import { delayRequest } from 'app/features/global/utils/managedSearchRequest';
import { distanceFromQuery, matchQuery } from 'app/features/global/utils/strings';
import useRouterWorkspace from 'app/features/router/hooks/use-router-workspace';
import { delayRequest } from '@features/global/utils/managedSearchRequest';
import { distanceFromQuery, matchQuery } from '@features/global/utils/strings';
import useRouterWorkspace from '@features/router/hooks/use-router-workspace';
import _ from 'lodash';
export const searchBackend = async (
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import UserAPIClient from 'app/features/users/api/user-api-client';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import useRouterWorkspace from 'app/features/router/hooks/use-router-workspace';
import UserAPIClient from '@features/users/api/user-api-client';
import useRouterCompany from '@features/router/hooks/use-router-company';
import useRouterWorkspace from '@features/router/hooks/use-router-workspace';
export const useSetLastWorkspacePreference = () => {
const companyId = useRouterCompany();
@@ -2,12 +2,12 @@ import { useEffect } from 'react';
import { cloneDeep, isEqual, uniqBy } from 'lodash';
import { useRecoilCallback, useRecoilValueLoadable } from 'recoil';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import useRouterWorkspace from 'app/features/router/hooks/use-router-workspace';
import { UserCompanyType, UserType, UserWorkspaceType } from 'app/features/users/types/user';
import WorkspaceUserAPIClient from 'app/features/workspace-members/api/workspace-members-api-client';
import useRouterCompany from '@features/router/hooks/use-router-company';
import useRouterWorkspace from '@features/router/hooks/use-router-workspace';
import { UserCompanyType, UserType, UserWorkspaceType } from '@features/users/types/user';
import WorkspaceUserAPIClient from '@features/workspace-members/api/workspace-members-api-client';
import { UserListState } from '../state/atoms/user-list';
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';
import _ from 'lodash';
export const usePreloadSomeUsers = () => {
@@ -73,13 +73,7 @@ export function useSetUserList(key: string) {
if (nextList && nextList.length) {
const nextListMerged = nextList.map(u =>
cloneDeep(
_.merge(
{},
currentList.find(cu => cu.id === u.id) || {},
u,
),
),
cloneDeep(_.merge({}, currentList.find(cu => cu.id === u.id) || {}, u)),
);
const newList = _.uniqBy([...nextListMerged, ...currentList], 'id')
@@ -1,9 +1,9 @@
import { useRecoilState, useRecoilValue } from 'recoil';
import { useGlobalEffect } from 'app/features/global/hooks/use-global-effect';
import { useRealtimeRoom } from 'app/features/global/hooks/use-realtime';
import { LoadingState } from 'app/features/global/state/atoms/Loading';
import { UserType } from 'app/features/users/types/user';
import { useGlobalEffect } from '@features/global/hooks/use-global-effect';
import { useRealtimeRoom } from '@features/global/hooks/use-realtime';
import { LoadingState } from '@features/global/state/atoms/Loading';
import { UserType } from '@features/users/types/user';
import UserAPIClient from '../api/user-api-client';
import { UserSelector, UserByUsernameSelector } from '../state/selectors/user-selector';
@@ -1,9 +1,9 @@
import { useState, useEffect } from 'react';
import { isArray } from 'lodash';
import UserListenerService from 'app/features/users/services/listen-users-service';
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections';
import UsersService from 'app/features/users/services/current-user-service';
import userAsyncGet from 'app/features/users/utils/async-get';
import UserListenerService from '@features/users/services/listen-users-service';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';
import UsersService from '@features/users/services/current-user-service';
import userAsyncGet from '@features/users/utils/async-get';
export const useUsersListener = (usersIds: string[] = []) => {
const users = (isArray(usersIds) ? usersIds : []).filter(
@@ -1,14 +1,14 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-explicit-any */
import Login from 'app/features/auth/login-service';
import Collections, { Collection } from 'app/deprecated/CollectionsV1/Collections/Collections';
import Api from 'app/features/global/framework/api-service';
import Languages from 'app/features/global/services/languages-service';
import { UserType } from 'app/features/users/types/user';
import { TdriveService } from 'app/features/global/framework/registry-decorator-service';
import { addApiUrlIfNeeded } from 'app/features/global/utils/URLUtils';
import Login from '@features/auth/login-service';
import Collections, { Collection } from '@deprecated/CollectionsV1/Collections/Collections';
import Api from '@features/global/framework/api-service';
import Languages from '@features/global/services/languages-service';
import { UserType } from '@features/users/types/user';
import { TdriveService } from '@features/global/framework/registry-decorator-service';
import { addApiUrlIfNeeded } from '@features/global/utils/URLUtils';
import { getUser } from '../hooks/use-user-list';
import { getGradient } from 'app/atoms/avatar';
import { getGradient } from '@atoms/avatar';
type SearchQueryType = {
searching: boolean;
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-this-alias */
/* eslint-disable @typescript-eslint/no-explicit-any */
import ws from 'app/deprecated/websocket/websocket';
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections';
import ws from '@deprecated/websocket/websocket';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';
import UserService from './current-user-service';
import Globals from 'app/features/global/services/globals-tdrive-app-service';
import userAsyncGet from 'app/features/users/utils/async-get';
import Globals from '@features/global/services/globals-tdrive-app-service';
import userAsyncGet from '@features/users/utils/async-get';
type Timeout = ReturnType<typeof setTimeout>;
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { notification as antNotification } from 'antd';
import RouterService, { ClientStateType } from '../../router/services/router-service';
import popupManager from 'app/deprecated/popupManager/popupManager';
import popupManager from '@deprecated/popupManager/popupManager';
import emojione from 'emojione';
import React from 'react';
import { X } from 'react-feather';
@@ -1,6 +1,6 @@
import { atom } from 'recoil';
import { UserType } from 'app/features/users/types/user';
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections';
import { UserType } from '@features/users/types/user';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';
import _ from 'lodash';
export const CurrentUserState = atom<UserType | undefined>({
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { atom, DefaultValue, selector, selectorFamily } from 'recoil';
import { UserType } from 'app/features/users/types/user';
import { UserType } from '@features/users/types/user';
import { CurrentUserState } from './current-user';
export type OnlineUserType = Pick<UserType, 'id' | 'connected'> & {
@@ -1,5 +1,5 @@
import { atom } from 'recoil';
import { UserType } from 'app/features/users/types/user';
import { UserType } from '@features/users/types/user';
export const UserListState = atom<UserType[]>({
key: 'UserListState',
@@ -1,7 +1,7 @@
import { CompanyType } from 'app/features/companies/types/company';
import { UserType } from 'app/features/users/types/user';
import { UserContext } from 'app/features/users/types/user-context';
import { WorkspaceType } from 'app/features/workspaces/types/workspace';
import { CompanyType } from '@features/companies/types/company';
import { UserType } from '@features/users/types/user';
import { UserContext } from '@features/users/types/user-context';
import { WorkspaceType } from '@features/workspaces/types/workspace';
class UserContextState implements UserContext {
private _user: UserType | undefined;
@@ -1,6 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-use-before-define
import React from 'react';
import { useOnlineUsers } from 'app/features/users/hooks/use-online-users';
import { useOnlineUsers } from '@features/users/hooks/use-online-users';
/**
* This hook will be global to application
@@ -1,7 +1,7 @@
import { selectorFamily } from 'recoil';
import { UserType } from 'app/features/users/types/user';
import { UserType } from '@features/users/types/user';
import { UserListState } from 'app/features/users/state/atoms/user-list';
import { UserListState } from '@features/users/state/atoms/user-list';
/**
* Search users locally
@@ -1,6 +1,6 @@
import { selectorFamily } from 'recoil';
import { UserListState } from 'app/features/users/state/atoms/user-list';
import { UserType } from 'app/features/users/types/user';
import { UserListState } from '@features/users/state/atoms/user-list';
import { UserType } from '@features/users/types/user';
export const UserSelector = selectorFamily<UserType | undefined, string>({
key: 'UserSelector',
@@ -1,7 +1,7 @@
import { CompanyType } from '../../companies/types/company';
import { PendingFileRecoilType } from '../../files/types/file';
import { UserType } from 'app/features/users/types/user';
import { UserType } from '@features/users/types/user';
import { WorkspaceType } from '../../workspaces/types/workspace';
export type UserContext = {
@@ -1,10 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
CompanyRoleType,
CompanyStatusType,
CompanyType,
} from 'app/features/companies/types/company';
import { WorkspaceType } from 'app/features/workspaces/types/workspace';
import { CompanyRoleType, CompanyStatusType, CompanyType } from '@features/companies/types/company';
import { WorkspaceType } from '@features/workspaces/types/workspace';
export type UserPreferencesType = null | {
locale?: string;
@@ -1,6 +1,6 @@
import { UserType } from 'app/features/users/types/user';
import { UserType } from '@features/users/types/user';
import UserAPIClient from '../api/user-api-client';
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';
const currentUserRequests: { [key: string]: PromiseLike<UserType | null> } = {};
const usersCollection = Collections.get('users');