fixing layout issues with list

This commit is contained in:
Roland Osborne 2022-08-23 22:58:33 -07:00
parent 53de020d74
commit 0501884708
6 changed files with 61 additions and 44 deletions

View File

@ -134,12 +134,14 @@ export function Carousel({ pad, ready, error, items, itemRenderer, itemRemove })
</div> </div>
)} )}
{ ready && !error && ( { ready && !error && (
<>
<div class="carousel" style={{ paddingLeft: pad + 32 }} ref={onRefSet}> <div class="carousel" style={{ paddingLeft: pad + 32 }} ref={onRefSet}>
{slots} {slots}
</div> </div>
)}
<div class="left-arrow" onClick={onRight} style={{ marginLeft: pad, visibility: scrollRight }}><LeftOutlined /></div> <div class="left-arrow" onClick={onRight} style={{ marginLeft: pad, visibility: scrollRight }}><LeftOutlined /></div>
<div class="right-arrow" onClick={onLeft} style={{ visibility: scrollLeft }}><RightOutlined /></div> <div class="right-arrow" onClick={onLeft} style={{ visibility: scrollLeft }}><RightOutlined /></div>
</>
)}
</CarouselWrapper> </CarouselWrapper>
); );
} }

View File

@ -27,6 +27,7 @@ export const CarouselWrapper = styled.div`
justify-content: center; justify-content: center;
color: #888888; color: #888888;
background-color: #eeeeee; background-color: #eeeeee;
margin-left: 72px;
} }
.carousel::-webkit-scrollbar { .carousel::-webkit-scrollbar {

View File

@ -310,6 +310,13 @@ export function useCardContext() {
else { else {
await addContactChannelTopic(node, token, channelId, message, files); await addContactChannelTopic(node, token, channelId, message, files);
} }
try {
resync.current.push(cardId);
await setCards(null);
}
catch (err) {
console.log(err);
}
}, },
getChannel: (cardId, channelId) => { getChannel: (cardId, channelId) => {
let card = cards.current.get(cardId); let card = cards.current.get(cardId);

View File

@ -68,9 +68,14 @@ export function useChannelContext() {
} }
const setChannels = async (rev) => { const setChannels = async (rev) => {
let force = false;
if (rev == null) {
force = true;
rev = revision.current;
}
if (next.current == null) { if (next.current == null) {
next.current = rev; next.current = rev;
if (revision.current !== rev) { if (force || revision.current !== rev) {
await updateChannels(); await updateChannels();
updateState({ init: true, channels: channels.current }); updateState({ init: true, channels: channels.current });
revision.current = rev; revision.current = rev;
@ -138,6 +143,12 @@ export function useChannelContext() {
else { else {
await addChannelTopic(access.current, channelId, message, files); await addChannelTopic(access.current, channelId, message, files);
} }
try {
await setChannels(null);
}
catch (err) {
console.log(err);
}
}, },
getChannel: (channelId) => { getChannel: (channelId) => {
return channels.current.get(channelId); return channels.current.get(channelId);

View File

@ -24,6 +24,7 @@ export function AddTopic({ cardId, channelId }) {
} }
const addTopic = async () => { const addTopic = async () => {
if (state.messageText || state.assets.length) {
try { try {
await actions.addTopic(); await actions.addTopic();
} }
@ -34,6 +35,7 @@ export function AddTopic({ cardId, channelId }) {
content: 'Please try again.', content: 'Please try again.',
}); });
} }
}
}; };
const onSelectImage = (e) => { const onSelectImage = (e) => {

View File

@ -96,26 +96,6 @@ export function TopicItem({ host, topic }) {
return <div style={{ color: state.textColor, fontSize: state.textSize }}>{ state.message?.text }</div> return <div style={{ color: state.textColor, fontSize: state.textSize }}>{ state.message?.text }</div>
} }
if (!state.confirmed) {
return (
<TopicItemWrapper>
<div class="avatar">
<Logo width={32} height={32} radius={4} url={state.imageUrl} />
</div>
<div class="topic">
<div class="info">
<div class={nameClass}>{ name }</div>
<div>{ getTime(offset) }</div>
</div>
<Skeleton size={'small'} active={true} />
<div class="options">
<Options />
</div>
</div>
</TopicItemWrapper>
)
}
return ( return (
<TopicItemWrapper> <TopicItemWrapper>
<div class="topic-header"> <div class="topic-header">
@ -127,6 +107,18 @@ export function TopicItem({ host, topic }) {
<div>{ getTime(offset) }</div> <div>{ getTime(offset) }</div>
</div> </div>
</div> </div>
{ !state.confirmed && (
<div>
<div class="message">
<Skeleton size={'small'} active={true} />
</div>
<div class="options">
<Options />
</div>
</div>
)}
{ state.confirmed && (
<div>
{ state.assets.length > 0 && ( { state.assets.length > 0 && (
<div class="topic-assets"> <div class="topic-assets">
<Carousel pad={40} ready={state.ready} error={state.error} items={state.assets} itemRenderer={renderAsset} /> <Carousel pad={40} ready={state.ready} error={state.error} items={state.assets} itemRenderer={renderAsset} />
@ -138,6 +130,8 @@ export function TopicItem({ host, topic }) {
<div class="options"> <div class="options">
<Options /> <Options />
</div> </div>
</div>
)}
</TopicItemWrapper> </TopicItemWrapper>
) )
} }