Skip to content

Commit 54bfd73

Browse files
Update chat scroll (#10182)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
1 parent 7d1ab03 commit 54bfd73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1003
-700
lines changed

dev/tool/src/communication.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,10 @@ async function migrateMessages (
746746
): Promise<void> {
747747
if (cards.length === 0) return
748748

749-
for (const card of cards) {
750-
await createGroupsBlob(hulylake, card._id)
749+
if (doc.__migratedUntil == null) {
750+
for (const card of cards) {
751+
await createGroupsBlob(hulylake, card._id)
752+
}
751753
}
752754
const iterator = await getActivityCursor(db, ws.uuid, doc._id, chunter.class.ChatMessage, 400, doc.__migratedUntil)
753755

@@ -1139,6 +1141,16 @@ function toMessage (r: any): RawMessage | undefined {
11391141
}
11401142

11411143
function toAttachment (a: any): RawAttachment | undefined {
1144+
let metadata = a.metadata ?? {}
1145+
1146+
if (typeof metadata === 'string') {
1147+
try {
1148+
metadata = JSON.parse(metadata)
1149+
} catch (e) {
1150+
metadata = {}
1151+
}
1152+
}
1153+
11421154
try {
11431155
return {
11441156
_id: a._id,
@@ -1147,7 +1159,7 @@ function toAttachment (a: any): RawAttachment | undefined {
11471159
type: a.type,
11481160
name: a.name,
11491161
size: Number(a.size ?? 0),
1150-
metadata: a.metadata ?? {},
1162+
metadata,
11511163
file: a.file
11521164
}
11531165
} catch (e) {

models/chat/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import core from '@hcengineering/model-core'
1818
import workbench from '@hcengineering/model-workbench'
1919
import { chatId } from '@hcengineering/chat'
2020
import { createSystemType } from '@hcengineering/model-card'
21-
import communication, { MessagesNavigationAnchors } from '@hcengineering/communication'
21+
import communication from '@hcengineering/communication'
2222
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
2323

2424
import chat from './plugin'
@@ -55,8 +55,7 @@ export function createModel (builder: Builder): void {
5555
chat.string.Thread,
5656
chat.string.Threads,
5757
{
58-
defaultSection: communication.ids.CardMessagesSection,
59-
defaultNavigation: MessagesNavigationAnchors.LatestMessages
58+
defaultSection: communication.ids.CardMessagesSection
6059
},
6160
PaletteColorIndexes.Houseplant
6261
)

models/communication/src/index.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// limitations under the License.
1313

1414
import { type Builder } from '@hcengineering/model'
15-
import core from '@hcengineering/core'
16-
import card from '@hcengineering/model-card'
17-
import { MessagesNavigationAnchors } from '@hcengineering/communication'
1815

1916
import communication from './plugin'
2017
import { buildTypes } from './types'
@@ -29,27 +26,6 @@ export function createModel (builder: Builder): void {
2926
buildMessageActions(builder)
3027
buildCardActions(builder)
3128
buildApplets(builder)
32-
33-
builder.createDoc(
34-
card.class.CardSection,
35-
core.space.Model,
36-
{
37-
label: communication.string.Messages,
38-
component: communication.component.CardMessagesSection,
39-
order: 9999,
40-
navigation: [
41-
{
42-
id: MessagesNavigationAnchors.ConversationStart,
43-
label: communication.string.FirstMessages
44-
},
45-
{
46-
id: MessagesNavigationAnchors.LatestMessages,
47-
label: communication.string.LatestMessages
48-
}
49-
]
50-
},
51-
communication.ids.CardMessagesSection
52-
)
5329
}
5430

5531
export default communication

models/communication/src/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import {
2525
type Poll,
2626
type CustomActivityPresenter,
2727
type GuestCommunicationSettings,
28-
type AppletGetTitleFnResource,
29-
MessagesNavigationAnchors
28+
type AppletGetTitleFnResource
3029
} from '@hcengineering/communication'
3130
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
3231
import { type AppletType } from '@hcengineering/communication-types'
@@ -100,8 +99,7 @@ function defineDirect (builder: Builder): void {
10099
communication.string.Direct,
101100
communication.string.Directs,
102101
{
103-
defaultSection: communication.ids.CardMessagesSection,
104-
defaultNavigation: MessagesNavigationAnchors.LatestMessages
102+
defaultSection: communication.ids.CardMessagesSection
105103
},
106104
PaletteColorIndexes.Lavander
107105
)

packages/presentation/src/components/MessageViewer.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<script lang="ts">
1717
import { isEmptyMarkup, markupToJSON } from '@hcengineering/text'
1818
import Node from './markup/Node.svelte'
19-
import { loadParseEmojisFunction, ParsedTextWithEmojis } from '@hcengineering/emoji'
19+
import { loadParseEmojisFunction, ParsedTextWithEmojis, getParseEmojisFunction } from '@hcengineering/emoji'
2020
import { onMount } from 'svelte'
2121
2222
export let message: string
@@ -25,10 +25,10 @@
2525
$: node = markupToJSON(message)
2626
$: empty = isEmptyMarkup(message)
2727
28-
let parseEmojisFunction: ((text: string) => ParsedTextWithEmojis) | undefined = undefined
28+
let parseEmojisFunction: ((text: string) => ParsedTextWithEmojis) | undefined = getParseEmojisFunction()
2929
3030
onMount(async () => {
31-
parseEmojisFunction = await loadParseEmojisFunction()
31+
parseEmojisFunction = getParseEmojisFunction() ?? (await loadParseEmojisFunction())
3232
})
3333
3434
export function isEmpty (): boolean {

packages/presentation/src/components/markup/NodeContent.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
class="emoji"
8585
style="display: inline-block"
8686
class:emojiOnly={parsedTextWithEmojis.emojisOnly && singleTextNode}
87+
class:custom={'image' in textOrEmoji}
8788
>
8889
{#if 'image' in textOrEmoji}
8990
{@const blob = toRefBlob(textOrEmoji.image)}
@@ -260,6 +261,10 @@
260261
.emojiOnly {
261262
font-size: 2rem;
262263
line-height: 115%;
264+
265+
&.custom {
266+
min-height: 2.625rem;
267+
}
263268
}
264269
265270
.img {

plugins/attachment-resources/src/components/AttachmentImagePreview.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
width={dimensions.width}
9090
height={dimensions.height}
9191
blurhash={value.metadata?.thumbnail?.blurhash}
92-
showLoading={true}
92+
showLoading={loading}
9393
on:load={handleLoad}
9494
on:error={handleError}
9595
on:loadstart={handleLoadStart}

plugins/card-resources/src/card.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright © 2025 Hardcore Engineering Inc.
2+
//
3+
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License. You may
5+
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
//
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
import { getClient } from '@hcengineering/presentation'
15+
import cardPlugin, { type Card, type CardSection } from '@hcengineering/card'
16+
import { getResource } from '@hcengineering/platform'
17+
import { type Heading } from '@hcengineering/text-editor'
18+
import communication from '@hcengineering/communication'
19+
20+
export async function getCardSections (card: Card): Promise<CardSection[]> {
21+
const client = getClient()
22+
const sections: CardSection[] = client
23+
.getModel()
24+
.findAllSync(cardPlugin.class.CardSection, {})
25+
.filter((it) => it._id !== communication.ids.CardMessagesSection)
26+
.sort((a, b) => a.order - b.order)
27+
28+
const res: CardSection[] = []
29+
for (const section of sections) {
30+
if (section.checkVisibility !== undefined) {
31+
const isVisibleFn = await getResource(section.checkVisibility)
32+
const isVisible = await isVisibleFn(card)
33+
if (isVisible) {
34+
res.push(section)
35+
}
36+
} else {
37+
res.push(section)
38+
}
39+
}
40+
41+
return res
42+
}
43+
44+
export function getCardToc (sections: CardSection[], tocBySection: Record<string, Heading[]>): Heading[] {
45+
const newToc: Heading[] = []
46+
47+
for (const section of sections) {
48+
const subToc = tocBySection[section._id]
49+
if (section.navigation.length > 0) {
50+
newToc.push(
51+
...section.navigation.map((nav) => ({
52+
id: nav.id,
53+
titleIntl: nav.label,
54+
level: 0,
55+
group: section._id
56+
}))
57+
)
58+
} else {
59+
newToc.push({
60+
id: section._id,
61+
titleIntl: section.label,
62+
level: 0,
63+
group: section._id
64+
})
65+
}
66+
67+
if (subToc !== undefined) {
68+
newToc.push(...subToc.map((it) => ({ ...it, group: section._id })))
69+
}
70+
}
71+
72+
newToc.push({
73+
id: communication.ids.CardMessagesSection,
74+
titleIntl: communication.string.Messages,
75+
level: 0,
76+
group: communication.ids.CardMessagesSection
77+
})
78+
79+
return newToc
80+
}

plugins/card-resources/src/components/Childs.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
export let object: Card
3636
export let readonly: boolean = false
3737
export let emptyKind: 'create' | 'placeholder' = 'create'
38+
export let limit = 20
3839
3940
let viewlet: WithLookup<Viewlet> | undefined
4041
let viewOptions: ViewOptions | undefined
@@ -177,6 +178,7 @@
177178
{config}
178179
{viewOptions}
179180
compactMode={listWidth <= 600}
181+
singleCategoryLimit={limit}
180182
on:docs
181183
on:row-focus={(event) => {
182184
listProvider.updateFocus(event.detail ?? undefined)

plugins/card-resources/src/components/EditCardNewContent.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
<div class="message-input" use:resizeObserver={onInputResize}>
6060
<MessageInput
6161
card={doc}
62-
title={doc.title}
6362
on:arrowUp={() => {
6463
content?.editLastMessage()
6564
}}

0 commit comments

Comments
 (0)