Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-03-28 14:03:50 +06:00 committed by GitHub
parent 4188d6a32b
commit 667d22cb7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 51 deletions

View File

@ -31,40 +31,24 @@
import { ChannelsEditor } from '@anticrm/contact-resources'
const client = getClient()
let account: EmployeeAccount | undefined
let employee: Employee | undefined
let firstName: string
let lastName: string
const accountQ = createQuery()
const employeeQ = createQuery()
$: accountQ.query(
contact.class.EmployeeAccount,
employeeQ.query(
contact.class.Employee,
{
_id: getCurrentAccount()._id as Ref<EmployeeAccount>
_id: (getCurrentAccount() as EmployeeAccount).employee
},
(res) => {
account = res[0]
employee = res[0]
firstName = getFirstName(employee.name)
lastName = getLastName(employee.name)
},
{ limit: 1 }
)
$: account && updateQuery(account.employee)
function updateQuery (id: Ref<Employee>): void {
employeeQ.query(
contact.class.Employee,
{
_id: id
},
(res) => {
employee = res[0]
firstName = getFirstName(employee.name)
lastName = getLastName(employee.name)
},
{ limit: 1 }
)
}
async function onAvatarDone (e: any) {
if (employee === undefined) return
const uploadFile = await getResource(attachment.helper.UploadFile)

View File

@ -27,7 +27,7 @@
import Connect from './Connect.svelte'
import TelegramIcon from './icons/Telegram.svelte'
import Messages from './Messages.svelte'
import Reconnect from './Reconnect.svelte';
import Reconnect from './Reconnect.svelte'
export let object: Contact
let channel: Channel | undefined = undefined

View File

@ -26,17 +26,11 @@
return await client.findAll(setting.class.SettingsCategory, {}, { sort: { order: 1 } })
}
let account: EmployeeAccount | undefined
const account = getCurrentAccount() as EmployeeAccount
let employee: Employee | undefined
const accountQ = createQuery()
const employeeQ = createQuery()
$: accountQ.query(contact.class.EmployeeAccount, {
_id: getCurrentAccount()._id as Ref<EmployeeAccount>
}, (res) => {
account = res[0]
}, { limit: 1 })
$: account && employeeQ.query(contact.class.Employee, {
employeeQ.query(contact.class.Employee, {
_id: account.employee
}, (res) => {
employee = res[0]

View File

@ -151,33 +151,21 @@
visibileNav = !visibileNav
closeTooltip()
}
let account: EmployeeAccount | undefined
const account = getCurrentAccount() as EmployeeAccount
let employee: Employee | undefined
const accountQ = createQuery()
const employeeQ = createQuery()
$: accountQ.query(
contact.class.EmployeeAccount,
employeeQ.query(
contact.class.Employee,
{
_id: getCurrentAccount()._id as Ref<EmployeeAccount>
_id: account.employee
},
(res) => {
account = res[0]
employee = res[0]
},
{ limit: 1 }
)
$: account &&
employeeQ.query(
contact.class.Employee,
{
_id: account.employee
},
(res) => {
employee = res[0]
},
{ limit: 1 }
)
let isNavigate: boolean = false
$: isNavigate = !!navigatorModel
@ -210,7 +198,7 @@
$: notificationQuery.query(
notification.class.Notification,
{
attachedTo: (getCurrentAccount() as EmployeeAccount).employee,
attachedTo: account.employee,
status: NotificationStatus.New
},
(res) => {