Skip to content

Commit 930d13b

Browse files
Add chat UI fixes (#5632)
Signed-off-by: Kristina Fefelova <[email protected]>
1 parent f956b8d commit 930d13b

File tree

9 files changed

+52
-19
lines changed

9 files changed

+52
-19
lines changed

Diff for: models/chunter/src/index.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ import {
3838
type Ref,
3939
type Space,
4040
type Timestamp,
41-
IndexKind,
42-
SortingOrder
41+
IndexKind
4342
} from '@hcengineering/core'
4443
import {
4544
ArrOf,
@@ -77,9 +76,6 @@ export const DOMAIN_CHUNTER = 'chunter' as Domain
7776
export class TChunterSpace extends TSpace implements ChunterSpace {
7877
@Prop(TypeTimestamp(), chunter.string.LastMessage)
7978
lastMessage?: Timestamp
80-
81-
@Prop(ArrOf(TypeRef(chunter.class.ChunterMessage)), chunter.string.PinnedMessages)
82-
pinned?: Ref<ChunterMessage>[]
8379
}
8480

8581
@Model(chunter.class.Channel, chunter.class.ChunterSpace)
@@ -352,15 +348,11 @@ export function createModel (builder: Builder): void {
352348
{
353349
attachTo: chunter.class.Channel,
354350
descriptor: view.viewlet.Table,
355-
viewOptions: {
356-
orderBy: [['modifiedOn', SortingOrder.Descending]],
357-
groupBy: [],
358-
other: []
359-
},
360351
configOptions: {
361352
strict: true
362353
},
363-
config: ['', 'topic', 'private', 'archived', 'members']
354+
config: ['', 'topic', 'private', 'archived', 'members'],
355+
props: { enableChecking: false }
364356
},
365357
chunter.viewlet.Channels
366358
)
@@ -738,6 +730,11 @@ export function createModel (builder: Builder): void {
738730
},
739731
chunter.action.ReplyToThreadAction
740732
)
733+
734+
builder.mixin(chunter.class.Channel, core.class.Class, view.mixin.ClassFilters, {
735+
filters: ['name', 'topic', 'private', 'archived', 'members'],
736+
strict: true
737+
})
741738
}
742739

743740
export default chunter

Diff for: models/view/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ export class TViewlet extends TDoc implements Viewlet {
300300
config!: (BuildModelKey | string)[]
301301
hiddenKeys?: string[]
302302
viewOptions?: ViewOptionsModel
303+
props?: Record<string, any>
303304
}
304305

305306
@Model(view.class.Action, core.class.Doc, DOMAIN_MODEL)

Diff for: packages/theme/styles/components.scss

