mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fix some rendering flicker on conversation titile
This commit is contained in:
parent
e054496827
commit
498413642a
@ -161,7 +161,6 @@ test('testing', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const renderCount = screen.getByTestId('profile').props.renderCount;
|
const renderCount = screen.getByTestId('profile').props.renderCount;
|
||||||
console.log("RENDER COUNT:", renderCount);
|
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
identity = { name: 'renderer' };
|
identity = { name: 'renderer' };
|
||||||
@ -169,8 +168,6 @@ console.log("RENDER COUNT:", renderCount);
|
|||||||
await profile.actions.setRevision(2048);
|
await profile.actions.setRevision(2048);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(renderCount);
|
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
expect(screen.getByTestId('profile').props.renderCount).toBe(renderCount + 1);
|
expect(screen.getByTestId('profile').props.renderCount).toBe(renderCount + 1);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Input, List } from 'antd';
|
import { Input, List, Button } from 'antd';
|
||||||
import { CardsWrapper } from './Cards.styled';
|
import { CardsWrapper } from './Cards.styled';
|
||||||
import { SortAscendingOutlined, UpOutlined, DoubleRightOutlined, UserOutlined, SearchOutlined } from '@ant-design/icons';
|
import { SortAscendingOutlined, UpOutlined, DoubleRightOutlined, UserOutlined, SearchOutlined } from '@ant-design/icons';
|
||||||
import { useCards } from './useCards.hook';
|
import { useCards } from './useCards.hook';
|
||||||
@ -27,10 +27,7 @@ export function Cards({ closeCards, openContact, openListing }) {
|
|||||||
</div>
|
</div>
|
||||||
{ state.display === 'small' && (
|
{ state.display === 'small' && (
|
||||||
<div className="inline">
|
<div className="inline">
|
||||||
<div className="add" onClick={openListing}>
|
<Button type="primary" icon={<UserOutlined />} onClick={openListing}>Add</Button>
|
||||||
<UserOutlined />
|
|
||||||
<div className="label">New</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{ state.display !== 'small' && (
|
{ state.display !== 'small' && (
|
||||||
|
@ -10,7 +10,7 @@ export function useCards() {
|
|||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
tooltip: false,
|
tooltip: false,
|
||||||
sorted: false,
|
sorted: false,
|
||||||
display: null,
|
display: 'small',
|
||||||
cards: [],
|
cards: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,6 +22,11 @@ export function useCards() {
|
|||||||
setState((s) => ({ ...s, ...value }));
|
setState((s) => ({ ...s, ...value }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const { display } = viewport.state;
|
||||||
|
updateState({ display });
|
||||||
|
}, [viewport.state]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const contacts = Array.from(card.state.cards.values()).map(item => {
|
const contacts = Array.from(card.state.cards.values()).map(item => {
|
||||||
const profile = item?.data?.cardProfile;
|
const profile = item?.data?.cardProfile;
|
||||||
|
@ -3,6 +3,7 @@ import { ChannelHeaderWrapper, StatusError } from './ChannelHeader.styled';
|
|||||||
import { ExclamationCircleOutlined, SettingOutlined, CloseOutlined } from '@ant-design/icons';
|
import { ExclamationCircleOutlined, SettingOutlined, CloseOutlined } from '@ant-design/icons';
|
||||||
import { Tooltip } from 'antd';
|
import { Tooltip } from 'antd';
|
||||||
import { Logo } from 'logo/Logo';
|
import { Logo } from 'logo/Logo';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export function ChannelHeader({ closeConversation, openDetails, contentKey }) {
|
export function ChannelHeader({ closeConversation, openDetails, contentKey }) {
|
||||||
|
|
||||||
|
@ -99,9 +99,14 @@ export function useChannelHeader(contentKey) {
|
|||||||
let title;
|
let title;
|
||||||
try {
|
try {
|
||||||
const detail = channelValue?.data?.channelDetail;
|
const detail = channelValue?.data?.channelDetail;
|
||||||
if (detail?.dataType === 'sealed' && contentKey) {
|
if (detail?.dataType === 'sealed') {
|
||||||
const unsealed = decryptChannelSubject(detail.data, contentKey);
|
if (contentKey) {
|
||||||
title = unsealed.subject;
|
const unsealed = decryptChannelSubject(detail.data, contentKey);
|
||||||
|
title = unsealed.subject;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
title = '...';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (detail?.dataType === 'superbasic') {
|
else if (detail?.dataType === 'superbasic') {
|
||||||
const data = JSON.parse(detail.data);
|
const data = JSON.parse(detail.data);
|
||||||
|
@ -51,7 +51,7 @@ export function useConversation(cardId, channelId) {
|
|||||||
const seals = getChannelSeals(data);
|
const seals = getChannelSeals(data);
|
||||||
if (isUnsealed(seals, sealKey)) {
|
if (isUnsealed(seals, sealKey)) {
|
||||||
const contentKey = getContentKey(seals, sealKey);
|
const contentKey = getContentKey(seals, sealKey);
|
||||||
updateState({ sealed: true, contentKey });
|
updateState({ sealed: true, wtf: true, contentKey });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
updateState({ sealed: true, contentKey: null });
|
updateState({ sealed: true, contentKey: null });
|
||||||
@ -105,7 +105,6 @@ export function useConversation(cardId, channelId) {
|
|||||||
const { card, channel } = conversationId.current;
|
const { card, channel } = conversationId.current;
|
||||||
loading.current = true;
|
loading.current = true;
|
||||||
conversationId.current = null;
|
conversationId.current = null;
|
||||||
updateState({ contentKey: null });
|
|
||||||
await conversation.actions.setChannel(card, channel);
|
await conversation.actions.setChannel(card, channel);
|
||||||
loading.current = false;
|
loading.current = false;
|
||||||
await setChannel();
|
await setChannel();
|
||||||
@ -258,7 +257,6 @@ export function useConversation(cardId, channelId) {
|
|||||||
updateTopic: async (topic, text) => {
|
updateTopic: async (topic, text) => {
|
||||||
const { assets, textSize, textColor } = topic;
|
const { assets, textSize, textColor } = topic;
|
||||||
const message = { text, textSize, textColor, assets };
|
const message = { text, textSize, textColor, assets };
|
||||||
console.log("UPDATE", message);
|
|
||||||
|
|
||||||
if (!state.busy) {
|
if (!state.busy) {
|
||||||
updateState({ busy: true });
|
updateState({ busy: true });
|
||||||
|
@ -129,7 +129,7 @@ export function Details({ closeDetails, closeConversation, openContact }) {
|
|||||||
<DetailsWrapper>
|
<DetailsWrapper>
|
||||||
{ modalContext }
|
{ modalContext }
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="label">Topic</div>
|
<div class="label">Topic Details</div>
|
||||||
{ state.display === 'xlarge' && (
|
{ state.display === 'xlarge' && (
|
||||||
<div class="dismiss" onClick={closeConversation}>
|
<div class="dismiss" onClick={closeConversation}>
|
||||||
<DoubleRightOutlined />
|
<DoubleRightOutlined />
|
||||||
|
@ -25,7 +25,7 @@ export function useDetails() {
|
|||||||
showEditSubject: false,
|
showEditSubject: false,
|
||||||
editSubject: null,
|
editSubject: null,
|
||||||
|
|
||||||
display: null,
|
display: 'small',
|
||||||
sealed: false,
|
sealed: false,
|
||||||
contentKey: null,
|
contentKey: null,
|
||||||
seals: null,
|
seals: null,
|
||||||
@ -167,9 +167,14 @@ export function useDetails() {
|
|||||||
let title;
|
let title;
|
||||||
try {
|
try {
|
||||||
const detail = channelValue?.data?.channelDetail;
|
const detail = channelValue?.data?.channelDetail;
|
||||||
if (detail?.dataType === 'sealed' && state.contentKey) {
|
if (detail?.dataType === 'sealed') {
|
||||||
const unsealed = decryptChannelSubject(detail.data, state.contentKey);
|
if (state.contentKey) {
|
||||||
title = unsealed.subject;
|
const unsealed = decryptChannelSubject(detail.data, state.contentKey);
|
||||||
|
title = unsealed.subject;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
title = '...';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (detail?.dataType === 'superbasic') {
|
else if (detail?.dataType === 'superbasic') {
|
||||||
const data = JSON.parse(detail.data);
|
const data = JSON.parse(detail.data);
|
||||||
|
Loading…
Reference in New Issue
Block a user