messagestorage: remove implementation details from interface

The interface should not contain things that aren't the API of the
storage interface.
Further, rename ISqliteMessageStorage to SearchableMessageStorage,
as that's also an implementation detail.
We'll never have a second sqlite backend, so the name seems
strange.
This commit is contained in:
Reto Brunner 2022-12-30 16:06:46 +01:00
parent 8b1a4f72fa
commit 661d5cb5b0
2 changed files with 5 additions and 11 deletions

View File

@ -8,11 +8,7 @@ import Msg, {Message} from "../../models/msg";
import Client from "../../client"; import Client from "../../client";
import Chan, {Channel} from "../../models/chan"; import Chan, {Channel} from "../../models/chan";
import Helper from "../../helper"; import Helper from "../../helper";
import type { import type {SearchResponse, SearchQuery, SearchableMessageStorage} from "./types";
SearchResponse,
SearchQuery,
SqliteMessageStorage as ISqliteMessageStorage,
} from "./types";
import Network from "../../models/network"; import Network from "../../models/network";
// TODO; type // TODO; type
@ -49,11 +45,11 @@ class Deferred {
} }
} }
class SqliteMessageStorage implements ISqliteMessageStorage { class SqliteMessageStorage implements SearchableMessageStorage {
client: Client;
isEnabled: boolean; isEnabled: boolean;
database!: Database; database!: Database;
initDone: Deferred; initDone: Deferred;
client: Client;
constructor(client: Client) { constructor(client: Client) {
this.client = client; this.client = client;

View File

@ -6,7 +6,6 @@ import {Network} from "../../models/network";
import Client from "../../client"; import Client from "../../client";
interface MessageStorage { interface MessageStorage {
client: Client;
isEnabled: boolean; isEnabled: boolean;
enable(): Promise<void>; enable(): Promise<void>;
@ -38,7 +37,6 @@ export type SearchResponse =
type SearchFunction = (query: SearchQuery) => Promise<SearchResponse>; type SearchFunction = (query: SearchQuery) => Promise<SearchResponse>;
export interface SqliteMessageStorage extends MessageStorage { export interface SearchableMessageStorage extends MessageStorage {
database: Database; search: SearchFunction;
search: SearchFunction | [];
} }