aboutsummaryrefslogtreecommitdiff
path: root/src/content/client/FindClient.ts
blob: 8b2aca49bc7a9e449c65c4a8cb5af518d130e7ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import * as messages from '../../shared/messages';

export default interface FindClient {
  getGlobalLastKeyword(): Promise<string | null>;

  setGlobalLastKeyword(keyword: string): Promise<void>;
}

export class FindClientImpl implements FindClient {
  async getGlobalLastKeyword(): Promise<string | null> {
    const keyword = await browser.runtime.sendMessage({
      type: messages.FIND_GET_KEYWORD,
    });
    return keyword as string;
  }

  async setGlobalLastKeyword(keyword: string): Promise<void> {
    await browser.runtime.sendMessage({
      type: messages.FIND_SET_KEYWORD,
      keyword: keyword,
    });
  }
}