Skip to content

Commit

Permalink
[desk-tool] Make color helper return observable value
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent 5058947 commit edbfb66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/@sanity/desk-tool/src/@types/parts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ declare module 'all:part:@sanity/base/diff-resolver' {
}

declare module '@sanity/base' {
import {Observable} from 'rxjs'

export type UserColorHue =
| 'blue'
| 'cyan'
Expand All @@ -22,7 +24,7 @@ declare module '@sanity/base' {
| 'magenta'
| 'purple'
export interface UserColorManager {
get: (userId: string) => UserColorHue
get: (userId: string) => Observable<UserColorHue>
}
export const useUserColorManager: () => UserColorManager
}
Expand Down
9 changes: 8 additions & 1 deletion packages/@sanity/desk-tool/src/diffs/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export function getAnnotationColor(
return {bg: '#fcc', fg: '#f00'}
}

const hueKey = colorManager.get(annotation.author)
let hueKey
colorManager
.get(annotation.author)
.subscribe(userColor => {
hueKey = userColor
})
.unsubscribe()

return color[hueKey]
}

0 comments on commit edbfb66

Please sign in to comment.