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

前後のmessageを更新しようとすると、型チェックで落ちるのを修正 #96

Merged
merged 2 commits into from
Jul 29, 2024
Merged
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
27 changes: 20 additions & 7 deletions denops/traqvim/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ export const homeChannelId = async (): Promise<string> => {
// userIdからユーザー情報を取得する
export const getUser = async (userId: string): Promise<traq.User> => {
const userRes = await api.api.getUser(userId);
const user = userRes.data;
const userDetail: traq.UserDetail = userRes.data;
// TODO: もっと良い変換方法ありそうなんで、見つけたらやっとく
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: Improve data transformation method.

The TODO comment indicates a potential for finding a better transformation method.

Do you want me to assist in finding and implementing a more efficient data transformation method?

const user: traq.User = {
id: userDetail.id,
name: userDetail.name,
displayName: userDetail.displayName,
iconFileId: userDetail.iconFileId,
bot: userDetail.bot,
state: userDetail.state,
updatedAt: userDetail.updatedAt,
};
return user;
};

Expand Down Expand Up @@ -172,6 +182,11 @@ export const channelTimeline = async (
)?.map((url: string) => {
return url.split("/").slice(-1)[0];
});
const ret: Message = {
...message,
user: user,
createdAt: new Date(message.createdAt).toLocaleString("ja-JP"),
};
// quotedMessageUUIDsが存在しなかった場合はundefinedを返す
let quotedMessages: Message[] | undefined = undefined;
if (quotedMessageUUIDs) {
Expand All @@ -192,12 +207,10 @@ export const channelTimeline = async (
}),
);
}
return {
...message,
user: user,
createdAt: new Date(message.createdAt).toLocaleString("ja-JP"),
quote: quotedMessages,
};
if (quotedMessages !== undefined) {
ret.quote = quotedMessages;
}
return ret;
}),
);
return messagesConverted;
Expand Down
Loading