Skip to content

Commit

Permalink
馃洜 Fixing bug 2022 07 (#2378)
Browse files Browse the repository at this point in the history
* Fix #2373

* Fix #2361 #2362 #2372

* Keep showing channels in channel scope mode

* Fix some bugs from #2374

* Fix linter
  • Loading branch information
RomaricMourgues committed Jul 1, 2022
1 parent 52e3ef9 commit 3293cdd
Show file tree
Hide file tree
Showing 21 changed files with 142 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ export const OpenDesktopPopup = (): React.ReactElement => {
}, []);

return (
<div className="flex flex-col items-center justify-center h-full overflow-hidden space-y-2">
<div className="flex flex-col items-center justify-center h-full overflow-hidden">
<Logo />
<Subtitle className="mt-6">{Languages.t('components.open_desktop_popup.subtitle')}</Subtitle>
<Subtitle className="mt-4 mb-2 block">
{Languages.t('components.open_desktop_popup.subtitle')}
</Subtitle>
{showLink && (
<A onClick={() => setUseWeb(true)}>
{Languages.t('components.open_desktop_popup.open_here_link')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export default ({
return (
<div className="flex overflow-hidden whitespace-nowrap text-ellipsis">
{!!user && <>{UsersService.getFullName(user)}</>}
{!!user && !!(channel || workspaceName) && ' -> '}
{!!user && !!(channel || workspaceName) && <span className="mx-2"> {'->'} </span>}
{(channel || workspaceName) && (
<>
{!!workspaceName && <span className="opacity-50 mx-2">{workspaceName}</span>}
{!!workspaceName && !!channel?.name && ' / '}
{!!workspaceName && <span className="opacity-50">{workspaceName}</span>}
{!!workspaceName && !!channel?.name && <span className="mx-2"> / </span>}
{!!channel?.name && (
<A
onClick={(e: any) => {
Expand Down
14 changes: 7 additions & 7 deletions twake/frontend/src/app/components/search-popup/search-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export const SearchResultsIndex = () => {
{hasInput && <SearchCounterBadge count={files.length} />}
</div>
</div>,
...(!input.channelId
? [
<div key="channels">
<ChannelsTab />
</div>,
]
: []),
.../*!input.channelId
?*/ [
<div key="channels">
<ChannelsTab />
</div>,
],
/*: []*/
]}
selected={orderedTabs.indexOf(tab)}
onClick={idx => setTab(orderedTabs[idx] as any)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default () => {

return (
<div className="-mt-4">
{!input.channelId && channels.length > 0 && (
{(!input.channelId || true) && channels.length > 0 && (
<>
<div className="flex mt-4">
<Text.Subtitle className="block grow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ChannelAPIClientService {
async get(companyId: string, workspaceId: string, channelId: string): Promise<ChannelType> {
return Api.get<{ resource: ChannelType }>(
`${PREFIX}/${companyId}/workspaces/${workspaceId}/channels/${channelId}`,
).then(result => result.resource);
).then(result => result?.resource);
}

async save(
Expand Down
32 changes: 17 additions & 15 deletions twake/frontend/src/app/features/channels/hooks/use-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,30 @@ export function useChannel(
setLoading(false);
};

const refresh = async () => {
setLoading(true);
const ch = await ChannelAPIClient.get(companyId, workspaceId, channelId);
if (ch && ch?.id) {
set(ch);
} else {
set({
id: channelId,
name: '',
visibility: 'private',
});
}
setLoading(false);
};

useGlobalEffect(
hookId,
async () => {
if (!channel) {
setLoading(true);
const ch = await ChannelAPIClient.get(companyId, workspaceId, channelId);
if (ch && ch?.id) {
set(ch);
} else {
set({
id: channelId,
name: 'You cannot access this content',
visibility: 'private',
});
}
setLoading(false);
}
if (!channel) refresh();
},
[],
);

return { channel, save, loading };
return { channel, save, loading, refresh };
}

export const useIsChannelMember = (channelId: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ export default class Api {
'',
(resp: any) => {
const result = raw ? resp : JSON.parse(resp);
if (result.statusCode === 500) {
if (resp.statusCode === 500) {
callback && callback(result);
return reject(result);
}

resolve(result);
callback && callback(result);
resolve({ ...result, _statusCode: resp.statusCode });
callback && callback({ ...result, _statusCode: resp.statusCode });
},
options,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ export const useMessageEditor = (key: EditorKey) => {
export const cleanFrontMessagesFromListOfMessages = (
messages: (AtomMessageKey | MessagesAndComponentsType)[],
) => {
messages = messages.filter(
i =>
(i as MessagesAndComponentsType)?.type !== 'message' ||
getMessage(i.id || '')?._status !== 'sent',
);
messages = messages.filter(i => {
if (getMessage(i.id || '') && getMessage(i.id || '')?._status !== 'sent') return true;

if (getMessage(i.id || '')?._status !== undefined) {
//This message was created in frontend
//If this message was retrieved from the backend, then we should not keep the frontend one
return !messages.find(
j =>
getMessage(j.id || '')?.context?._front_id ===
getMessage(i.id || '')?.context?._front_id && j.id !== i.id,
);
}
});
messages = _.uniqBy(
messages,
a =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ export const searchFrontend = (

if (!query) {
// TODO return list with users sorted by favorite
// eslint-disable-next-line no-self-assign
result = result;
}

if (scope === 'company') {
Expand Down
21 changes: 9 additions & 12 deletions twake/frontend/src/app/features/users/hooks/use-user-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ export const getUser = (userId: string) => {
return currentUserList.filter(u => u.id === userId)[0];
};

const completeUserWithCompanies = (user: UserType, companies?: UserCompanyType[]): UserType => ({
...user,
companies: companies !== undefined ? companies : user.companies || [],
});
const completeUserWithCompanies = (user: UserType, companies?: UserCompanyType[]): UserType => {
return {
...user,
companies: companies !== undefined ? companies : user.companies || [],
};
};

const completeUserWithWorkspaces = (
user: UserType,
Expand All @@ -72,15 +74,10 @@ export function useSetUserList(key: string) {
const currentList = currentUserList;

if (nextList && nextList.length) {
const newList = concat(
currentList.filter(u => !nextList.map(u => u.id).includes(u.id)),
nextList,
)
const newList = _.uniqBy([...currentList, ...nextList], 'id')
.map(u => cloneDeep(u))
.map(u => completeUserWithCompanies(u, currentList.find(obj => obj.id === u.id)?.companies))
.map(u =>
completeUserWithWorkspaces(u, currentList.find(obj => obj.id === u.id)?.workspaces),
);
.map(u => completeUserWithCompanies(u, nextList.find(obj => obj.id === u.id)?.companies))
.map(u => completeUserWithWorkspaces(u, nextList.find(obj => obj.id === u.id)?.workspaces));

newList.sort();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ export default React.memo(
setFirstItemIndex(() => nextFirstItemIndex);
setItems([...newItems, ...items]);
} else {
//Nothing changed
if (
_.intersection(
items.map(i => itemId(i)),
_items.map(i => itemId(i)),
).length > 0
) {
const newList = [...items, ..._items];
if (filterOnAppend) setItems(filterOnAppend(newList));
}
}
}, [_items]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default (props: Props) => {
}}
onClick={() => setActive(false)}
>
{message._status + ' - ' + message.id + ' - ' + message.thread_id}
<MessageHeader linkToThread={props.linkToThread} />
{!!showEdition && !deleted && (
<div className="content-parent">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import Shortcuts, {
} from 'app/features/global/services/shortcut-service';
import AddUserButton from 'components/add-user-button/add-user-button';
import Workspaces from 'app/deprecated/workspaces/workspaces';
import ModalManager from 'app/components/modal/modal-manager';
import WorkspaceChannelList from './Modals/WorkspaceChannelList';
import ScrollWithHiddenComponents from 'app/components/scroll-hidden-components/scroll-with-hidden-components';
import HiddenNotificationsButton from 'app/components/scroll-hidden-components/hidden-notifications-button';
import AccessRightsService from 'app/features/workspace-members/services/workspace-members-access-rights-service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import ChannelIntermediate from '../Parts/Channel/ChannelIntermediate';
import ChannelsBarService from 'app/features/channels/services/channels-bar-service';
import AccessRightsService from 'app/features/workspace-members/services/workspace-members-access-rights-service';
import { useDirectChannels } from 'app/features/channels/hooks/use-direct-channels';
import { Modal } from 'app/atoms/modal';

export default () => {
const { companyId } = RouterServices.getStateFromRoute();
const { directChannels } = useDirectChannels();
const [max, setMax] = useState(20);
const [openDirect, setOpenDirect] = useState(false);

const openConv = () => {
return MediumPopupComponent.open(<NewDirectMessagesPopup />, {
position: 'center',
size: { width: '400px' },
});
setOpenDirect(true);
};

const [delayed, setDelayed] = useState(true);
Expand All @@ -41,6 +40,10 @@ export default () => {

return (
<div className="users_channels">
<Modal open={openDirect} onClose={() => setOpenDirect(false)}>
<NewDirectMessagesPopup onClose={() => setOpenDirect(false)} />
</Modal>

<ChannelCategory
refAdd={(node: any) => {
// eslint-disable-next-line no-self-assign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ChannelCategory from '../Parts/Channel/ChannelCategory';
import ChannelIntermediate from '../Parts/Channel/ChannelIntermediate';

import ChannelWorkspaceEditor from 'app/views/client/channels-bar/Modals/ChannelWorkspaceEditor';
import WorkspaceChannelList from 'app/views/client/channels-bar/Modals/WorkspaceChannelList';

import Menu from 'components/menus/menu.js';
import Icon from 'app/components/icon/icon';
Expand Down
Loading

0 comments on commit 3293cdd

Please sign in to comment.