Skip to content

Commit

Permalink
Prevent from being temp forever
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Aug 24, 2022
1 parent 76ed463 commit 1c15862
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion apps/meteor/app/models/client/models/ChatMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class ChatMessageCollection extends Mongo.Collection<IMessage & { ignored?: bool
}

// TODO: check if we can dodge these missing typings from Meteor Collection Hooks
export const ChatMessage = new ChatMessageCollection() as unknown as Mongo.Collection<IMessage & { ignored?: boolean }> & {
export const ChatMessage = new ChatMessageCollection() as unknown as Mongo.Collection<
Omit<IMessage, '_id'> & { ignored?: boolean },
IMessage & { ignored?: boolean }
> & {
direct: Mongo.Collection<Omit<IMessage, '_id'>, IMessage>;

queries: unknown[];
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/threads/client/flextab/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ThreadTemplateInstance = Blaze.TemplateInstance<{
mainMessage: IMessage;
}> & {
firstNode: HTMLElement;
Threads: Mongo.Collection<IMessage> & {
Threads: Mongo.Collection<Omit<IMessage, '_id'>, IMessage> & {
direct: Mongo.Collection<Omit<IMessage, '_id'>, IMessage>;
queries: unknown[];
};
Expand Down Expand Up @@ -169,7 +169,7 @@ Template.thread.helpers({
});

Template.thread.onCreated(async function (this: ThreadTemplateInstance) {
this.Threads = new Mongo.Collection(null) as Mongo.Collection<IMessage> & {
this.Threads = new Mongo.Collection(null) as Mongo.Collection<Omit<IMessage, '_id'>, IMessage> & {
direct: Mongo.Collection<Omit<IMessage, '_id'>, IMessage>;
queries: unknown[];
};
Expand Down Expand Up @@ -304,10 +304,10 @@ Template.thread.onRendered(function (this: ThreadTemplateInstance) {
},
).observe({
added: ({ _id, ...message }: IMessage) => {
this.Threads.upsert({ _id }, { $set: message });
this.Threads.upsert({ _id }, message);
},
changed: ({ _id, ...message }: IMessage) => {
this.Threads.update({ _id }, { $set: message });
this.Threads.update({ _id }, message);
},
removed: ({ _id }: IMessage) => this.Threads.remove(_id),
});
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/ui/client/lib/ChatMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ChatMessages {
$input: JQuery<HTMLTextAreaElement> | undefined;

constructor(
public collection: Mongo.Collection<IMessage> & {
public collection: Mongo.Collection<Omit<IMessage, '_id'>, IMessage> & {
direct: Mongo.Collection<Omit<IMessage, '_id'>, IMessage>;
queries: unknown[];
} = ChatMessage,
Expand Down

0 comments on commit 1c15862

Please sign in to comment.