Skip to content

Commit

Permalink
fix(metadata): title's count is passed via localChanges
Browse files Browse the repository at this point in the history
BREAKING CHANGE: MetaDataService.initTitle parameters change : before it was initTitle(title:
string), now it's initTitle(title: string, titleLastModification: number)
  • Loading branch information
cedricenclos committed Jun 28, 2018
1 parent 3e9f429 commit 6e5e3f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/doc/FixDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class FixDataService {
this.fixDataState = { creationDate, key }
}

public handleRemoteTitleState(newState: FixDataState): void {
public handleRemoteFixDataState(newState: FixDataState): void {
if (!newState.creationDate) {
return
}
Expand Down
11 changes: 7 additions & 4 deletions src/doc/MetaDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class MetaDataService implements Disposable {
this.msgToSendToSubject = new Subject()
}

initTitle(title: string) {
this.titleService.initTitle(title)
initTitle(title: string, titleLastModification: number) {
this.titleService.initTitle(title, titleLastModification)
}

initFixMetaData(creationDate: Date, key: string) {
Expand All @@ -71,7 +71,7 @@ export class MetaDataService implements Disposable {
break
case MetaDataType.FixData:
data.creationDate = new Date(data.creationDate)
this.fixDataService.handleRemoteTitleState(data)
this.fixDataService.handleRemoteFixDataState(data)
this.remoteChangeSubject.next({
type: MetaDataType.FixData,
data: this.fixDataService.state,
Expand All @@ -87,7 +87,10 @@ export class MetaDataService implements Disposable {
source.pipe(takeUntil(this.disposeSubject)).subscribe((metadata: MetaDataMessage) => {
switch (metadata.type) {
case MetaDataType.Title:
this.titleService.handleLocalTitleState(metadata.data)
this.titleService.handleLocalTitleState(
metadata.data.title,
metadata.data.titleLastModification
)
this.emitMetaData(MetaDataType.Title, JSON.stringify(this.titleService.asObject))
break
case MetaDataType.FixData:
Expand Down
7 changes: 4 additions & 3 deletions src/doc/TitleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ export class TitleService {
this.titleState = this.register.state()
}

public handleLocalTitleState(newTitle: string): void {
this.titleState = this.register.write(Date.now(), newTitle)
public handleLocalTitleState(newTitle: string, newCount: number): void {
this.titleState = this.register.write(newCount, newTitle)
}

public handleRemoteTitleState(newState: TitleState): void {
this.register.apply([newState.count, newState.title])
this.titleState = this.register.state()
}

public initTitle(init: string): void {
public initTitle(init: string, timestamp: number): void {
this.titleState[0] = timestamp
this.titleState[1] = init
}

Expand Down

0 comments on commit 6e5e3f7

Please sign in to comment.