Skip to content

Commit 35798e7

Browse files
authored
refactor: shift some text messages to work on blabsy (#199)
1 parent 72acf0b commit 35798e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2834
-2666
lines changed

platforms/blabsy/README.md

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,113 +12,112 @@ https://user-images.githubusercontent.com/55032197/201472767-9db0177a-79b5-4913-
1212

1313
## Features ✨
1414

15-
- Authentication with Firebase Authentication
16-
- Strongly typed React components with TypeScript
17-
- Users can add tweets, like, retweet, and reply
18-
- Users can delete tweets, add a tweet to bookmarks, and pin their tweet
19-
- Users can add images and GIFs to tweet
20-
- Users can follow and unfollow other users
21-
- Users can see their and other followers and the following list
22-
- Users can see all users and the trending list
23-
- Realtime update likes, retweets, and user profile
24-
- Realtime trending data from Twitter API
25-
- User can edit their profile
26-
- Responsive design for mobile, tablet, and desktop
27-
- Users can customize the site color scheme and color background
28-
- All images uploads are stored on Firebase Cloud Storage
15+
- Authentication with Firebase Authentication
16+
- Strongly typed React components with TypeScript
17+
- Users can add blabs, like, reblab, and reply
18+
- Users can delete blabs, add a blab to bookmarks, and pin their blab
19+
- Users can add images and GIFs to blab
20+
- Users can follow and unfollow other users
21+
- Users can see their and other followers and the following list
22+
- Users can see all users and the trending list
23+
- Realtime update likes, reblabs, and user profile
24+
- User can edit their profile
25+
- Responsive design for mobile, tablet, and desktop
26+
- Users can customize the site color scheme and color background
27+
- All images uploads are stored on Firebase Cloud Storage
2928

3029
## Tech 🛠
3130

32-
- [Next.js](https://nextjs.org)
33-
- [TypeScript](https://www.typescriptlang.org)
34-
- [Tailwind CSS](https://tailwindcss.com)
35-
- [Firebase](https://firebase.google.com)
36-
- [SWR](https://swr.vercel.app)
37-
- [Headless UI](https://headlessui.com)
38-
- [React Hot Toast](https://react-hot-toast.com)
39-
- [Framer Motion](https://framer.com)
31+
- [Next.js](https://nextjs.org)
32+
- [TypeScript](https://www.typescriptlang.org)
33+
- [Tailwind CSS](https://tailwindcss.com)
34+
- [Firebase](https://firebase.google.com)
35+
- [SWR](https://swr.vercel.app)
36+
- [Headless UI](https://headlessui.com)
37+
- [React Hot Toast](https://react-hot-toast.com)
38+
- [Framer Motion](https://framer.com)
4039

4140
## Development 💻
4241

4342
Here are the steps to run the project locally.
4443

4544
1. Clone the repository
4645

47-
```bash
48-
git clone https://github.com/ccrsxx/twitter-clone.git
49-
```
46+
```bash
47+
git clone https://github.com/MetaState-Prototype-Project/prototype.git
48+
```
5049

5150
1. Install dependencies
5251

53-
```bash
54-
npm i
55-
```
52+
```bash
53+
npm i
54+
```
5655

5756
1. Create a Firebase project and select the web app
5857

5958
1. Add your Firebase config to `.env.development`. Note that `NEXT_PUBLIC_MEASUREMENT_ID` is optional
6059

6160
1. Make sure you have enabled the following Firebase services:
6261

63-
- Authentication. Enable the Google sign-in method.
64-
- Cloud Firestore. Create a database and set its location to your nearest region.
65-
- Cloud Storage. Create a storage bucket.
62+
- Authentication. Enable the Google sign-in method.
63+
- Cloud Firestore. Create a database and set its location to your nearest region.
64+
- Cloud Storage. Create a storage bucket.
6665

6766
1. Install Firebase CLI globally
6867

69-
```bash
70-
npm i -g firebase-tools
71-
```
68+
```bash
69+
npm i -g firebase-tools
70+
```
7271

7372
1. Log in to Firebase
7473

75-
```bash
76-
firebase login
77-
```
74+
```bash
75+
firebase login
76+
```
7877

7978
1. Get your project ID
8079

81-
```bash
82-
firebase projects:list
83-
```
80+
```bash
81+
firebase projects:list
82+
```
8483

8584
1. Select your project ID
8685

87-
```bash
88-
firebase use your-project-id
89-
```
86+
```bash
87+
firebase use your-project-id
88+
```
9089

9190
1. At this point, you have two choices. Either run this project using the Firebase on the cloud or locally using emulator.
9291

93-
1. Using the Firebase Cloud Backend:
92+
1. Using the Firebase Cloud Backend:
9493

95-
1. Deploy Firestore rules, Firestore indexes, and Cloud Storage rules
94+
1. Deploy Firestore rules, Firestore indexes, and Cloud Storage rules
9695

97-
```bash
98-
firebase deploy --except functions
99-
```
96+
```bash
97+
firebase deploy --except functions
98+
```
10099

101-
1. Run the project
100+
1. Run the project
102101

103-
```bash
104-
npm run dev
105-
```
102+
```bash
103+
npm run dev
104+
```
106105

107-
1. Using Firebase Local Emulator:
106+
1. Using Firebase Local Emulator:
108107

109-
1. Install [Java JDK version 11 or higher](https://jdk.java.net/) before proceeding. This is required to run the emulators.
108+
1. Install [Java JDK version 11 or higher](https://jdk.java.net/) before proceeding. This is required to run the emulators.
110109

111-
1. Set the environment variable `NEXT_PUBLIC_USE_EMULATOR` to `true` in `.env.development`. This will make the app use the emulators instead of the cloud backend.
110+
1. Set the environment variable `NEXT_PUBLIC_USE_EMULATOR` to `true` in `.env.development`. This will make the app use the emulators instead of the cloud backend.
112111

113-
1. At this point, you can run the following command to have a fully functional Twitter clone running locally:
112+
1. At this point, you can run the following command to have a fully functional Twitter clone running locally:
114113

115-
```bash
116-
npm run dev:emulators
117-
```
114+
```bash
115+
npm run dev:emulators
116+
```
118117

119118
> **_Note_**: When you deploy Firestore indexes rules, it might take a few minutes to complete. So before the indexes are enabled, you will get an error when you fetch the data from Firestore.<br><br>You can check the status of your Firestore indexes with the link below, replace `your-project-id` with your project ID: https://console.firebase.google.com/u/0/project/your-project-id/firestore/indexes
120119

121120
Optional:
122121

123-
- If you want to get trending data from Twitter API, you need to create a Twitter developer account and get your API keys. Then add your API keys to `.env.development`. I hope Elon Musk doesn't make this API paid 😅.
124-
- If you want to make the user stats synced with the deleted tweets, you need to enable the Cloud Functions for Firebase. Then deploy the Cloud Functions.
122+
- If you want to get trending data from Twitter API, you need to create a Twitter developer account and get your API keys. Then add your API keys to `.env.development`. I hope Elon Musk doesn't make this API paid 😅.
123+
- If you want to make the user stats synced with the deleted blabs, you need to enable the Cloud Functions for Firebase. Then deploy the Cloud Functions.
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
import { functions, firestore, regionalFunctions } from './lib/utils';
2-
import { tweetConverter, bookmarkConverter } from './types';
3-
import type { Tweet } from './types';
1+
import { firestore, functions, regionalFunctions } from "./lib/utils";
2+
import { bookmarkConverter, tweetConverter } from "./types";
3+
import type { Tweet } from "./types";
44

55
export const normalizeStats = regionalFunctions.firestore
6-
.document('tweets/{tweetId}')
7-
.onDelete(async (snapshot): Promise<void> => {
8-
const tweetId = snapshot.id;
9-
const tweetData = snapshot.data() as Tweet;
6+
.document("tweets/{tweetId}")
7+
.onDelete(async (snapshot): Promise<void> => {
8+
const tweetId = snapshot.id;
9+
const tweetData = snapshot.data() as Tweet;
1010

11-
functions.logger.info(`Normalizing stats from tweet ${tweetId}`);
11+
functions.logger.info(`Normalizing stats from tweet ${tweetId}`);
1212

13-
const { userRetweets, userLikes } = tweetData;
13+
const { userRetweets, userLikes } = tweetData;
1414

15-
const usersStatsToDelete = new Set([...userRetweets, ...userLikes]);
15+
const usersStatsToDelete = new Set([...userRetweets, ...userLikes]);
1616

17-
const batch = firestore().batch();
17+
const batch = firestore().batch();
1818

19-
usersStatsToDelete.forEach((userId) => {
20-
functions.logger.info(`Deleting stats from ${userId}`);
19+
usersStatsToDelete.forEach((userId) => {
20+
functions.logger.info(`Deleting stats from ${userId}`);
2121

22-
const userStatsRef = firestore()
23-
.doc(`users/${userId}/stats/stats`)
24-
.withConverter(tweetConverter);
22+
const userStatsRef = firestore()
23+
.doc(`users/${userId}/stats/stats`)
24+
.withConverter(tweetConverter);
2525

26-
batch.update(userStatsRef, {
27-
tweets: firestore.FieldValue.arrayRemove(tweetId),
28-
likes: firestore.FieldValue.arrayRemove(tweetId)
29-
});
30-
});
26+
batch.update(userStatsRef, {
27+
tweets: firestore.FieldValue.arrayRemove(tweetId),
28+
likes: firestore.FieldValue.arrayRemove(tweetId),
29+
});
30+
});
3131

32-
const bookmarksQuery = firestore()
33-
.collectionGroup('bookmarks')
34-
.where('id', '==', tweetId)
35-
.withConverter(bookmarkConverter);
32+
const bookmarksQuery = firestore()
33+
.collectionGroup("bookmarks")
34+
.where("id", "==", tweetId)
35+
.withConverter(bookmarkConverter);
3636

37-
const docsSnap = await bookmarksQuery.get();
37+
const docsSnap = await bookmarksQuery.get();
3838

39-
functions.logger.info(`Deleting ${docsSnap.size} bookmarks`);
39+
functions.logger.info(`Deleting ${docsSnap.size} bookmarks`);
4040

41-
docsSnap.docs.forEach(({ id, ref }) => {
42-
functions.logger.info(`Deleting bookmark ${id}`);
43-
batch.delete(ref);
44-
});
41+
docsSnap.docs.forEach(({ id, ref }) => {
42+
functions.logger.info(`Deleting bookmark ${id}`);
43+
batch.delete(ref);
44+
});
4545

46-
await batch.commit();
46+
await batch.commit();
4747

48-
functions.logger.info(`Normalizing stats for tweet ${tweetId} is done`);
49-
});
48+
functions.logger.info(`Normalizing stats for blab ${tweetId} is done`);
49+
});

platforms/blabsy/functions/src/notify-email.ts

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
1-
import { createTransport } from 'nodemailer';
2-
import { firestore, functions, regionalFunctions } from './lib/utils';
3-
import { EMAIL_API, EMAIL_API_PASSWORD, TARGET_EMAIL } from './lib/env';
4-
import type { Tweet, User } from './types';
1+
import { createTransport } from "nodemailer";
2+
import { EMAIL_API, EMAIL_API_PASSWORD, TARGET_EMAIL } from "./lib/env";
3+
import { firestore, functions, regionalFunctions } from "./lib/utils";
4+
import type { Tweet, User } from "./types";
55

66
export const notifyEmail = regionalFunctions.firestore
7-
.document('tweets/{tweetId}')
8-
.onCreate(async (snapshot): Promise<void> => {
9-
functions.logger.info('Sending notification email.');
10-
11-
const { text, createdBy, images, parent } = snapshot.data() as Tweet;
12-
13-
const imagesLength = images?.length ?? 0;
14-
15-
const { name, username } = (
16-
await firestore().doc(`users/${createdBy}`).get()
17-
).data() as User;
18-
19-
const client = createTransport({
20-
service: 'Gmail',
21-
auth: {
22-
user: EMAIL_API.value(),
23-
pass: EMAIL_API_PASSWORD.value()
24-
}
25-
});
26-
27-
const tweetLink = `https://twitter-clone-ccrsxx.vercel.app/tweet/${snapshot.id}`;
28-
29-
const emailHeader = `New Tweet${
30-
parent ? ' reply' : ''
31-
} from ${name} (@${username})`;
32-
33-
const emailText = `${text ?? 'No text provided'}${
34-
images ? ` (${imagesLength} image${imagesLength > 1 ? 's' : ''})` : ''
35-
}\n\nLink to Tweet: ${tweetLink}\n\n- Firebase Function.`;
36-
37-
await client.sendMail({
38-
from: EMAIL_API.value(),
39-
to: TARGET_EMAIL.value(),
40-
subject: emailHeader,
41-
text: emailText
7+
.document("tweets/{tweetId}")
8+
.onCreate(async (snapshot): Promise<void> => {
9+
functions.logger.info("Sending notification email.");
10+
11+
const { text, createdBy, images, parent } = snapshot.data() as Tweet;
12+
13+
const imagesLength = images?.length ?? 0;
14+
15+
const { name, username } = (
16+
await firestore().doc(`users/${createdBy}`).get()
17+
).data() as User;
18+
19+
const client = createTransport({
20+
service: "Gmail",
21+
auth: {
22+
user: EMAIL_API.value(),
23+
pass: EMAIL_API_PASSWORD.value(),
24+
},
25+
});
26+
27+
const tweetLink = `https://twitter-clone-ccrsxx.vercel.app/tweet/${snapshot.id}`;
28+
29+
const emailHeader = `New Blab${
30+
parent ? " reply" : ""
31+
} from ${name} (@${username})`;
32+
33+
const emailText = `${text ?? "No text provided"}${
34+
images
35+
? ` (${imagesLength} image${imagesLength > 1 ? "s" : ""})`
36+
: ""
37+
}\n\nLink to Blab: ${tweetLink}\n\n- Firebase Function.`;
38+
39+
await client.sendMail({
40+
from: EMAIL_API.value(),
41+
to: TARGET_EMAIL.value(),
42+
subject: emailHeader,
43+
text: emailText,
44+
});
45+
46+
functions.logger.info("Notification email sent.");
4247
});
43-
44-
functions.logger.info('Notification email sent.');
45-
});

platforms/blabsy/project.inlang/cache/plugins/2sy648wh9sugi

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)