+6-2
Original file line numberDiff line numberDiff line change
@@ -1524,8 +1524,12 @@
15241524
th, td {
15251525
padding: .5rem 1.5rem;
15261526
text-align: left;
1527-
&:first-child { padding-left: 0; }
1528-
&:last-child { padding-right: 0; }
1527+
&:first-child { .metaColumn {
1528+
padding-left: 0; }
1529+
}
1530+
&:last-child { .metaColumn {
1531+
padding-right: 0; }
1532+
}
15291533
}
15301534
th {
15311535
height: 3rem;

Diff for: plugins/chunter-resources/src/components/chat/Chat.svelte

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
})
6262
6363
openedChannelStore.subscribe((data) => {
64-
if (data && selectedData?._id !== data._id) {
64+
if (data === undefined) {
65+
selectedData = undefined
66+
object = undefined
67+
} else if (selectedData?._id !== data._id) {
6568
selectedData = data
6669
openChannel(data._id, data._class, data.thread)
6770
}
@@ -94,6 +97,8 @@
9497
const id = loc.path[3]
9598
9699
if (!id) {
100+
currentSpecial = undefined
101+
clearChannel()
97102
return
98103
}
99104

Diff for: plugins/chunter-resources/src/utils.ts

+27-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
//
15-
import { type Channel, type ChatMessage, type DirectMessage, type ThreadMessage } from '@hcengineering/chunter'
15+
import {
16+
type Channel,
17+
type ChatMessage,
18+
chunterId,
19+
type DirectMessage,
20+
type ThreadMessage
21+
} from '@hcengineering/chunter'
1622
import contact, { type Employee, getName, type Person, type PersonAccount } from '@hcengineering/contact'
1723
import { employeeByIdStore, PersonIcon } from '@hcengineering/contact-resources'
1824
import {
@@ -28,7 +34,7 @@ import {
2834
type Timestamp
2935
} from '@hcengineering/core'
3036
import { getClient } from '@hcengineering/presentation'
31-
import { type AnySvelteComponent } from '@hcengineering/ui'
37+
import { type AnySvelteComponent, getCurrentLocation, navigate } from '@hcengineering/ui'
3238
import { type Asset, translate } from '@hcengineering/platform'
3339
import { classIcon, getDocLinkTitle, getDocTitle } from '@hcengineering/view-resources'
3440
import activity, {
@@ -49,6 +55,7 @@ import { get, type Unsubscriber } from 'svelte/store'
4955
import chunter from './plugin'
5056
import DirectIcon from './components/DirectIcon.svelte'
5157
import ChannelIcon from './components/ChannelIcon.svelte'
58+
import { decodeChannelURI } from './navigation'
5259

5360
export async function getDmName (client: Client, space?: Space): Promise<string> {
5461
if (space === undefined) {
@@ -395,6 +402,21 @@ export async function readChannelMessages (
395402
}
396403
}
397404

405+
function resetChunterLoc (objectId: Ref<Doc>): void {
406+
const loc = getCurrentLocation()
407+
const [_id] = decodeChannelURI(loc.path[3])
408+
409+
if (loc.path[2] !== chunterId || _id !== objectId) {
410+
return
411+
}
412+
413+
loc.path[3] = ''
414+
loc.path[4] = ''
415+
loc.query = {}
416+
loc.path.length = 3
417+
navigate(loc)
418+
}
419+
398420
export async function leaveChannelAction (context?: DocNotifyContext): Promise<void> {
399421
if (context === undefined) {
400422
return
@@ -407,6 +429,7 @@ export async function leaveChannelAction (context?: DocNotifyContext): Promise<v
407429
}
408430

409431
await leaveChannel(channel, getCurrentAccount()._id)
432+
resetChunterLoc(channel._id)
410433
}
411434

412435
export async function removeChannelAction (context?: DocNotifyContext): Promise<void> {
@@ -418,6 +441,8 @@ export async function removeChannelAction (context?: DocNotifyContext): Promise<
418441

419442
await archiveContextNotifications(context)
420443
await client.remove(context)
444+
445+
resetChunterLoc(context.attachedTo)
421446
}
422447

423448
export function isThreadMessage (message: ActivityMessage): message is ThreadMessage {

Diff for: plugins/chunter/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { Action } from '@hcengineering/view'
2727
*/
2828
export interface ChunterSpace extends Space {
2929
lastMessage?: Timestamp
30-
pinned?: Ref<ChunterMessage>[]
3130
}
3231

3332
/**

Diff for: plugins/view/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ export interface Viewlet extends Doc {
410410
configOptions?: ViewletConfigOptions
411411
viewOptions?: ViewOptionsModel
412412
variant?: string
413+
props?: Record<string, any>
413414
}
414415

415416
/**

Diff for: plugins/workbench-resources/src/components/SpecialView.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@
129129
createItemDialog: createComponent,
130130
createItemLabel: createLabel,
131131
query: resultQuery,
132-
totalQuery: query
132+
totalQuery: query,
133+
...viewlet.props
133134
}}
134135
/>
135136
{/if}

Diff for: tests/sanity/tests/model/channel-page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class ChannelPage {
1212
readonly textMessage = (): Locator => this.page.getByText('Test message')
1313
readonly channelName = (channel: string): Locator => this.page.getByText('general random').getByText(channel)
1414
readonly channelTab = (): Locator => this.page.getByRole('link', { name: 'Channels' }).getByRole('button')
15-
readonly channelTable = (): Locator => this.page.locator('[class="antiTable metaColumn highlightRows"]')
15+
readonly channelTable = (): Locator => this.page.getByRole('table')
1616
readonly channel = (channel: string): Locator => this.page.getByRole('button', { name: channel })
1717

1818
async sendMessage (message: string): Promise<void> {

0 commit comments

Comments
 (0)