More protobufjs migration
This commit is contained in:
parent
cf06e6638e
commit
ddbbe3a6b1
70 changed files with 3967 additions and 3369 deletions
|
@ -4,19 +4,19 @@
|
|||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
import type {
|
||||
ConversationAttributesType,
|
||||
ConversationModelCollectionType,
|
||||
MessageAttributesType,
|
||||
MessageModelCollectionType,
|
||||
} from '../model-types.d';
|
||||
import { MessageModel } from '../models/messages';
|
||||
import { ConversationModel } from '../models/conversations';
|
||||
import { StoredJob } from '../jobs/types';
|
||||
import { ReactionType } from '../types/Reactions';
|
||||
import { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
import type { MessageModel } from '../models/messages';
|
||||
import type { ConversationModel } from '../models/conversations';
|
||||
import type { StoredJob } from '../jobs/types';
|
||||
import type { ReactionType } from '../types/Reactions';
|
||||
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
import { StorageAccessType } from '../types/Storage.d';
|
||||
import { AttachmentType } from '../types/Attachment';
|
||||
import type { AttachmentType } from '../types/Attachment';
|
||||
|
||||
export type AttachmentDownloadJobTypeType =
|
||||
| 'long-message'
|
||||
|
@ -111,41 +111,48 @@ export type SignedPreKeyType = {
|
|||
privateKey: ArrayBuffer;
|
||||
publicKey: ArrayBuffer;
|
||||
};
|
||||
export type StickerPackStatusType =
|
||||
| 'known'
|
||||
| 'ephemeral'
|
||||
| 'downloaded'
|
||||
| 'installed'
|
||||
| 'pending'
|
||||
| 'error';
|
||||
|
||||
export type StickerType = {
|
||||
export type StickerType = Readonly<{
|
||||
id: number;
|
||||
packId: string;
|
||||
|
||||
emoji: string | null;
|
||||
emoji?: string;
|
||||
isCoverOnly: boolean;
|
||||
lastUsed?: number;
|
||||
path: string;
|
||||
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
export type StickerPackType = {
|
||||
}>;
|
||||
|
||||
export const StickerPackStatuses = [
|
||||
'known',
|
||||
'ephemeral',
|
||||
'downloaded',
|
||||
'installed',
|
||||
'pending',
|
||||
'error',
|
||||
] as const;
|
||||
|
||||
export type StickerPackStatusType = typeof StickerPackStatuses[number];
|
||||
|
||||
export type StickerPackType = Readonly<{
|
||||
id: string;
|
||||
key: string;
|
||||
|
||||
attemptedStatus: 'downloaded' | 'installed' | 'ephemeral';
|
||||
attemptedStatus?: 'downloaded' | 'installed' | 'ephemeral';
|
||||
author: string;
|
||||
coverStickerId: number;
|
||||
createdAt: number;
|
||||
downloadAttempts: number;
|
||||
installedAt: number | null;
|
||||
lastUsed: number;
|
||||
installedAt?: number;
|
||||
lastUsed?: number;
|
||||
status: StickerPackStatusType;
|
||||
stickerCount: number;
|
||||
stickers: ReadonlyArray<string>;
|
||||
stickers: Record<string, StickerType>;
|
||||
title: string;
|
||||
};
|
||||
}>;
|
||||
|
||||
export type UnprocessedType = {
|
||||
id: string;
|
||||
timestamp: number;
|
||||
|
|
|
@ -33,6 +33,7 @@ import { ReactionType } from '../types/Reactions';
|
|||
import { StoredJob } from '../jobs/types';
|
||||
import { assert } from '../util/assert';
|
||||
import { combineNames } from '../util/combineNames';
|
||||
import { dropNull } from '../util/dropNull';
|
||||
import { isNormalNumber } from '../util/isNormalNumber';
|
||||
import { isNotNil } from '../util/isNotNil';
|
||||
import { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
|
@ -301,6 +302,7 @@ function rowToSticker(row: StickerRow): StickerType {
|
|||
return {
|
||||
...row,
|
||||
isCoverOnly: Boolean(row.isCoverOnly),
|
||||
emoji: dropNull(row.emoji),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -4416,13 +4418,13 @@ async function createOrUpdateStickerPack(pack: StickerPackType): Promise<void> {
|
|||
)
|
||||
.all({ id });
|
||||
const payload = {
|
||||
attemptedStatus,
|
||||
attemptedStatus: attemptedStatus ?? null,
|
||||
author,
|
||||
coverStickerId,
|
||||
createdAt: createdAt || Date.now(),
|
||||
downloadAttempts: downloadAttempts || 1,
|
||||
id,
|
||||
installedAt,
|
||||
installedAt: installedAt ?? null,
|
||||
key,
|
||||
lastUsed: lastUsed || null,
|
||||
status,
|
||||
|
@ -4563,7 +4565,7 @@ async function createOrUpdateSticker(sticker: StickerType): Promise<void> {
|
|||
)
|
||||
`
|
||||
).run({
|
||||
emoji,
|
||||
emoji: emoji ?? null,
|
||||
height,
|
||||
id,
|
||||
isCoverOnly: isCoverOnly ? 1 : 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue