Stickers in storage service
This commit is contained in:
parent
d8a7e99c81
commit
b47a906211
18 changed files with 1216 additions and 80 deletions
|
@ -96,6 +96,8 @@ const STICKER_PACK_DEFAULTS: StickerPackType = {
|
|||
stickerCount: 0,
|
||||
stickers: {},
|
||||
title: '',
|
||||
|
||||
storageNeedsSync: false,
|
||||
};
|
||||
|
||||
const VALID_PACK_ID_REGEXP = /^[0-9a-f]{32}$/i;
|
||||
|
@ -529,6 +531,7 @@ export async function downloadEphemeralPack(
|
|||
export type DownloadStickerPackOptions = Readonly<{
|
||||
messageId?: string;
|
||||
fromSync?: boolean;
|
||||
fromStorageService?: boolean;
|
||||
finalStatus?: StickerPackStatusType;
|
||||
suppressError?: boolean;
|
||||
}>;
|
||||
|
@ -558,6 +561,7 @@ async function doDownloadStickerPack(
|
|||
finalStatus = 'downloaded',
|
||||
messageId,
|
||||
fromSync = false,
|
||||
fromStorageService = false,
|
||||
suppressError = false,
|
||||
}: DownloadStickerPackOptions
|
||||
): Promise<void> {
|
||||
|
@ -668,6 +672,7 @@ async function doDownloadStickerPack(
|
|||
status: 'pending',
|
||||
createdAt: Date.now(),
|
||||
stickers: {},
|
||||
storageNeedsSync: !fromStorageService,
|
||||
...pick(proto, ['title', 'author']),
|
||||
};
|
||||
await Data.createOrUpdateStickerPack(pack);
|
||||
|
@ -748,7 +753,10 @@ async function doDownloadStickerPack(
|
|||
}
|
||||
|
||||
if (finalStatus === 'installed') {
|
||||
await installStickerPack(packId, packKey, { fromSync });
|
||||
await installStickerPack(packId, packKey, {
|
||||
fromSync,
|
||||
fromStorageService,
|
||||
});
|
||||
} else {
|
||||
// Mark the pack as complete
|
||||
await Data.updateStickerPackStatus(packId, finalStatus);
|
||||
|
@ -888,7 +896,7 @@ export async function deletePackReference(
|
|||
}
|
||||
|
||||
// The override; doesn't honor our ref-counting scheme - just deletes it all.
|
||||
export async function deletePack(packId: string): Promise<void> {
|
||||
async function deletePack(packId: string): Promise<void> {
|
||||
const isBlessed = Boolean(BLESSED_PACKS[packId]);
|
||||
if (isBlessed) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue