Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
williamhorning committed Aug 5, 2024
1 parent dae507d commit 33a0981
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/chat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { is_api_attachment, type api_attachment } from '../api/uploads.ts';
import { type api_attachment, is_api_attachment } from '../api/uploads.ts';
import { type api_post, post } from './post.ts';

/** chat types */
Expand Down
36 changes: 23 additions & 13 deletions src/interfaces/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface api_post {
count: number;
emoji: string;
user_reacted: boolean;
}[]
}[];
}

/** post creation options */
Expand Down Expand Up @@ -139,7 +139,7 @@ export class post {
/** username */
username!: string;
/** reply to */
replies!: post[]
replies!: post[];
/** stickers */
stickers!: api_attachment[];
/** reactions */
Expand All @@ -164,12 +164,14 @@ export class post {
this.chat_id = this.raw.post_origin;
this.timestamp = this.raw.t.e;
this.type = this.raw.type;
this.replies = this.raw.reply_to.map(i=>new post({
api_token: this.api_token,
api_url: this.api_url,
api_username: this.api_username,
data: i,
}));
this.replies = this.raw.reply_to.map((i) =>
new post({
api_token: this.api_token,
api_url: this.api_url,
api_username: this.api_username,
data: i,
})
);
this.stickers = this.raw.stickers;
this.reactions = this.raw.reactions;
}
Expand Down Expand Up @@ -331,15 +333,19 @@ export class post {
});
}

const found_emoji_index = this.reactions.findIndex(i=>i.emoji === emoji);
const found_raw_emoji_index = this.raw.reactions.findIndex(i=>i.emoji === emoji);
const found_emoji_index = this.reactions.findIndex((i) =>
i.emoji === emoji
);
const found_raw_emoji_index = this.raw.reactions.findIndex((i) =>
i.emoji === emoji
);

if (found_emoji_index === -1) {
const new_reaction = {
emoji,
count: 1,
user_reacted: true,
}
};

this.reactions.push(new_reaction);
this.raw.reactions.push(new_reaction);
Expand Down Expand Up @@ -370,8 +376,12 @@ export class post {
});
}

const found_emoji_index = this.reactions.findIndex(i=>i.emoji === emoji);
const found_raw_emoji_index = this.raw.reactions.findIndex(i=>i.emoji === emoji);
const found_emoji_index = this.reactions.findIndex((i) =>
i.emoji === emoji
);
const found_raw_emoji_index = this.raw.reactions.findIndex((i) =>
i.emoji === emoji
);

if (found_emoji_index !== -1) {
this.reactions[found_emoji_index].count--;
Expand Down

0 comments on commit 33a0981

Please sign in to comment.