Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create doc #2672

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
// date = new Date().getTime() + value.shift
// }
if (date === undefined) return
const _id = await client.createDoc(calendar.class.Event, space, {
attachedTo,
attachedToClass,
collection: 'reminders',
const _id = await client.addCollection(calendar.class.Event, space, attachedTo, attachedToClass, 'reminders', {
date,
description: '',
participants,
Expand Down
15 changes: 6 additions & 9 deletions plugins/chunter-resources/src/components/ChannelView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
async function onMessage (event: CustomEvent) {
const { message, attachments } = event.detail
const me = getCurrentAccount()._id
await client.createDoc<Message>(
await client.addCollection(
_class,
space,
space,
chunter.class.ChunterSpace,
'messages',
{
attachedTo: space,
attachedToClass: chunter.class.ChunterSpace,
collection: 'messages',
content: message,
createOn: Date.now(),
createBy: me,
Expand All @@ -59,12 +59,9 @@
chunterSpace.members
.filter((accId) => accId !== me)
.map((accId) =>
client.createDoc(notification.class.LastView, space, {
client.addCollection(notification.class.LastView, space, space, chunterSpace._class, 'lastViews', {
user: accId,
lastView: 0,
attachedTo: space,
attachedToClass: chunterSpace._class,
collection: 'lastViews'
lastView: 0
})
)
)
Expand Down
18 changes: 11 additions & 7 deletions plugins/chunter-resources/src/components/Message.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,17 @@

const reaction = reactions?.find((r) => r.emoji === emoji && r.createBy === me)
if (!reaction) {
await client.createDoc(chunter.class.Reaction, message.space, {
attachedTo: message._id,
attachedToClass: chunter.class.ChunterMessage,
emoji,
createBy: me,
collection: 'reactions'
})
await client.addCollection(
chunter.class.Reaction,
message.space,
message._id,
chunter.class.ChunterMessage,
'reactions',
{
emoji,
createBy: me
}
)
} else {
await client.removeDoc(chunter.class.Reaction, message.space, reaction._id)
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/chunter-resources/src/components/ThreadView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@
async function onMessage (event: CustomEvent) {
const { message, attachments } = event.detail
const me = getCurrentAccount()._id
await client.createDoc(
await client.addCollection(
chunter.class.ThreadMessage,
currentSpace,
_id,
chunter.class.Message,
'replies',
{
attachedTo: _id,
attachedToClass: chunter.class.Message,
collection: 'replies',
content: message,
createBy: me,
createOn: Date.now(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
} else if (status && !newStatus) {
client.removeDoc(contact.class.Status, status.space, status._id)
} else {
client.createDoc(contact.class.Status, employee!.space, {
attachedTo: employeeId,
attachedToClass: contact.class.Employee,
collection: 'statuses',
client.addCollection(contact.class.Status, employee!.space, employeeId, contact.class.Employee, 'statuses', {
name: newStatus.name,
dueDate: newStatus.dueDate
})
Expand Down
3 changes: 2 additions & 1 deletion plugins/lead-resources/src/components/CreateCustomer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
async function createCustomer () {
const candidate: Data<Contact> = {
name: formatName(targetClass._id, firstName, lastName, object.name),
city: object.city
city: object.city,
createOn: Date.now()
}
if (avatar !== undefined) {
candidate.avatar = await avatarEditor.createAvatar()
Expand Down
10 changes: 5 additions & 5 deletions plugins/telegram-resources/src/components/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@
async function onMessage (event: CustomEvent) {
if (channel === undefined) return
const { message, attachments } = event.detail
await client.createDoc(
await client.addCollection(
telegram.class.NewMessage,
telegram.space.Telegram,
channel._id,
channel._class,
'newMessages',
{
content: message,
status: 'new',
attachments,
attachedTo: channel._id,
attachedToClass: channel._class,
collection: 'newMessages'
attachments
},
objectId
)
Expand Down