mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-17 22:03:09 +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
plugins/contact-resources/src/components
@ -50,7 +50,7 @@
|
|||||||
export let focusIndex = -1
|
export let focusIndex = -1
|
||||||
export let restricted: Ref<ChannelProvider>[] = []
|
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()))
|
getResource(notification.function.GetNotificationClient).then((res) => (lastViews = res().getLastViews()))
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -70,7 +70,7 @@
|
|||||||
function getProvider (
|
function getProvider (
|
||||||
item: AttachedData<Channel>,
|
item: AttachedData<Channel>,
|
||||||
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
||||||
lastViews: LastView
|
lastViews: LastView | undefined
|
||||||
): Item | undefined {
|
): Item | undefined {
|
||||||
const provider = map.get(item.provider)
|
const provider = map.get(item.provider)
|
||||||
if (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
|
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
|
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) {
|
if (value == null) {
|
||||||
displayItems = []
|
displayItems = []
|
||||||
return
|
return
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
export let reverse: boolean = false
|
export let reverse: boolean = false
|
||||||
export let integrations: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
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()))
|
getResource(notification.function.GetNotificationClient).then((res) => (lastViews = res().getLastViews()))
|
||||||
|
|
||||||
interface Item {
|
interface Item {
|
||||||
@ -48,7 +48,7 @@
|
|||||||
function getProvider (
|
function getProvider (
|
||||||
item: AttachedData<Channel>,
|
item: AttachedData<Channel>,
|
||||||
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
map: Map<Ref<ChannelProvider>, ChannelProvider>,
|
||||||
lastViews: LastView
|
lastViews: LastView | undefined
|
||||||
): any | undefined {
|
): any | undefined {
|
||||||
const provider = map.get(item.provider)
|
const provider = map.get(item.provider)
|
||||||
if (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
|
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
|
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) {
|
if (value === null) {
|
||||||
displayItems = []
|
displayItems = []
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user