Migrate InviteStore.js to TypeScript.

This commit is contained in:
Danila Fedorin 2021-08-11 12:03:06 -07:00
parent 7c56ac7746
commit 7de704ef86
2 changed files with 23 additions and 5 deletions

View File

@ -19,7 +19,7 @@ import {StorageError} from "../common";
import {Store} from "./Store";
import {SessionStore} from "./stores/SessionStore";
import {RoomSummaryStore} from "./stores/RoomSummaryStore";
import {InviteStore} from "./stores/InviteStore.js";
import {InviteStore} from "./stores/InviteStore";
import {TimelineEventStore} from "./stores/TimelineEventStore.js";
import {TimelineRelationStore} from "./stores/TimelineRelationStore.js";
import {RoomStateStore} from "./stores/RoomStateStore.js";

View File

@ -13,21 +13,39 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {Store} from "../Store";
import {MemberData} from "./RoomMemberStore";
// TODO: Move to Invite when that's TypeScript.
export interface InviteData {
roomId: string;
isEncrypted: boolean;
isDirectMessage: boolean;
name?: string;
avatarUrl?: string;
avatarColorId: number;
canonicalAlias?: string;
timestamp: number;
joinRule: string;
inviter?: MemberData;
}
export class InviteStore {
constructor(inviteStore) {
private _inviteStore: Store<InviteData>;
constructor(inviteStore: Store<InviteData>) {
this._inviteStore = inviteStore;
}
getAll() {
getAll(): Promise<InviteData[]> {
return this._inviteStore.selectAll();
}
set(invite) {
set(invite: InviteData): Promise<IDBValidKey> {
return this._inviteStore.put(invite);
}
remove(roomId) {
remove(roomId: string): void {
this._inviteStore.delete(roomId);
}
}