Skip to content

Commit

Permalink
SyncAgent: Update load priority of spaces and channels (#1007)
Browse files Browse the repository at this point in the history
They load faster this way
  • Loading branch information
texuf authored Sep 8, 2024
1 parent 04d9018 commit 7f445a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/sdk/src/sync-agent/spaces/models/channel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PlainMessage } from '@bufbuild/protobuf'
import { PersistedObservable, persistedObservable } from '../../../observable/persistedObservable'
import { Identifiable, Store } from '../../../store/store'
import { Identifiable, LoadPriority, Store } from '../../../store/store'
import { RiverConnection } from '../../river-connection/riverConnection'
import { ChannelMessage_Post_Attachment, ChannelMessage_Post_Mention } from '@river-build/proto'
import { Timeline } from '../../timeline/timeline'
Expand Down Expand Up @@ -29,7 +29,7 @@ export class Channel extends PersistedObservable<ChannelModel> {
private spaceDapp: SpaceDapp,
store: Store,
) {
super({ id, spaceId, isJoined: false }, store)
super({ id, spaceId, isJoined: false }, store, LoadPriority.high)
this.timeline = new Timeline(riverConnection.userId)
this.members = new Members(id, riverConnection, store)
}
Expand Down
11 changes: 8 additions & 3 deletions packages/sdk/src/sync-agent/spaces/models/space.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { check, dlogger } from '@river-build/dlog'
import { isDefined } from '../../../check'
import { makeDefaultChannelStreamId, makeUniqueChannelStreamId } from '../../../id'
import {
isChannelStreamId,
makeDefaultChannelStreamId,
makeUniqueChannelStreamId,
} from '../../../id'
import { PersistedObservable, persistedObservable } from '../../../observable/persistedObservable'
import { Identifiable, Store } from '../../../store/store'
import { Identifiable, LoadPriority, Store } from '../../../store/store'
import { RiverConnection } from '../../river-connection/riverConnection'
import { Channel } from './channel'
import { ethers } from 'ethers'
Expand All @@ -28,7 +32,7 @@ export class Space extends PersistedObservable<SpaceModel> {
store: Store,
private spaceDapp: SpaceDapp,
) {
super({ id, channelIds: [], initialized: false }, store)
super({ id, channelIds: [], initialized: false }, store, LoadPriority.high)
this.channels = {
[makeDefaultChannelStreamId(id)]: new Channel(
makeDefaultChannelStreamId(id),
Expand Down Expand Up @@ -111,6 +115,7 @@ export class Space extends PersistedObservable<SpaceModel> {
}

getChannel(channelId: string): Channel {
check(isChannelStreamId(channelId), 'channelId is not a channel stream id')
if (!this.channels[channelId]) {
this.channels[channelId] = new Channel(
channelId,
Expand Down

0 comments on commit 7f445a9

Please sign in to comment.