Skip to content

Commit

Permalink
🚨⚰️ front: Remove unused references
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlinagora committed Nov 13, 2024
1 parent b2bbce9 commit 26ca1be
Show file tree
Hide file tree
Showing 37 changed files with 52 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React from 'react';
import './connection-indicator.scss';
import ErrorOutlinedIcon from '@material-ui/icons/ErrorOutlined';
import HourglassEmpty from '@material-ui/icons/HourglassEmpty';
Expand All @@ -9,7 +9,7 @@ import { useRecoilState } from 'recoil';
// import WebSocket, { WebsocketEvents } from '@features/global/types/websocket-types';

export default () => {
const [{ connected, reconnecting }, setState] = useRecoilState(ConnectedState);
const [{ connected, reconnecting }] = useRecoilState(ConnectedState);

return (
<div className={'connection_indicator ' + (connected === false ? 'visible' : '')}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import React, { useEffect, useState } from 'react';
import InitService from '../../features/global/services/init-service';
// import InitService from '../../features/global/services/init-service';
import LocalStorage from '../../features/global/framework/local-storage-service';
import DownloadBanner from '@molecules/download-banner';
import { detectDesktopAppPresence } from '../../../utils/browser-detect';

export default (): React.ReactElement => {
const [showBanner, setShowBanner] = useState(false);
const [ , setShowBanner] = useState(false);

const download = (): void => {
const appDownloadUrl = InitService?.server_infos?.configuration?.app_download_url;
// const download = (): void => {
// const appDownloadUrl = InitService?.server_infos?.configuration?.app_download_url;
// if (appDownloadUrl)
// window.open(appDownloadUrl, '_blank');
// };

if (appDownloadUrl) {
window.open(appDownloadUrl, '_blank');
}
};

const removeBanner = (): void => {
LocalStorage.setItem('show_app_banner', 'false');
setShowBanner(false);
};
// const removeBanner = (): void => {
// LocalStorage.setItem('show_app_banner', 'false');
// setShowBanner(false);
// };

useEffect(() => {
if (LocalStorage.getItem('show_app_banner') === 'false') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { ReactNode } from 'react';
import { getDevice } from '../../features/global/utils/device';
import configuration from '../../environment/environment';
import { Smartphone, X } from 'react-feather';
import './style.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class PopupComponent extends React.Component {
{this.state.popupManager.canClose() && (
<div className="header">
<div className="close" onClick={() => this.state.popupManager.close()}>
<CloseIcon class="m-icon" />
<CloseIcon className="m-icon" />
</div>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FolderIcon } from '@heroicons/react/solid';
import Highlighter from 'react-highlight-words';
import { useRecoilState, useRecoilValue } from 'recoil';
import { useRecoilValue } from 'recoil';
import { onDriveItemDownloadClick } from '../common';
import ResultContext from './result-context';
import { Button } from '@atoms/button/button';
Expand All @@ -15,18 +15,14 @@ import { SearchInputState } from '@features/search/state/search-input';
import { UserType } from '@features/users/types/user';
import { useDrivePreview } from '@features/drive/hooks/use-drive-preview';
import Media from '@molecules/media';
import { DriveCurrentFolderAtom } from '@views/client/body/drive/browser';
import { useHistory } from 'react-router-dom';
import RouterServices from '@features/router/services/router-service';
import { useCurrentUser } from 'app/features/users/hooks/use-current-user';
import useRouterCompany from 'app/features/router/hooks/use-router-company';
import { DocumentIcon } from '@views/client/body/drive/documents/document-icon';

export default (props: { driveItem: DriveItem & { user?: UserType }}) => {
const history = useHistory();
const input = useRecoilValue(SearchInputState);
const { user } = useCurrentUser();
const [_, setParentId] = useRecoilState(DriveCurrentFolderAtom({ initialFolderId: 'user_'+user?.id }));
const file = props.driveItem;
const name = file?.name;
const extension = name?.split('.').pop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
type TreeItem = { [key: string]: File | TreeItem };

export type FileTreeObject = {
Expand Down
2 changes: 1 addition & 1 deletion tdrive/frontend/src/app/deprecated/user/CurrentUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import AlertManager from '@features/global/services/alert-manager-service';
import Languages from '@features/global/services/languages-service';
import JWTStorage from '@features/auth/jwt-storage-service';
import Globals from '@features/global/services/globals-tdrive-app-service';
import { useCurrentUser } from '@features/users/hooks/use-current-user';
import UserAPIClient from '../../features/users/api/user-api-client';
import { getUser } from '@features/users/hooks/use-user-list';

Expand Down Expand Up @@ -68,6 +67,7 @@ class CurrentUser extends Observable {
const data = {
status: user.tutorial_status,
};
// eslint-disable-next-line @typescript-eslint/no-empty-function
Api.post('/ajax/users/account/set_tutorial_status', data, () => {});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
onChangeCompanyApplications,
} from '../state/company-applications';
import CompanyApplicationsAPIClient from 'app/features/applications/api/company-applications-api-client';
import { useCurrentCompany } from '../../companies/hooks/use-companies';
import { Application } from 'app/features/applications/types/application';
import { LoadingState } from 'app/features/global/state/atoms/Loading';
import useRouterWorkspace from 'app/features/router/hooks/use-router-workspace';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { atomFamily, selectorFamily } from 'recoil';

import { Application } from 'app/features/applications/types/application';
import Collections from 'app/deprecated/CollectionsV1/Collections/Collections';
import _ from 'lodash';

//Retro compatibility
Expand Down
2 changes: 0 additions & 2 deletions tdrive/frontend/src/app/features/companies/state/companies.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { atomFamily } from 'recoil';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';

import { CompanyType } from '@features/companies/types/company';
import CompanyAPIClient from '@features/companies/api/company-api-client';
import _ from 'lodash';

const companies: { [key: string]: CompanyType } = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Languages from '@features/global/services/languages-service';
import { ToasterService as Toaster } from '@features/global/services/toaster-service';
import { ConsoleMemberRole } from '@features/console/types/types';
import Logger from '@features/global/framework/logger-service';
import { JWTDataType } from '@features/auth/jwt-storage-service';

class ConsoleService {
logger: Logger.Logger;
Expand Down
4 changes: 2 additions & 2 deletions tdrive/frontend/src/app/features/dragndrop/hook/draggable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { MouseEventHandler } from 'react';
import React from 'react';
import {useDraggable} from '@dnd-kit/core';

type DraggableProps={
Expand All @@ -7,7 +7,7 @@ type DraggableProps={
}

export function Draggable(props:DraggableProps) {
const {attributes, listeners, setNodeRef, transform} = useDraggable({
const { attributes, listeners, setNodeRef } = useDraggable({
id: `draggable-${props.id+1}`,
data: {
child: props.children
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
const companyId = useRouterCompany();
const sharedFilter = useRecoilValue(SharedWithMeFilterState);
const sortItem = useRecoilValue(DriveItemSort);
const [paginateItem, _] = useRecoilState(DriveItemPagination);
const [ paginateItem ] = useRecoilState(DriveItemPagination);
const { getQuota } = useUserQuota();

const refresh = useRecoilCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ToasterService } from '@features/global/services/toaster-service';
import { LoadingStateInitTrue } from '@features/global/state/atoms/Loading';
import useRouterCompany from '@features/router/hooks/use-router-company';
import { useCallback, useState } from 'react';
import { useCallback } from 'react';
import { useRecoilCallback, useRecoilState, useRecoilValue } from 'recoil';
import { DriveItemAtom, DriveItemChildrenAtom, DriveItemPagination } from '../state/store';
import { DriveItem } from '../types';
Expand All @@ -20,7 +20,7 @@ export const useDriveItem = (id: string) => {
// const children = useRecoilValue(DriveItemChildrenAtom(id));
const [children, setChildren] = useRecoilState(DriveItemChildrenAtom(id));
const [loading, setLoading] = useRecoilState(LoadingStateInitTrue('useDriveItem-' + id));
const [_, setPaginateItem] = useRecoilState(DriveItemPagination);
const [, setPaginateItem] = useRecoilState(DriveItemPagination);
const {
refresh: refreshItem,
create,
Expand Down Expand Up @@ -171,6 +171,7 @@ export const useDriveItem = (id: string) => {
updateLevel,
remove,
refresh,
restore,
loadNextPage,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import { useRecoilState } from 'recoil';
import { DriveApiClient } from '../api-client/api-client';
import { DriveViewerState } from '../state/viewer';
import { DriveItem } from '../types';
import { useHistory } from 'react-router-dom';
import RouterServices from '@features/router/services/router-service';
import useRouterCompany from '@features/router/hooks/use-router-company';
import { DriveCurrentFolderAtom } from 'app/views/client/body/drive/browser';
import { useCurrentUser } from 'app/features/users/hooks/use-current-user';

export const useDrivePreviewModal = () => {
const history = useHistory();
const company = useRouterCompany();
const [status, setStatus] = useRecoilState(DriveViewerState);
const { user } = useCurrentUser();
const [ parentId, setParentId ] = useRecoilState(
const [ , setParentId ] = useRecoilState(
DriveCurrentFolderAtom({ initialFolderId: 'user_'+user?.id }),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { string } from 'prop-types';
import { atom } from 'recoil';

export type SharedWithMeFilter = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useSearchDriveItems = () => {
const [loading, setLoading] = useRecoilState(LoadingState('useSearchDriveItems'));

const [searched, setSearched] = useRecoilState(SearchDriveItemsResultsState(companyId));
const [recent, setRecent] = useRecoilState(RecentDriveItemsState(companyId));
const [, setRecent] = useRecoilState(RecentDriveItemsState(companyId));

const opt = _.omitBy(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useRef } from "react";
import { useEffect } from "react";
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 Languages from '@features/global/services/languages-service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { atomFamily, selectorFamily, useSetRecoilState } from 'recoil';
import { WorkspaceType } from '@features/workspaces/types/workspace';
import WorkspaceAPIClient from '@features/workspaces/api/workspace-api-client';
import Logger from '@features/global/framework/logger-service';
import _ from 'lodash';
import Collections from '@deprecated/CollectionsV1/Collections/Collections';

const logger = Logger.getLogger('WorkspaceListState');

Expand Down
14 changes: 5 additions & 9 deletions tdrive/frontend/src/app/views/client/body/drive/browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { useDriveUpload } from '@features/drive/hooks/use-drive-upload';
import { DriveItemSelectedList, DriveItemSort } from '@features/drive/state/store';
import { formatBytes } from '@features/drive/utils';
import useRouterCompany from '@features/router/hooks/use-router-company';
import _, { set } from 'lodash';
import _ from 'lodash';
import { memo, Suspense, useCallback, useEffect, useRef, useState } from 'react';
import { atomFamily, useRecoilState, useSetRecoilState, useRecoilValue } from 'recoil';
import { atomFamily, useRecoilState, useSetRecoilState } from 'recoil';
import { DrivePreview } from '../../viewer/drive-preview';
import {
useOnBuildContextMenu,
Expand Down Expand Up @@ -40,7 +40,7 @@ import useRouteState from 'app/features/router/hooks/use-route-state';
import { SharedWithMeFilterState } from '@features/drive/state/shared-with-me-filter';
import MenusManager from '@components/menus/menus-manager.jsx';
import Languages from 'features/global/services/languages-service';
import {DndContext, useSensors, useSensor, PointerSensor, DragOverlay} from '@dnd-kit/core';
import { DndContext, useSensors, useSensor, PointerSensor, DragOverlay } from '@dnd-kit/core';
import { Droppable } from 'app/features/dragndrop/hook/droppable';
import { Draggable } from 'app/features/dragndrop/hook/draggable';
import { useDriveActions } from '@features/drive/hooks/use-drive-actions';
Expand All @@ -49,7 +49,6 @@ import { useCurrentUser } from 'app/features/users/hooks/use-current-user';
import { ConfirmModal } from './modals/confirm-move';
import { useHistory } from 'react-router-dom';
import { SortIcon } from 'app/atoms/icons-agnostic';
import { useDrivePreview, useDrivePreviewLoading } from 'app/features/drive/hooks/use-drive-preview';

export const DriveCurrentFolderAtom = atomFamily<
string,
Expand Down Expand Up @@ -78,12 +77,9 @@ export default memo(
? (user?.companies || []).find(company => company?.company.id === companyId)?.role
: 'member';
setTdriveTabToken(tdriveTabContextToken || null);
const [filter, __] = useRecoilState(SharedWithMeFilterState);
const { viewId, dirId, itemId } = useRouteState();
const { status } = useDrivePreview();
const { openWithId, close } = useDrivePreview();
const [ filter ] = useRecoilState(SharedWithMeFilterState);
const { viewId, dirId } = useRouteState();
const [sortLabel] = useRecoilState(DriveItemSort)
const { loading: isModalLoading } = useDrivePreviewLoading();
const [parentId, _setParentId] = useRecoilState(
DriveCurrentFolderAtom({
context: context,
Expand Down
19 changes: 6 additions & 13 deletions tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import { copyToClipboard } from '@features/global/utils/CopyClipboard';
import { SharedWithMeFilterState } from '@features/drive/state/shared-with-me-filter';
import { getCurrentUserList } from '@features/users/hooks/use-user-list';
import useRouteState from 'app/features/router/hooks/use-route-state';
import RouterServices from '@features/router/services/router-service';
import useRouterCompany from '@features/router/hooks/use-router-company';
import _, { set } from 'lodash';
import _ from 'lodash';
import Languages from 'features/global/services/languages-service';
import { hasAnyPublicLinkAccess } from '@features/files/utils/access-info-helpers';
import FeatureTogglesService, {
Expand All @@ -42,7 +40,7 @@ export const useOnBuildContextMenu = (
const [checkedIds, setChecked] = useRecoilState(DriveItemSelectedList);
const checked = children.filter(c => checkedIds[c.id]);

const [_, setParentId] = useRecoilState(
const [setParentId] = useRecoilState(
DriveCurrentFolderAtom({ initialFolderId: initialParentId || 'root' }),
);

Expand All @@ -59,11 +57,6 @@ export const useOnBuildContextMenu = (
const setUsersModalState = useSetRecoilState(UsersModalAtom);
const { open: preview } = useDrivePreview();
const { viewId } = useRouteState();
const company = useRouterCompany();

function getIdsFromArray(arr: DriveItem[]): string[] {
return arr.map(obj => obj.id);
}

return useCallback(
async (parent?: Partial<DriveItemDetails> | null, item?: DriveItem) => {
Expand Down Expand Up @@ -378,7 +371,7 @@ export const useOnBuildContextMenu = (
};

export const useOnBuildFileTypeContextMenu = () => {
const [filter, setFilter] = useRecoilState(SharedWithMeFilterState);
const [, setFilter] = useRecoilState(SharedWithMeFilterState);
const mimeTypes = [
{ key: Languages.t('components.item_context_menu.all'), value: '' },
{ key: 'CSV', value: 'text/csv' },
Expand Down Expand Up @@ -414,8 +407,8 @@ export const useOnBuildFileTypeContextMenu = () => {
};

export const useOnBuildPeopleContextMenu = () => {
const [filter, setFilter] = useRecoilState(SharedWithMeFilterState);
const [_userList, setUserList] = useState(getCurrentUserList());
const [, setFilter] = useRecoilState(SharedWithMeFilterState);
const [_userList] = useState(getCurrentUserList());
let userList = _userList;
userList = _.uniqBy(userList, 'id');
return useCallback(() => {
Expand All @@ -439,7 +432,7 @@ export const useOnBuildPeopleContextMenu = () => {
};

export const useOnBuildDateContextMenu = () => {
const [filter, setFilter] = useRecoilState(SharedWithMeFilterState);
const [, setFilter] = useRecoilState(SharedWithMeFilterState);
return useCallback(() => {
const menuItems = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type DriveItemProps = {
checked: boolean;
onClick?: () => void;
onBuildContextMenu: () => Promise<any[]>;
inPublicSharing?: boolean;
};

export type DriveItemOverlayProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import Menu from '@components/menus/menu';
import useRouterCompany from '@features/router/hooks/use-router-company';
import { useDrivePreview } from '@features/drive/hooks/use-drive-preview';
import { formatBytes } from '@features/drive/utils';
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { PublicIcon } from '../components/public-icon';
import { CheckableIcon, DriveItemOverlayProps, DriveItemProps } from './common';
import './style.scss';
import { useHistory } from 'react-router-dom';
import RouterServices from '@features/router/services/router-service';
import useRouteState from 'app/features/router/hooks/use-route-state';
import { DocumentIcon } from './document-icon';
import { hasAnyPublicLinkAccess } from '@features/files/utils/access-info-helpers';
import { formatDateShort } from 'app/features/global/utils/Numbers';
Expand All @@ -23,11 +22,10 @@ export const DocumentRow = ({
checked,
onClick,
onBuildContextMenu,
inPublicSharing,
}: DriveItemProps) => {
const history = useHistory();
const [hover, setHover] = useState(false);
const { open, close, isOpen } = useDrivePreview();
const {open} = useDrivePreview();
const company = useRouterCompany();

const preview = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DesktopComputerIcon } from '@heroicons/react/solid';
import { Base } from '@atoms/text';

export const DriveItem = ({ className, onClick }: { className?: string; onClick: Function }) => {
export const DriveItem = ({ className, onClick }: { className?: string; onClick: () => void }) => {
return (
<div
className={
Expand Down
Loading

0 comments on commit 26ca1be

Please sign in to comment.