Skip to content

Commit

Permalink
channel用のmapを作成
Browse files Browse the repository at this point in the history
  • Loading branch information
kamecha committed Mar 14, 2024
1 parent d0b264c commit 3eabc5b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions denops/traqvim/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ export type channelMessageOptions = {
order?: "asc" | "desc";
};

export const channelMapCache: Map<string, traq.Channel> = new Map();

const getChannelCache = () => {
return channelMapCache;
};

const makeCacheChannel = async () => {
const channelsRes = await api.api.getChannels();
const channels = channelsRes.data;
channels.public.forEach((channel: traq.Channel) => {
setCacheChannel(channel);
});
};

const setCacheChannel = (channel: traq.Channel) => {
channelMapCache.set(channel.id, channel);
};

const getCacheChannel = (channelId: string): traq.Channel | undefined => {
return channelMapCache.get(channelId);
};

const makeChannelPath = (
channels: traq.Channel[],
channel: traq.Channel,
Expand Down

0 comments on commit 3eabc5b

Please sign in to comment.