Skip to content

Commit

Permalink
Merge pull request #59 from kamecha/refacter/tokenFile
Browse files Browse the repository at this point in the history
dduのソースからもapiのtokenFileのパス設定を行うよう変更
  • Loading branch information
kamecha authored Nov 28, 2023
2 parents 59a9530 + 4d4fb48 commit 7f8d1da
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
17 changes: 16 additions & 1 deletion denops/@ddc-sources/stamp.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { ddcVim, Denops, traq } from "../traqvim/deps.ts";
import {
ddcVim,
ddcVimSource,
Denops,
ensureString,
traq,
vars,
} from "../traqvim/deps.ts";

import { getStamps } from "../traqvim/model.ts";
import { api } from "../traqvim/api.ts";

type Params = Record<never, never>;

export class Source extends ddcVim.BaseSource<Params> {
async onInit(args: ddcVimSource.OnInitArguments<Params>): Promise<void> {
const path = await vars.globals.get(args.denops, "traqvim#token_file_path");
ensureString(path);
api.tokenFilePath = path;
return Promise.resolve();
}

override async gather(): Promise<ddcVim.Item[]> {
const stamps: traq.Stamp[] = await getStamps();
return stamps
Expand Down
16 changes: 15 additions & 1 deletion denops/@ddu-sources/channel.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import { dduVim, Denops, helper } from "../traqvim/deps.ts";
import {
dduVim,
dduVimSource,
Denops,
ensureString,
helper,
vars,
} from "../traqvim/deps.ts";
import { ActionData } from "../@ddu-kinds/channel.ts";
import { channelsRecursive, searchChannelUUID } from "../traqvim/model.ts";
import { Channel } from "../traqvim/type.d.ts";
import { api } from "../traqvim/api.ts";

type Params = Record<never, never>;

export class Source extends dduVim.BaseSource<Params> {
kind = "channel";
async onInit(args: dduVimSource.OnInitArguments<Params>): Promise<void> {
const path = await vars.globals.get(args.denops, "traqvim#token_file_path");
ensureString(path);
api.tokenFilePath = path;
return Promise.resolve();
}
override gather(args: {
denops: Denops;
sourceOptions: dduVim.SourceOptions;
Expand Down
15 changes: 14 additions & 1 deletion denops/@ddu-sources/channel_rec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { dduVim, Denops } from "../traqvim/deps.ts";
import {
dduVim,
dduVimSource,
Denops,
ensureString,
vars,
} from "../traqvim/deps.ts";
import { ActionData } from "../@ddu-kinds/channel.ts";
import { channelsRecursive, getUnreadChannels } from "../traqvim/model.ts";
import { Channel, UnreadChannel } from "../traqvim/type.d.ts";
import { api } from "../traqvim/api.ts";

type Params = {
type: "all" | "unread";
};

export class Source extends dduVim.BaseSource<Params> {
kind = "channel";
async onInit(args: dduVimSource.OnInitArguments<Params>): Promise<void> {
const path = await vars.globals.get(args.denops, "traqvim#token_file_path");
ensureString(path);
api.tokenFilePath = path;
return Promise.resolve();
}
gather(args: {
denops: Denops;
sourceParams: Params;
Expand Down
2 changes: 2 additions & 0 deletions denops/traqvim/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ export * as fn from "https://deno.land/x/denops_std@v4.0.0/function/mod.ts";
export * as vars from "https://deno.land/x/denops_std@v4.0.0/variable/mod.ts";
export * as helper from "https://deno.land/x/denops_std@v4.0.0/helper/mod.ts";
export * as ddcVim from "https://deno.land/x/ddc_vim@v3.4.0/types.ts";
export * as ddcVimSource from "https://deno.land/x/ddc_vim@v3.4.0/base/source.ts";
export * as dduVim from "https://deno.land/x/ddu_vim@v1.13.0/types.ts";
export * as dduVimSource from "https://deno.land/x/ddu_vim@v1.13.0/base/source.ts";
export * as traq from "https://esm.sh/@traptitech/traq@3.11.0-3";

0 comments on commit 7f8d1da

Please sign in to comment.