Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBER-226 UBER-227 fix activity collapse #3248

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/activity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class TTxViewlet extends TDoc implements TxViewlet {
// Component to display on.
component!: AnyComponent
// Filter
match!: DocumentQuery<Tx>
match?: DocumentQuery<Tx>
label!: IntlString
display!: 'inline' | 'content' | 'emphasized'
editable!: boolean
Expand Down
15 changes: 9 additions & 6 deletions plugins/activity-resources/src/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type DisplayTxListener = (txes: DisplayTx[]) => void

// Use 5 minutes to combine similar transactions.
const combineThreshold = 5 * 60 * 1000
const createCombineThreshold = 10 * 1000

/**
* Define activity.
Expand All @@ -64,7 +65,7 @@ export interface Activity {
listener: DisplayTxListener,
sort: SortingOrder,
editable: Map<Ref<Class<Doc>>, boolean>
) => void
) => boolean
}

class ActivityImpl implements Activity {
Expand Down Expand Up @@ -110,16 +111,17 @@ class ActivityImpl implements Activity {
listener: DisplayTxListener,
sort: SortingOrder,
editable: Map<Ref<Class<Doc>>, boolean>
): void {
if (objectId === this.prevObjectId && objectClass === this.prevObjectClass) return
): boolean {
this.editable = editable
if (objectId === this.prevObjectId && objectClass === this.prevObjectClass) {
return false
}
this.prevObjectClass = objectClass
this.prevObjectId = objectId
let isAttached = false

isAttached = this.hierarchy.isDerived(objectClass, core.class.AttachedDoc)

this.editable = editable

this.ownTxQuery.query<TxCUD<Doc>>(
isAttached ? core.class.TxCollectionCUD : core.class.TxCUD,
isAttached
Expand Down Expand Up @@ -164,6 +166,7 @@ class ActivityImpl implements Activity {
)
// In case editable is changed
this.notify(objectId, listener, sort)
return true
}

async combineTransactions (
Expand Down Expand Up @@ -404,7 +407,7 @@ class ActivityImpl implements Activity {
(result.tx.objectId === prevTx.createTx.objectId ||
(result.doc as AttachedDoc)?.attachedTo === prevTx.createTx.objectId)
) {
return result.tx.modifiedOn - prevTx.createTx.modifiedOn < combineThreshold
return result.tx.modifiedOn - prevTx.createTx.modifiedOn < createCombineThreshold
}
}
return false
Expand Down
5 changes: 4 additions & 1 deletion plugins/activity-resources/src/components/Activity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
editableMap: Map<Ref<Class<Doc>>, boolean> | undefined
): void {
loading = true
activityQuery.update(
const res = activityQuery.update(
objectId,
objectClass,
(result) => {
Expand All @@ -84,6 +84,9 @@
SortingOrder.Ascending,
editableMap ?? new Map()
)
if (!res) {
loading = false
}
}

$: updateTxes(object._id, object._class, editableMap)
Expand Down