From 3eabc5b70614f982477cc60860223efee327163e Mon Sep 17 00:00:00 2001 From: kamecha Date: Thu, 14 Mar 2024 20:52:26 +0900 Subject: [PATCH] =?UTF-8?q?channel=E7=94=A8=E3=81=AEmap=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/traqvim/model.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/denops/traqvim/model.ts b/denops/traqvim/model.ts index b33350d..c3e8f9f 100644 --- a/denops/traqvim/model.ts +++ b/denops/traqvim/model.ts @@ -15,6 +15,28 @@ export type channelMessageOptions = { order?: "asc" | "desc"; }; +export const channelMapCache: Map = 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,