accounts update

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-10 17:54:13 +02:00
parent 944f8fbef8
commit 590124f668
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
4 changed files with 36 additions and 12 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License.
//
import type { Doc, Ref } from './classes'
import type { Doc, Ref, Account } from './classes'
function toHex (value: number, chars: number): string {
const result = value.toString(16)
@ -43,3 +43,19 @@ function count (): string {
export function generateId<T extends Doc> (): Ref<T> {
return (timestamp() + random + count()) as Ref<T>
}
let currentAccount: Account
/**
* @public
* @returns
*/
export function getCurrentAccount (): Account { return currentAccount }
/**
* @public
* @param account -
*/
export function setCurrentAccount (account: Account): void {
currentAccount = account
}

View File

@ -15,18 +15,34 @@
<script lang="ts">
import type { Comment } from '@anticrm/chunter'
import MessageViewer from '@anticrm/presentation/src/components/MessageViewer.svelte'
import { getClient } from '@anticrm/presentation'
import type { Ref } from '@anticrm/core'
import MessageViewer from '@anticrm/presentation/src/components/MessageViewer.svelte'
import Avatar from '@anticrm/presentation/src/components/Avatar.svelte'
import contact, { Employee, EmployeeAccount } from '@anticrm/contact'
export let comment: Comment
let employee: Employee | undefined
console.log('comment modified by', comment.modifiedBy)
const client = getClient()
client.findOne(contact.class.EmployeeAccount, { _id: comment.modifiedBy as Ref<EmployeeAccount> })
.then(account => client.findOne(contact.class.Employee, { _id: account?.employee }))
.then(result => {
console.log('comment', result)
employee = result
})
</script>
<div class="flex-nowrap">
<div class="avatar"><Avatar size={'medium'} /></div>
<div class="flex-col-stretch message">
<div class="header">Rosamund Chen<span>July 28th</span></div>
<div class="header">{#if employee}{employee.firstName} {employee.lastName}{/if}<span>July 28th</span></div>
<div class="text"><MessageViewer message={comment.message} /></div>
</div>
</div>

View File

@ -17,6 +17,7 @@
import { getResource } from '@anticrm/platform'
import type { Client } from '@anticrm/core'
import { setCurrentAccount } from '@anticrm/core'
import { navigate, Loading, fetchMetadataLocalStorage } from '@anticrm/ui'
import client from '@anticrm/client'
@ -24,7 +25,6 @@ import login from '@anticrm/login'
import contact from '@anticrm/contact'
import Workbench from './Workbench.svelte'
import { setCurrentAccount } from '../utils'
async function connect(): Promise<Client | undefined> {
const token = fetchMetadataLocalStorage(login.metadata.LoginToken)

View File

@ -22,11 +22,3 @@ import type { EmployeeAccount } from '@anticrm/contact'
export function classIcon(client: Client, _class: Ref<Class<Obj>>): Asset | undefined {
return client.getHierarchy().getClass(_class).icon
}
let currentAccount: EmployeeAccount
export function getCurrentAccount(): EmployeeAccount { return currentAccount }
export function setCurrentAccount(account: EmployeeAccount): void {
currentAccount = account
}