Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving UX: Intuitive User Posts and User Events Display and Dynamic Feed Functionality #2321

Merged
merged 16 commits into from
Jan 21, 2024
Merged
10 changes: 6 additions & 4 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@
"Explore Events": "Veranstaltungen erkunden",
"Filters": "Filter",
"Filter by Date": "Filtern nach Datum",
"All Events": "Alle Veranstaltungen",
"Show all events": "Alle Veranstaltungen anzeigen",
"Show all events created by you": "Alle Veranstaltungen anzeigen, die von Ihnen erstellt wurden",
"Registered Events": "Registrierte Veranstaltungen",
"Show all events you have registered": "Alle Veranstaltungen anzeigen, für die Sie sich registriert haben",
"Show events for all": "Alle Veranstaltungen anzeigen",
"Show invite-only events": "Nur Einladungsveranstaltungen anzeigen",

"Add Date": "Datum hinzufügen",
"Event": "Vorfall",
"My Events": "Meine Veranstaltungen",
Expand Down Expand Up @@ -234,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "Dies ist der Tab 'Beitrag erstellen', hier können Sie der aktuell ausgewählten Organisation einen Beitrag hinzufügen",
"This is the Chat tab here you can see all your messages of the current selected organization": "Dies ist der Chat-Tab, hier können Sie alle Ihre Nachrichten der aktuell ausgewählten Organisation sehen",
"To help your organization grow you can support them financially from here": "Um Ihre Organisation zu unterstützen, können Sie sie finanziell von hier aus unterstützen.",
"You are all set to go let's get you in": "Sie sind bereit zu gehen, lassen Sie uns Ihnen helfen."
"You have no event in this organization": "Sie haben keine Veranstaltung in dieser Organisation",
"Create your first event": "Erstellen Sie Ihr erstes Event",
"You are all set to go let's get you in": "Sie sind bereit zu gehen, lassen Sie uns Ihnen helfen.",
"There are no posts in this organization": "Es gibt keine Beiträge in dieser Organisation",
"Create your first post": "Erstellen Sie Ihren ersten Beitrag",
"You have no post in this organization": "Sie haben keinen Beitrag in dieser Organisation"
}
9 changes: 6 additions & 3 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@
"Explore Events": "Explore Events",
"Filters": "Filters",
"Filter by Date": "Filter by Date",
"All Events": "All Events",
"Show all events": "Show all events",
"Show all events created by you": "Show all events created by you",
"Registered Events": "Registered Events",
"Show all events you have registered": "Show all events you have registered",
"Show events for all": "Show events for all",
"Show invite-only events": "Show invite-only events",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "This is the Create post tab here you can add post to the current selected organization.",
"This is the Chat tab here you can see all your messages of the current selected organization": "This is the Chat tab here you can see all your messages of the current selected organization.",
"To help your organization grow you can support them financially from here": "To help your organization grow you can support them financially from here.",
"You are all set to go let's get you in": "You are all set to go let's get you in."
"You are all set to go let's get you in": "You are all set to go let's get you in.",
"You have no event in this organization": "You have no event in this organization",
"Create your first event": "Create your first event",
"There are no posts in this organization": "There are no posts in this organization",
"Create your first post": "Create your first post",
"You have no post in this organization": "You have no post in this organization"
}
9 changes: 6 additions & 3 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@
"Explore Events": "Explorar eventos",
"Filters": "Filtros",
"Filter by Date": "Filtrar por fecha",
"All Events": "Todos los eventos",
"Show all events": "Mostrar todos los eventos",
"Show all events created by you": "Mostrar todos los eventos creados por ti",
"Registered Events": "Eventos registrados",
"Show all events you have registered": "Mostrar todos los eventos en los que te has registrado",
"Show events for all": "Mostrar eventos para todos",
"Show invite-only events": "Mostrar eventos solo por invitación",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "Esta es la pestaña de Crear publicación; aquí puedes agregar una publicación a la organización actualmente seleccionada",
"This is the Chat tab here you can see all your messages of the current selected organization": "Esta es la pestaña de Chat; aquí puedes ver todos tus mensajes de la organización actualmente seleccionada",
"To help your organization grow you can support them financially from here": "Para ayudar a que tu organización crezca, puedes apoyarla financieramente desde aquí",
"You are all set to go let's get you in": "Estás listo para ir, vamos a empezar"
"You are all set to go let's get you in": "Estás listo para ir, vamos a empezar",
"You have no event in this organization": "No tienes ningún evento en esta organización",
"Create your first event": "Crea tu primer evento",
"There are no posts in this organization": "No hay publicaciones en esta organización",
"Create your first post": "Crea tu primera publicación",
"You have no post in this organization": "No tienes ninguna publicación en esta organización"
}
9 changes: 6 additions & 3 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@
"Explore Events": "Explorer les événements",
"Filters": "Filtres",
"Filter by Date": "Filtrer par date",
"All Events": "Tous les événements",
"Show all events": "Afficher tous les événements",
"Show all events created by you": "Afficher tous les événements créés par vous",
"Registered Events": "Événements enregistrés",
"Show all events you have registered": "Afficher tous les événements auxquels vous êtes inscrit",
"Show events for all": "Afficher les événements pour tous",
"Show invite-only events": "Afficher les événements sur invitation uniquement",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "Ceci est l'onglet Créer une publication, ici vous pouvez ajouter une publication à l'organisation actuellement sélectionnée",
"This is the Chat tab here you can see all your messages of the current selected organization": "Ceci est l'onglet Chat, ici vous pouvez voir tous vos messages de l'organisation actuellement sélectionnée",
"To help your organization grow you can support them financially from here": "Pour aider votre organisation à se développer, vous pouvez les soutenir financièrement depuis ici.",
"You are all set to go let's get you in": "Vous êtes prêt à partir, laissez-nous vous aider."
"You are all set to go let's get you in": "Vous êtes prêt à partir, laissez-nous vous aider.",
"You have no event in this organization": "Vous n'avez aucun événement dans cette organisation",
"Create your first event": "Créez votre premier événement",
"There are no posts in this organization": "Il n'y a aucun article dans cette organisation",
"Create your first post": "Créez votre premier article",
"You have no post in this organization": "Vous n'avez aucun article dans cette organisation"
}
9 changes: 6 additions & 3 deletions lang/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@
"Explore Events": "घटनाओं का अन्वेषण करें",
"Filters": "फ़िल्टर",
"Filter by Date": "तारीख़ से फ़िल्टर करें",
"All Events": "सभी घटनाएँ",
"Show all events": "सभी घटनाएँ दिखाएं",
"Show all events created by you": "आपके द्वारा बनाई गई सभी घटनाएँ दिखाएं",
"Registered Events": "रजिस्टर की गई घटनाएँ",
"Show all events you have registered": "आपने जिन घटनाओं में पंजीकृत हुए हैं, उन सभी घटनाएँ दिखाएं",
"Show events for all": "सभी के लिए घटनाएँ दिखाएं",
"Show invite-only events": "आमंत्रित लोगों के लिए घटनाएँ दिखाएं",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "यह यहाँ से तैयार करें पोस्ट टैब है जहाँ आप वर्तमान चयनित संगठन में पोस्ट जोड़ सकते हैं।",
"This is the Chat tab here you can see all your messages of the current selected organization": "यहाँ चैट टैब है जहाँ आप वर्तमान चयनित संगठन के सभी संदेश देख सकते हैं।",
"To help your organization grow you can support them financially from here": "अपने संगठन को बढ़ावा देने के लिए आप उन्हें यहाँ से वित्तपोषण दे सकते हैं।",
"You are all set to go let's get you in": "आप तैयार हैं जाने के लिए, चलो आपको एंटर करते हैं।"
"You are all set to go let's get you in": "आप तैयार हैं जाने के लिए, चलो आपको एंटर करते हैं।",
"You have no event in this organization": "इस संगठन में आपका कोई इवेंट नहीं है",
"Create your first event": "अपना पहला इवेंट बनाएं",
"There are no posts in this organization": "इस संगठन में कोई पोस्ट नहीं है",
"Create your first post": "अपनी पहली पोस्ट बनाएं",
"You have no post in this organization": "इस संगठन में आपका कोई पोस्ट नहीं है"
}
9 changes: 6 additions & 3 deletions lang/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@
"Explore Events": "イベントを探索する",
"Filters": "フィルター",
"Filter by Date": "日付で絞り込む",
"All Events": "すべてのイベント",
"Show all events": "すべてのイベントを表示",
"Show all events created by you": "あなたが作成したすべてのイベントを表示",
"Registered Events": "登録済みイベント",
"Show all events you have registered": "あなたが登録したすべてのイベントを表示",
"Show events for all": "すべてのイベントを表示",
"Show invite-only events": "招待限定イベントを表示",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "これは投稿を作成するタブです。ここでは、現在選択されている組織に投稿を追加できます。",
"This is the Chat tab here you can see all your messages of the current selected organization": "これはチャットタブです。ここでは、現在選択されている組織のすべてのメッセージを見ることができます。",
"To help your organization grow you can support them financially from here": "組織の成長をサポートするためには、ここから経済的にサポートできます。",
"You are all set to go let's get you in": "準備が整いました。さあ、始めましょう。"
"You are all set to go let's get you in": "準備が整いました。さあ、始めましょう。",
"You have no event in this organization": "この組織にはイベントがありません",
"Create your first event": "最初のイベントを作成してください",
"There are no posts in this organization": "この組織には投稿がありません",
"Create your first post": "最初の投稿を作成してください",
"You have no post in this organization": "この組織には投稿がありません"
}
9 changes: 6 additions & 3 deletions lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@
"Explore Events": "Explorar eventos",
"Filters": "Filtros",
"Filter by Date": "Filtrar por data",
"All Events": "Todos os eventos",
"Show all events": "Mostrar todos os eventos",
"Show all events created by you": "Mostrar todos os eventos criados por você",
"Registered Events": "Eventos registrados",
"Show all events you have registered": "Mostrar todos os eventos em que você se registrou",
"Show events for all": "Mostrar eventos para todos",
"Show invite-only events": "Mostrar apenas eventos com convite",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "Esta é a aba de Criar postagem; aqui você pode adicionar uma postagem à organização atualmente selecionada",
"This is the Chat tab here you can see all your messages of the current selected organization": "Esta é a aba de Chat; aqui você pode ver todas as suas mensagens da organização atualmente selecionada",
"To help your organization grow you can support them financially from here": "Para ajudar sua organização a crescer, você pode apoiá-la financeiramente a partir daqui",
"You are all set to go let's get you in": "Você está pronto para ir; vamos começar"
"You are all set to go let's get you in": "Você está pronto para ir; vamos começar",
"You have no event in this organization": "Você não tem nenhum evento nesta organização",
"Create your first event": "Crie seu primeiro evento",
"There are no posts in this organization": "Não há posts nesta organização",
"Create your first post": "Crie sua primeira postagem",
"You have no post in this organization": "Você não tem nenhuma postagem nesta organização"
}
9 changes: 6 additions & 3 deletions lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@
"Explore Events": "探索事件",
"Filters": "过滤器",
"Filter by Date": "按日期过滤",
"All Events": "所有活动",
"Show all events": "显示所有活动",
"My Events": "我的活动",
"Show all events created by you": "显示由您创建的所有活动",
"Registered Events": "已注册活动",
"Show all events you have registered": "显示您已注册的所有活动",
"Public Events": "公共活动",
"Show events for all": "显示所有人的活动",
Expand Down Expand Up @@ -233,5 +231,10 @@
"This is the Create post tab here you can add post to the current selected organization": "这是创建帖子选项卡,您可以在此处向当前选择的组织添加帖子。",
"This is the Chat tab here you can see all your messages of the current selected organization": "这是聊天选项卡,您可以在此处查看当前选择组织的所有消息。",
"To help your organization grow you can support them financially from here": "要帮助您的组织成长,您可以从这里提供财务支持。",
"You are all set to go let's get you in": "您已经准备好了,让我们开始吧。"
"You are all set to go let's get you in": "您已经准备好了,让我们开始吧。",
"You have no event in this organization": "您在此组织中没有活动",
"Create your first event": "创建您的第一个活动",
"There are no posts in this organization": "此组织中没有帖子",
"Create your first post": "创建您的第一篇帖子",
"You have no post in this organization": "您在此组织中没有帖子"
}
99 changes: 84 additions & 15 deletions lib/services/post_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,39 @@ class PostService {
// ignore: prefer_final_fields
List<Post> _posts = [];

//Getters
/// Getter for Stream of posts.
Stream<List<Post>> get postStream => _postStream;

/// Getter for Stream of update in any post.
Stream<Post> get updatedPostStream => _updatedPostStream;

//Setters
///This method sets up a stream that constantly listens to change in current org.
///
/// **params**:
/// None
///
/// **returns**:
/// None
void setOrgStreamSubscription() {
_userConfig.currentOrgInfoStream.listen((updatedOrganization) {
if (updatedOrganization != _currentOrg) {
print("org changes from post service");
_renderedPostID.clear();
_currentOrg = updatedOrganization;
getPosts();
}
});
}

/// Retrieves all posts of the organization.
/// Method used to fetch all posts of the current organisation.
///
/// **params**:
/// None
///
/// This method queries the organization ID from `_currentOrg` and fetches
/// posts using a GraphQL query. The retrieved posts are added to the internal
/// post stream
/// **returns**:
/// * `Future<void>`: returns future void
Dante291 marked this conversation as resolved.
Show resolved Hide resolved
Future<void> getPosts() async {
await _dbFunctions.refreshAccessToken(userConfig.currentUser.refreshToken!);
_dbFunctions.init();
// variables
final String currentOrgID = _currentOrg.id!;
final String query = PostQueries().getPostsById(currentOrgID);
Expand All @@ -76,7 +87,6 @@ class PostService {

// ignore:avoid_dynamic_calls
final List postsJson = result.data!['postsByOrganization'] as List;

postsJson.forEach((postJson) {
final Post post = Post.fromJson(postJson as Map<String, dynamic>);
if (!_renderedPostID.contains(post.sId)) {
Expand All @@ -87,10 +97,43 @@ class PostService {
_postStreamController.add(_posts);
}

/// This function is used to add Like to the Post.
/// Method to refresh feed of current selected organisation.
///
/// **params**:
/// None
///
/// params:
/// * [postId] : id of the post where like need to be added.
/// **returns**:
/// * `Future<void>`: returns future void
Future<void> refreshFeed() async {
_posts.clear();
_renderedPostID.clear();
await getPosts();
}

///Method to add newly created post at the very top of the feed.
///
/// **params**:
/// * `newPost`: new post made by user to add in feed
///
/// **returns**:
/// None
void addNewpost(Post newPost) {
if (!_posts.contains(newPost)) {
_posts.insert(0, newPost);
}
_postStreamController.add(_posts);
}

///Method to add like on a Post.
///
/// This method basically update likedBy list of a Post
/// in database.
///
/// **params**:
/// * `postID`: ID of the post to add like in database
///
/// **returns**:
/// * `Future<void>`: define_the_return
Future<void> addLike(String postID) async {
_localAddLike(postID);
final String mutation = PostQueries().addLike();
Expand All @@ -102,6 +145,13 @@ class PostService {
return result;
}

/// Locally add like on a Post and updates it using updated Post Stream.
///
/// **params**:
/// * `postID`: ID of the post to add like locally
///
/// **returns**:
/// None
void _localAddLike(String postID) {
_posts.forEach((post) {
if (post.sId == postID) {
Expand All @@ -111,10 +161,16 @@ class PostService {
});
}

/// This function is used to remove like from the Post.
/// Method to remove like in a Post.
///
/// params:
/// * [postId] : id of the post where like need to be removed.
/// This method basically update likedBy list of a Post
/// and removes the like of a user in database.
///
/// **params**:
/// * `postID`: ID of the post to remove like in database.
///
/// **returns**:
/// * `Future<void>`: nothing
Future<void> removeLike(String postID) async {
_removeLocal(postID);
final String mutation = PostQueries().removeLike();
Expand All @@ -124,6 +180,13 @@ class PostService {
return result;
}

/// Locally removes the like of a user and update the Post UI.
///
/// **params**:
/// * `postID`: ID of the post to remove like locally
///
/// **returns**:
/// None
void _removeLocal(String postID) {
_posts.forEach((post) {
if (post.sId == postID) {
Expand All @@ -135,7 +198,13 @@ class PostService {
});
}

// Functions related to comments
///Method to add comment of a user and update comments using updated Post Stream.
///
/// **params**:
/// * `postID`: ID of the post to add comment locally
///
/// **returns**:
/// None
void addCommentLocally(String postID) {
for (int i = 0; i < _posts.length; i++) {
if (_posts[i].sId == postID) {
Expand Down
Loading
Loading