mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 04:08:19 +00:00
Fix channels last view (#2894)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
442fcace43
commit
a212a850ed
@ -50,7 +50,7 @@
|
||||
export let focusIndex = -1
|
||||
export let restricted: Ref<ChannelProvider>[] = []
|
||||
|
||||
let lastViews: Writable<LastView> = writable()
|
||||
let lastViews: Writable<LastView | undefined> = writable()
|
||||
getResource(notification.function.GetNotificationClient).then((res) => (lastViews = res().getLastViews()))
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
function getProvider (
|
||||
item: AttachedData<Channel>,
|
||||
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
||||
lastViews: LastView
|
||||
lastViews: LastView | undefined
|
||||
): Item | undefined {
|
||||
const provider = map.get(item.provider)
|
||||
if (provider) {
|
||||
@ -92,13 +92,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function isNew (item: Channel, lastViews: LastView): boolean {
|
||||
function isNew (item: Channel, lastViews: LastView | undefined): boolean {
|
||||
if (item.lastMessage === undefined) return false
|
||||
const lastView = (item as Channel)._id !== undefined ? lastViews[(item as Channel)._id] : undefined
|
||||
const lastView =
|
||||
(item as Channel)._id !== undefined && lastViews !== undefined ? lastViews[(item as Channel)._id] : undefined
|
||||
return lastView ? lastView < item.lastMessage : (item.items ?? 0) > 0
|
||||
}
|
||||
|
||||
async function update (value: AttachedData<Channel>[] | Channel | null, lastViews: LastView) {
|
||||
async function update (value: AttachedData<Channel>[] | Channel | null, lastViews: LastView | undefined) {
|
||||
if (value == null) {
|
||||
displayItems = []
|
||||
return
|
||||
|
@ -31,7 +31,7 @@
|
||||
export let reverse: boolean = false
|
||||
export let integrations: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
||||
|
||||
let lastViews: Writable<LastView> = writable()
|
||||
let lastViews: Writable<LastView | undefined> = writable()
|
||||
getResource(notification.function.GetNotificationClient).then((res) => (lastViews = res().getLastViews()))
|
||||
|
||||
interface Item {
|
||||
@ -48,7 +48,7 @@
|
||||
function getProvider (
|
||||
item: AttachedData<Channel>,
|
||||
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
||||
lastViews: LastView
|
||||
lastViews: LastView | undefined
|
||||
): any | undefined {
|
||||
const provider = map.get(item.provider)
|
||||
if (provider) {
|
||||
@ -66,13 +66,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function isNew (item: Channel, lastViews: LastView): boolean {
|
||||
function isNew (item: Channel, lastViews: LastView | undefined): boolean {
|
||||
if (item.lastMessage === undefined) return false
|
||||
const lastView = (item as Channel)._id !== undefined ? lastViews[(item as Channel)._id] : undefined
|
||||
const lastView =
|
||||
(item as Channel)._id !== undefined && lastViews !== undefined ? lastViews[(item as Channel)._id] : undefined
|
||||
return lastView ? lastView < item.lastMessage : (item.items ?? 0) > 0
|
||||
}
|
||||
|
||||
async function update (value: AttachedData<Channel>[] | Channel | null, lastViews: LastView) {
|
||||
async function update (value: AttachedData<Channel>[] | Channel | null, lastViews: LastView | undefined) {
|
||||
if (value === null) {
|
||||
displayItems = []
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user