Skip to content

Commit

Permalink
refactor: types to new name
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Sep 28, 2023
1 parent 176b940 commit ee4187f
Show file tree
Hide file tree
Showing 29 changed files with 79 additions and 81 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/components/Channel/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ClockIcon } from '@heroicons/react/24/outline';
import { FireIcon } from '@heroicons/react/24/solid';
import { STATIC_IMAGES_URL } from '@hey/data/constants';
import formatHandle from '@hey/lib/formatHandle';
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { Image, LightBox, Tooltip } from '@hey/ui';
import { formatDate } from '@lib/formatTime';
import { t } from '@lingui/macro';
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Channel/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
PublicationTypes,
useExploreFeedQuery
} from '@hey/lens';
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { Card, EmptyState, ErrorMessage } from '@hey/ui';
import { t } from '@lingui/macro';
import type { FC } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Channel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MetaTags from '@components/Common/MetaTags';
import { APP_NAME, CHANNELS_WORKER_URL } from '@hey/data/constants';
import { PAGEVIEW } from '@hey/data/tracking';
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { GridItemEight, GridItemFour, GridLayout } from '@hey/ui';
import { Leafwatch } from '@lib/leafwatch';
import { useQuery } from '@tanstack/react-query';
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
import { useApolloClient } from '@hey/lens/apollo';
import getSignature from '@hey/lib/getSignature';
import type { IGif } from '@hey/types/giphy';
import type { NewLensterAttachment } from '@hey/types/misc';
import type { NewAttachment } from '@hey/types/misc';
import { Button, Card, ErrorMessage, Spinner } from '@hey/ui';
import cn from '@hey/ui/cn';
import type {
Expand Down Expand Up @@ -847,7 +847,7 @@ const NewPublication: FC<NewPublicationProps> = ({ publication }) => {
};

const setGifAttachment = (gif: IGif) => {
const attachment: NewLensterAttachment = {
const attachment: NewAttachment = {
id: uuid(),
previewItem: gif.images.original.url,
original: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LENSTER_POLLS_SPACE } from '@hey/data/constants';
import { HEY_POLLS_SPACE } from '@hey/data/constants';
import stopEventPropagation from '@hey/lib/stopEventPropagation';
import type { Proposal, Vote } from '@hey/snapshot';
import { useProposalQuery } from '@hey/snapshot';
Expand Down Expand Up @@ -42,7 +42,7 @@ const Snapshot: FC<SnapshotProps> = ({ proposalId }) => {
}

const { proposal, votes } = data;
const isLensterPoll = proposal?.space?.id === LENSTER_POLLS_SPACE;
const isLensterPoll = proposal?.space?.id === HEY_POLLS_SPACE;

if (!proposal) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Shared/Attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import getThumbnailUrl from '@hey/lib/getThumbnailUrl';
import imageKit from '@hey/lib/imageKit';
import sanitizeDStorageUrl from '@hey/lib/sanitizeDStorageUrl';
import stopEventPropagation from '@hey/lib/stopEventPropagation';
import type { NewLensterAttachment } from '@hey/types/misc';
import type { NewAttachment } from '@hey/types/misc';
import { Button, Image, LightBox } from '@hey/ui';
import cn from '@hey/ui/cn';
import { Leafwatch } from '@lib/leafwatch';
Expand Down Expand Up @@ -104,7 +104,7 @@ const Attachments: FC<AttachmentsProps> = ({
<>
<div className={cn(getClass(attachmentsLength)?.row, 'mt-3 grid gap-2')}>
{slicedAttachments?.map(
(attachment: NewLensterAttachment & MediaSet, index: number) => {
(attachment: NewAttachment & MediaSet, index: number) => {
const type = attachment.original?.mimeType;
const url = isNew
? attachment.previewItem
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Shared/Channel/Join.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UserPlusIcon } from '@heroicons/react/24/outline';
import { CHANNELS_WORKER_URL } from '@hey/data/constants';
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { Button, Modal } from '@hey/ui';
import { t } from '@lingui/macro';
import { useQuery } from '@tanstack/react-query';
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Shared/Channel/Mint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CurrencyDollarIcon, UserPlusIcon } from '@heroicons/react/24/outline';
import { CheckCircleIcon } from '@heroicons/react/24/solid';
import { ZoraERC721Drop } from '@hey/abis';
import { ADMIN_ADDRESS } from '@hey/data/constants';
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { Button, Spinner } from '@hey/ui';
import { t, Trans } from '@lingui/macro';
import Link from 'next/link';
Expand Down
36 changes: 17 additions & 19 deletions apps/web/src/hooks/useUploadAttachments.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NewLensterAttachment } from '@hey/types/misc';
import type { NewAttachment } from '@hey/types/misc';
import uploadToIPFS from '@lib/uploadToIPFS';
import { t } from '@lingui/macro';
import { useCallback } from 'react';
Expand All @@ -20,27 +20,25 @@ const useUploadAttachments = () => {
);

const handleUploadAttachments = useCallback(
async (attachments: any): Promise<NewLensterAttachment[]> => {
async (attachments: any): Promise<NewAttachment[]> => {
setIsUploading(true);
const files = Array.from(attachments);
const attachmentIds: string[] = [];

const previewAttachments: NewLensterAttachment[] = files.map(
(file: any) => {
const attachmentId = uuid();
attachmentIds.push(attachmentId);
const previewAttachments: NewAttachment[] = files.map((file: any) => {
const attachmentId = uuid();
attachmentIds.push(attachmentId);

return {
id: attachmentId,
file: file,
previewItem: URL.createObjectURL(file),
original: {
url: URL.createObjectURL(file),
mimeType: file.type
}
};
}
);
return {
id: attachmentId,
file: file,
previewItem: URL.createObjectURL(file),
original: {
url: URL.createObjectURL(file),
mimeType: file.type
}
};
});

const hasLargeAttachment = files.map((file: any) => {
const isImage = file.type.includes('image');
Expand All @@ -66,7 +64,7 @@ const useUploadAttachments = () => {
});

addAttachments(previewAttachments);
let attachmentsIPFS: NewLensterAttachment[] = [];
let attachmentsIPFS: NewAttachment[] = [];
try {
if (hasLargeAttachment.includes(false)) {
setIsUploading(false);
Expand All @@ -80,7 +78,7 @@ const useUploadAttachments = () => {
);
if (attachmentsUploaded) {
attachmentsIPFS = previewAttachments.map(
(attachment: NewLensterAttachment, index: number) => ({
(attachment: NewAttachment, index: number) => ({
...attachment,
original: {
url: attachmentsUploaded[index].original.url,
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/lib/getAlgorithmicFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const getAlgorithmicFeed = async (
offset,
profile?.handle
).then((data) => data);
case HomeFeedType.LENSTER_MOSTVIEWED:
case HomeFeedType.LENSTER_MOSTINTERACTED:
case HomeFeedType.HEY_MOSTVIEWED:
case HomeFeedType.HEY_MOSTINTERACTED:
return getPublicationIds(
AlgorithmProvider.LENSTER,
feedType.replace('LENSTER_', '').toLowerCase(),
AlgorithmProvider.HEY,
feedType.replace('HEY_', '').toLowerCase(),
limit,
offset
).then((data) => data);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/getChannelByTag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { featuredChannels } from 'src/store/app';

const getChannelByTag = (tags: string[]): Channel | undefined => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/uploadToIPFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const uploadToIPFS = async (
files.map(async (_: any, i: number) => {
const file = data[i];
const params = {
Bucket: S3_BUCKET.LENSTER_MEDIA,
Bucket: S3_BUCKET.HEY_MEDIA,
Key: uuid(),
Body: file,
ContentType: file.type
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/store/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Localstorage } from '@hey/data/storage';
import type { Profile } from '@hey/lens';
import type { Channel } from '@hey/types/lenster';
import type { Channel } from '@hey/types/hey';
import { create } from 'zustand';
import { persist } from 'zustand/middleware';

Expand Down
10 changes: 5 additions & 5 deletions apps/web/src/store/publication.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Publication } from '@hey/lens';
import type { NewLensterAttachment } from '@hey/types/misc';
import type { NewAttachment } from '@hey/types/misc';
import { create } from 'zustand';

interface PublicationState {
Expand All @@ -19,10 +19,10 @@ interface PublicationState {
cover: string;
coverMimeType: string;
}) => void;
attachments: NewLensterAttachment[];
setAttachments: (attachments: NewLensterAttachment[]) => void;
addAttachments: (attachments: NewLensterAttachment[]) => void;
updateAttachments: (attachments: NewLensterAttachment[]) => void;
attachments: NewAttachment[];
setAttachments: (attachments: NewAttachment[]) => void;
addAttachments: (attachments: NewAttachment[]) => void;
updateAttachments: (attachments: NewAttachment[]) => void;
removeAttachments: (ids: string[]) => void;
videoThumbnail: {
url?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/data/algorithms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export const algorithms: {
}[] = [
{
name: 'Most viewed',
feedType: HomeFeedType.LENSTER_MOSTVIEWED,
feedType: HomeFeedType.HEY_MOSTVIEWED,
description:
'Most viewed posts sorted by the number of views in the last 24 hours in Lenster.',
image: `${STATIC_IMAGES_URL}/algorithms/lenster-mostviewed.png`,
by: 'Lenster'
},
{
name: 'Most interacted',
feedType: HomeFeedType.LENSTER_MOSTINTERACTED,
feedType: HomeFeedType.HEY_MOSTINTERACTED,
description:
'Most interacted posts sorted by the number of interactions in the last 24 hours in Lenster.',
image: `${STATIC_IMAGES_URL}/algorithms/lenster-mostinteracted.png`,
Expand Down
4 changes: 2 additions & 2 deletions packages/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const XMTP_ENV = IS_MAINNET ? 'production' : 'dev';
export const XMTP_PREFIX = 'lens.dev/dm';

// Snapshot
export const LENSTER_POLLS_SPACE = 'polls.lenster.xyz';
export const HEY_POLLS_SPACE = 'polls.lenster.xyz';
export const SNAPSHOT_HUB_URL = IS_MAINNET
? 'https://hub.snapshot.org'
: 'https://testnet.snapshot.org';
Expand Down Expand Up @@ -159,5 +159,5 @@ export const ATTACHMENT = 'tr:w-1000';

// S3 bucket
export const S3_BUCKET = {
LENSTER_MEDIA: 'lenster-media'
HEY_MEDIA: 'hey-media'
};
6 changes: 3 additions & 3 deletions packages/data/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export enum HomeFeedType {
K3L_POPULAR = 'K3L_POPULAR',
K3L_CROWDSOURCED = 'K3L_CROWDSOURCED',
K3L_FOLLOWING = 'K3L_FOLLOWING',
LENSTER_MOSTVIEWED = 'LENSTER_MOSTVIEWED',
LENSTER_MOSTINTERACTED = 'LENSTER_MOSTINTERACTED'
HEY_MOSTVIEWED = 'HEY_MOSTVIEWED',
HEY_MOSTINTERACTED = 'HEY_MOSTINTERACTED'
}

export const AlgorithmProvider = {
K3L: 'k3l',
LENSTER: 'lenster'
HEY: 'hey'
};
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/types/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { MediaSet } from '@hey/lens';

export interface MediaSetWithoutOnChain extends Omit<MediaSet, 'onChain'> {}

export interface NewLensterAttachment extends MediaSetWithoutOnChain {
export interface NewAttachment extends MediaSetWithoutOnChain {
id: string;
file?: File;
previewItem: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/workers/feeds/src/handlers/getPublicationIds.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AlgorithmProvider } from '@hey/data/enums';
import response from '@hey/lib/response';

import heyFeed from '../providers/hey/heyFeed';
import k3lFeed from '../providers/k3l/k3lFeed';
import lensterFeed from '../providers/lenster/lensterFeed';
import type { WorkerRequest } from '../types';

export default async (request: WorkerRequest) => {
Expand All @@ -25,8 +25,8 @@ export default async (request: WorkerRequest) => {
case AlgorithmProvider.K3L:
ids = await k3lFeed(strategy, profile, limit, offset);
break;
case AlgorithmProvider.LENSTER:
ids = await lensterFeed(strategy, limit, offset, request.env);
case AlgorithmProvider.HEY:
ids = await heyFeed(strategy, limit, offset, request.env);
break;
default:
return response({ success: false, message: 'Invalid provider' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const generateWeightedCaseStatement = () => {
.join(' ');
};

const lensterMostInteracted = async (
const heyMostInteracted = async (
limit: number,
offset: number,
env: Env
Expand Down Expand Up @@ -71,4 +71,4 @@ const lensterMostInteracted = async (
}
};

export default lensterMostInteracted;
export default heyMostInteracted;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import removeParamsFromString from '../../../helpers/removeParamsFromString';
import type { Env } from '../../../types';
import clickhouseQuery from '../clickhouseQuery';

const lensterMostViewed = async (
const heyMostViewed = async (
limit: number,
offset: number,
env: Env
Expand Down Expand Up @@ -48,4 +48,4 @@ const lensterMostViewed = async (
}
};

export default lensterMostViewed;
export default heyMostViewed;
21 changes: 21 additions & 0 deletions packages/workers/feeds/src/providers/hey/heyFeed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Env } from '../../types';
import heyMostInteracted from './algorithms/heyMostInteracted';
import heyMostViewed from './algorithms/heyMostViewed';

const heyFeed = async (
strategy: string,
limit: number,
offset: number,
env: Env
) => {
switch (strategy) {
case 'mostviewed':
return await heyMostViewed(limit, offset, env);
case 'mostinteracted':
return await heyMostInteracted(limit, offset, env);
default:
return [];
}
};

export default heyFeed;
21 changes: 0 additions & 21 deletions packages/workers/feeds/src/providers/lenster/lensterFeed.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/workers/snapshot-relay/src/handlers/createPoll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
LENSTER_POLLS_SPACE,
HEY_POLLS_SPACE,
MAINNET_SNAPSHOT_SEQUNECER_URL,
MAINNET_SNAPSHOT_URL,
TESTNET_SNAPSHOT_SEQUNECER_URL,
Expand Down Expand Up @@ -93,7 +93,7 @@ export default async (request: WorkerRequest) => {
]
},
message: {
space: LENSTER_POLLS_SPACE,
space: HEY_POLLS_SPACE,
type: 'single-choice',
title,
body: description,
Expand Down Expand Up @@ -132,7 +132,7 @@ export default async (request: WorkerRequest) => {

return response({
success: true,
snapshotUrl: `${snapshotUrl}/#/${LENSTER_POLLS_SPACE}/proposal/${snapshotResponse.id}`
snapshotUrl: `${snapshotUrl}/#/${HEY_POLLS_SPACE}/proposal/${snapshotResponse.id}`
});
} catch (error) {
throw error;
Expand Down

0 comments on commit ee4187f

Please sign in to comment.