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

In-app Chat and notifications #32

Open
8 of 9 tasks
itsalb3rt opened this issue Aug 20, 2022 · 5 comments · Fixed by #35 or #55
Open
8 of 9 tasks

In-app Chat and notifications #32

itsalb3rt opened this issue Aug 20, 2022 · 5 comments · Fixed by #35 or #55
Assignees
Labels
enhancement New feature or request

Comments

@itsalb3rt
Copy link
Member

itsalb3rt commented Aug 20, 2022

Description

According to the Database, we need an In-app chat, the dynamic is simply, only the users can start a chat with the coworkers owners.

  • Need to create a chats page
  • Add Chat button in spaces
    • Added the space owner information in space details
  • Added bell to show notifications into the main header (desktop version)
    • Added read properties read_for_from_user and read_for_to_user to the chat entity
    • Add functionality to the notifications
    • Add notifications of schedules
  • Mobile
  • Remove the profile icon and use the avatar to redirect the user to the profile #54

Any others features are welcome.

@itsalb3rt itsalb3rt linked a pull request Aug 21, 2022 that will close this issue
@itsalb3rt itsalb3rt reopened this Aug 21, 2022
@itsalb3rt
Copy link
Member Author

@chakrihacker I have a request for you 😃 When you have time, please add properties to chat entity to make chat read by users read_for_from_user and read_for_to_user

@itsalb3rt
Copy link
Member Author

image

Added bell icon

@itsalb3rt itsalb3rt changed the title In-app Chat In-app Chat and notifications Dec 23, 2022
@itsalb3rt
Copy link
Member Author

itsalb3rt commented Dec 23, 2022

I added a table notification, function, and trigger on Supabase

Table

-- public.notification definition

-- Drop table

-- DROP TABLE public.notification;

CREATE TABLE public.notification (
	id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
	created_at timestamptz NULL DEFAULT now(),
	"read" bool NOT NULL DEFAULT false,
	"type" text NOT NULL,
	meta json NULL DEFAULT '{}'::json,
	to_user uuid NULL,
	CONSTRAINT notification_pkey PRIMARY KEY (id),
	CONSTRAINT notification_to_user_fkey FOREIGN KEY (to_user) REFERENCES auth.users(id)
);

Function

image

begin
  insert into public.notification(type, to_user, meta)
  values(
    'message',
    new.to_user,
    format('{"chat_id":"%s", "from_user":"%s"}', new.chat_id, (select from_user from public.chats where id = new.chat_id))::jsonb
  );

  return new;
end;

Trigger

image

@itsalb3rt
Copy link
Member Author

Created function and trigger to handle the notifications of the schedules

Function

image

begin
  insert into public.notification(type, to_user, meta)
  values(
    'schedule',
    (select space.userid 
from public.spaces space
inner join public.users on public.users.id = space.userid 
where space.id = new.space_id),
    format('{"space_id":"%s", "schedule_id":"%s"}', new.space_id, new.id)::jsonb
  );

  return new;
end;

Trigger

image

@itsalb3rt
Copy link
Member Author

The schedule notification uses a combination of schedule_id query parameter and in-code highlight, when the user clicked any notification, is redirected to the profile and the app automatic scroll down to the schedule and add a background color

image

@itsalb3rt itsalb3rt linked a pull request Dec 31, 2022 that will close this issue
@itsalb3rt itsalb3rt reopened this Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants