Skip to content

Commit fef5c59

Browse files
authored
Feat/bulk insert api (#210)
* feat(bulk insert): 🚧 api bulk insert * feat(twitter): ✨ added twitter sync api * feat(twitter): ✨ added tweets sections and updates all the apis for tweets * fix(twitter): ✨ added empty tweets condition * feat(twitter): ✨ added twitter sync api * feat(timeline): ✨ added new timeline option * feat(read more): ✨ added read more component for description * feat(twitter): ✨ added avatar and blur hash * feat(twitter sync): ✨ added duplicate check in sync logic * fix(TS): 🐛 fixed TS issues * test(env): 🚧 flipped prod env * fix(env): ⚡️ reverted production fix
1 parent 601e404 commit fef5c59

29 files changed

+800
-372
lines changed

Diff for: src/async/mutationHooks/bookmarks/useAddBookmarkMinDataOptimisticMutation.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
DOCUMENTS_URL,
1919
IMAGES_URL,
2020
menuListItemName,
21+
TWEETS_URL,
2122
URL_IMAGE_CHECK_PATTERN,
2223
VIDEOS_URL,
2324
} from "../../../utils/constants";
@@ -143,6 +144,7 @@ export default function useAddBookmarkMinDataOptimisticMutation() {
143144
if (
144145
(CATEGORY_ID === VIDEOS_URL ||
145146
CATEGORY_ID === DOCUMENTS_URL ||
147+
CATEGORY_ID === TWEETS_URL ||
146148
CATEGORY_ID === IMAGES_URL) &&
147149
apiResponseTyped?.status === 200
148150
) {

Diff for: src/async/mutationHooks/files/useFileUploadOptimisticMutation.ts

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
imageFileTypes,
1616
IMAGES_URL,
1717
LINKS_URL,
18+
TWEETS_URL,
19+
tweetType,
1820
videoFileTypes,
1921
VIDEOS_URL,
2022
} from "../../../utils/constants";
@@ -182,6 +184,10 @@ export default function useFileUploadOptimisticMutation() {
182184
successToast(`Added to ${fileTypeName}`);
183185
}
184186

187+
if (CATEGORY_ID === TWEETS_URL && uploadedDataType !== tweetType) {
188+
successToast(`Added to ${fileTypeName}`);
189+
}
190+
185191
if (CATEGORY_ID === LINKS_URL && uploadedDataType !== bookmarkType) {
186192
successToast(`Added to ${fileTypeName}`);
187193
}

Diff for: src/components/customDropdowns.tsx/bookmarksSortDropdown.tsx

+3-80
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,39 @@
1-
import { type PostgrestError } from "@supabase/supabase-js";
2-
import { useQueryClient } from "@tanstack/react-query";
3-
import { isEmpty } from "lodash";
41
import find from "lodash/find";
52

3+
import useGetSortBy from "../../hooks/useGetSortBy";
64
import AlphabeticalIcon from "../../icons/sortByIcons/alphabeticalIcon";
75
import ClockRewindIcon from "../../icons/sortByIcons/clockRewindIcon";
86
import DateIcon from "../../icons/sortByIcons/dateIcon";
97
import TickIcon from "../../icons/tickIcon";
10-
import {
11-
useLoadersStore,
12-
useSupabaseSession,
13-
} from "../../store/componentStore";
14-
import {
15-
type CategoriesData,
16-
type FetchSharedCategoriesData,
17-
type ProfilesTableTypes,
18-
} from "../../types/apiTypes";
8+
import { useLoadersStore } from "../../store/componentStore";
199
import {
2010
type BookmarksSortByTypes,
2111
type BookmarkViewCategories,
2212
} from "../../types/componentStoreTypes";
23-
import { type CategoryIdUrlTypes } from "../../types/componentTypes";
2413
import { dropdownMenuItemClassName } from "../../utils/commonClassNames";
25-
import {
26-
CATEGORIES_KEY,
27-
SHARED_CATEGORIES_TABLE_NAME,
28-
USER_PROFILE,
29-
} from "../../utils/constants";
3014
import { AriaDropdownMenu } from "../ariaDropdown";
3115
import AriaSelect from "../ariaSelect";
3216
import Spinner from "../spinner";
3317

3418
type BookmarksSortDropdownTypes = {
35-
categoryId: CategoryIdUrlTypes;
3619
isDropdown?: boolean;
3720
renderOnlyButton?: boolean;
3821
setBookmarksView: (
3922
value: BookmarksSortByTypes,
4023
type: BookmarkViewCategories,
4124
) => void;
42-
userId: string;
4325
};
4426

4527
const BookmarksSortDropdown = (props: BookmarksSortDropdownTypes) => {
4628
const {
4729
setBookmarksView,
48-
categoryId,
49-
userId,
5030
isDropdown = true,
5131
renderOnlyButton = false,
5232
} = props;
5333

54-
const queryClient = useQueryClient();
55-
const session = useSupabaseSession((state) => state.session);
56-
57-
const categoryData = queryClient.getQueryData([CATEGORIES_KEY, userId]) as {
58-
data: CategoriesData[];
59-
error: PostgrestError;
60-
};
61-
62-
const userProfilesData = queryClient.getQueryData([USER_PROFILE, userId]) as {
63-
data: ProfilesTableTypes[];
64-
error: PostgrestError;
65-
};
66-
67-
const sharedCategoriesData = queryClient.getQueryData([
68-
SHARED_CATEGORIES_TABLE_NAME,
69-
]) as {
70-
data: FetchSharedCategoriesData[];
71-
error: PostgrestError;
72-
};
73-
7434
const isSortByLoading = useLoadersStore((state) => state.isSortByLoading);
7535

76-
const currentCategory = find(
77-
categoryData?.data,
78-
(item) => item?.id === categoryId,
79-
);
80-
81-
const isInNonCategoryPage = typeof categoryId !== "number";
82-
83-
const getSortValue = () => {
84-
if (!isInNonCategoryPage) {
85-
// user is in a category page
86-
87-
// tells if the user is the category owner
88-
const isUserTheCategoryOwner = currentCategory?.user_id?.id === userId;
89-
90-
if (isUserTheCategoryOwner) {
91-
// if user is the category owner then get value from category table
92-
return currentCategory?.category_views?.sortBy;
93-
} else {
94-
// if user is not the category owner then get value from the shared category table
95-
const sharedCategoryUserData = find(
96-
sharedCategoriesData?.data,
97-
(item) =>
98-
item?.category_id === categoryId &&
99-
item?.email === session?.user?.email,
100-
);
101-
102-
return sharedCategoryUserData?.category_views?.sortBy;
103-
}
104-
}
105-
106-
if (!isEmpty(userProfilesData?.data)) {
107-
return userProfilesData?.data[0]?.bookmarks_view?.sortBy as string;
108-
}
109-
110-
return "";
111-
};
112-
113-
const bookmarksSortValue = getSortValue();
36+
const { sortBy: bookmarksSortValue } = useGetSortBy();
11437

11538
const sortOptions = [
11639
// {

0 commit comments

Comments
 (0)