@@ -137,37 +137,18 @@ export type ReplyToType = {
137
137
parentId ?: string ;
138
138
} ;
139
139
140
- type GroupPostCategoryType = Omit <
141
- PostCategory ,
142
- PostCategory . Video | PostCategory . Article | PostCategory . MusicAudio
143
- > ;
144
-
145
- const postCategoriesGrouped : GroupPostCategoryType [ ] = [
146
- PostCategory . Reaction ,
147
- PostCategory . Comment ,
148
- PostCategory . Normal ,
149
- PostCategory . Picture ,
150
- PostCategory . Question ,
151
- PostCategory . BriefForStableDiffusion ,
152
- PostCategory . Flagged ,
153
- PostCategory . VideoNote ,
154
- PostCategory . Audio ,
155
- ] ;
156
-
157
- const socialFeedSchemaMap : Record < PostCategory , z . ZodTypeAny > = {
158
- [ PostCategory . Video ] : ZodSocialFeedVideoMetadata ,
159
- [ PostCategory . Article ] : ZodSocialFeedArticleMetadata ,
160
- [ PostCategory . MusicAudio ] : ZodSocialFeedTrackMetadata ,
161
- ...Object . fromEntries (
162
- postCategoriesGrouped . map ( ( cat ) => [ cat , ZodSocialFeedPostMetadata ] ) ,
163
- ) ,
164
- } ;
165
-
166
140
export const parseSocialFeedMetadata = (
167
141
category : PostCategory ,
168
142
metadata : string ,
169
143
) => {
170
- const zodType = socialFeedSchemaMap [ category ] ;
171
-
172
- return zodTryParseJSON ( zodType , metadata ) ;
144
+ switch ( category ) {
145
+ case PostCategory . Video :
146
+ return zodTryParseJSON ( ZodSocialFeedVideoMetadata , metadata ) ;
147
+ case PostCategory . Article :
148
+ return zodTryParseJSON ( ZodSocialFeedPostMetadata , metadata ) ;
149
+ case PostCategory . MusicAudio :
150
+ return zodTryParseJSON ( ZodSocialFeedTrackMetadata , metadata ) ;
151
+ default :
152
+ return zodTryParseJSON ( ZodSocialFeedPostMetadata , metadata ) ;
153
+ }
173
154
} ;
0 commit comments