Fixes storybook

This commit is contained in:
Josh Perez 2022-11-09 16:11:45 -05:00 committed by GitHub
parent 4fa614e1d6
commit 4a5da95c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 30 deletions

View file

@ -28,7 +28,7 @@ import { sleep } from './util/sleep';
import { isNotNil } from './util/isNotNil';
import { MINUTE, SECOND } from './util/durations';
import { getUuidsForE164s } from './util/getUuidsForE164s';
import { SIGNAL_ACI, SIGNAL_AVATAR_PATH } from './types/Conversation';
import { SIGNAL_ACI, SIGNAL_AVATAR_PATH } from './types/SignalConversation';
type ConvoMatchType =
| {
@ -409,8 +409,8 @@ export class ConversationController {
return conversation;
}
getOrCreateSignalConversation(): ConversationModel {
const conversation = this.getOrCreate(SIGNAL_ACI, 'private', {
async getOrCreateSignalConversation(): Promise<ConversationModel> {
const conversation = await this.getOrCreateAndWait(SIGNAL_ACI, 'private', {
muteExpiresAt: Number.MAX_SAFE_INTEGER,
profileAvatar: { path: SIGNAL_AVATAR_PATH },
profileName: 'Signal',
@ -422,28 +422,12 @@ export class ConversationController {
return conversation;
}
getSignalConversationId(): string {
if (this._signalConversationId) {
return this._signalConversationId;
}
let conversation = this.get(SIGNAL_ACI);
if (!conversation) {
conversation = this.getOrCreateSignalConversation();
}
this._signalConversationId = conversation.id;
return conversation.id;
}
isSignalConversation(uuidOrId: string): boolean {
if (uuidOrId === SIGNAL_ACI) {
return true;
}
return this.getSignalConversationId() === uuidOrId;
return this._signalConversationId === uuidOrId;
}
areWePrimaryDevice(): boolean {

View file

@ -1021,6 +1021,7 @@ export async function startApp(): Promise<void> {
await window.ConversationController.load();
await Promise.all([
window.ConversationController.getOrCreateSignalConversation(),
Stickers.load(),
loadRecentEmojis(),
loadInitialBadgesState(),

View file

@ -25,7 +25,7 @@ import { getBadgeImageFileLocalPath } from '../badges/getBadgeImageFileLocalPath
import { getInitials } from '../util/getInitials';
import { isBadgeVisible } from '../badges/isBadgeVisible';
import { shouldBlurAvatar } from '../util/shouldBlurAvatar';
import { SIGNAL_AVATAR_PATH } from '../types/Conversation';
import { SIGNAL_AVATAR_PATH } from '../types/SignalConversation';
export enum AvatarBlur {
NoBlur,

View file

@ -11,7 +11,7 @@ import type { ViewUserStoriesActionCreatorType } from '../state/ducks/stories';
import { Avatar, AvatarSize } from './Avatar';
import { ConfirmationDialog } from './ConfirmationDialog';
import { ContextMenu } from './ContextMenu';
import { SIGNAL_ACI } from '../types/Conversation';
import { SIGNAL_ACI } from '../types/SignalConversation';
import { StoryViewTargetType, HasStories } from '../types/Stories';
import { MessageTimestamp } from './conversation/MessageTimestamp';

View file

@ -16,7 +16,7 @@ import { isNotNil } from '../util/isNotNil';
import { strictAssert } from '../util/assert';
import { dropNull } from '../util/dropNull';
import { isGroup } from '../util/whatTypeOfConversation';
import { SIGNAL_ACI } from '../types/Conversation';
import { SIGNAL_ACI } from '../types/SignalConversation';
let storyData:
| Array<

View file

@ -20,7 +20,7 @@ import type { StoryViewTargetType, StoryViewType } from '../../types/Stories';
import type { SyncType } from '../../jobs/helpers/syncHelpers';
import type { UUIDStringType } from '../../types/UUID';
import * as log from '../../logging/log';
import { SIGNAL_ACI } from '../../types/Conversation';
import { SIGNAL_ACI } from '../../types/SignalConversation';
import dataInterface from '../../sql/Client';
import { ReadStatus } from '../../messages/MessageReadStatus';
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';

View file

@ -38,7 +38,7 @@ import { getStoriesEnabled } from './items';
import { calculateExpirationTimestamp } from '../../util/expirationTimer';
import { getMessageIdForLogging } from '../../util/idForLogging';
import * as log from '../../logging/log';
import { SIGNAL_ACI } from '../../types/Conversation';
import { SIGNAL_ACI } from '../../types/SignalConversation';
export const getStoriesState = (state: StateType): StoriesStateType =>
state.stories;

View file

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { ConversationAttributesType } from '../model-types.d';
import { UUID } from './UUID';
import { computeHash } from '../Crypto';
export type BuildAvatarUpdaterOptions = Readonly<{
@ -88,6 +87,3 @@ export async function deleteExternalFiles(
await deleteAttachmentData(profileAvatar.path);
}
}
export const SIGNAL_ACI = UUID.cast('11111111-1111-4111-8111-111111111111');
export const SIGNAL_AVATAR_PATH = 'images/icon_256.png';

View file

@ -0,0 +1,7 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { UUID } from './UUID';
export const SIGNAL_ACI = UUID.cast('11111111-1111-4111-8111-111111111111');
export const SIGNAL_AVATAR_PATH = 'images/icon_256.png';

View file

@ -92,6 +92,7 @@ async function continueDownloadingOnboardingStory(): Promise<void> {
})
);
log.info('downloadOnboardingStory: getting signal conversation');
const signalConversation =
await window.ConversationController.getOrCreateSignalConversation();

View file

@ -1,7 +1,7 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { SIGNAL_ACI } from '../types/Conversation';
import { SIGNAL_ACI } from '../types/SignalConversation';
export function isSignalConversation(conversation: {
id: string;