setting up a lot of models and such and now time to implement
This commit is contained in:
@@ -1,27 +1,143 @@
|
|||||||
import { v4 as uuid } from "uuid";
|
import { v4 as uuid } from "uuid";
|
||||||
import { Timestamp } from "firebase/firestore";
|
import { Timestamp } from "firebase/firestore";
|
||||||
|
|
||||||
|
export class CompleteConversation {
|
||||||
|
id: string; // conversation id
|
||||||
|
|
||||||
|
conversation: Conversation;
|
||||||
|
|
||||||
|
constructor(convo: Conversation) {
|
||||||
|
this.conversation = convo;
|
||||||
|
this.id = this.conversation.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
userMember?: ConversationMember;
|
||||||
|
|
||||||
|
members: ConversationMember[] = [] as ConversationMember[];
|
||||||
|
audioClips: AudioClip[] = [] as AudioClip[];
|
||||||
|
links: Link[] = [] as Link[];
|
||||||
|
}
|
||||||
export default class Conversation {
|
export default class Conversation {
|
||||||
id: string = uuid();
|
id: string = uuid();
|
||||||
|
|
||||||
type: ConversationType;
|
name: string; // engineering, general, arjun, jacob and rachel...
|
||||||
name?: string; // engineering, general, arjun, jacob and rachel...
|
|
||||||
|
|
||||||
createdDate: Timestamp = Timestamp.now();
|
createdDate: Timestamp = Timestamp.now();
|
||||||
createdByUserId: string;
|
createdByUserId: string;
|
||||||
|
|
||||||
constructor(
|
lastActivityDate?: Timestamp; // caching this for purpose of saving on listeners
|
||||||
_createdByUserId: string,
|
|
||||||
_type: ConversationType,
|
membersInLiveRoom: string[] = [] as string[]; // all members in a live call right now for this convo
|
||||||
_name?: string
|
|
||||||
) {
|
constructor(_createdByUserId: string, _name: string) {
|
||||||
this.name = _name;
|
this.name = _name;
|
||||||
this.createdByUserId = _createdByUserId;
|
this.createdByUserId = _createdByUserId;
|
||||||
this.type = _type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ConversationType {
|
export class ConversationMember {
|
||||||
personal = "personal", // no conversation name then
|
id: string; // will be the userId
|
||||||
group = "group", // must have conversation name
|
state: ConversationMemberState;
|
||||||
|
|
||||||
|
role: ConversationMemberRole;
|
||||||
|
|
||||||
|
createdDate: Timestamp = Timestamp.now();
|
||||||
|
lastUpdatedDate?: Timestamp;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
_userId: string,
|
||||||
|
_state: ConversationMemberState,
|
||||||
|
_role: ConversationMemberRole
|
||||||
|
) {
|
||||||
|
this.id = _userId;
|
||||||
|
this.state = _state;
|
||||||
|
this.role = _role;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ConversationMemberRole {
|
||||||
|
admin = "admin",
|
||||||
|
member = "member",
|
||||||
|
attendee = "attendee", // for future when only execs or higher ups want to talk in an async chat
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ConversationMemberState {
|
||||||
|
inbox = "inbox",
|
||||||
|
default = "default",
|
||||||
|
priority = "priority",
|
||||||
|
later = "later",
|
||||||
|
done = "done",
|
||||||
|
blocked = "removed", // blocked from the conversation now
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AudioClip {
|
||||||
|
id: string = uuid();
|
||||||
|
|
||||||
|
audioDataUrl: string;
|
||||||
|
|
||||||
|
senderUserId: string;
|
||||||
|
createdDate: Timestamp = Timestamp.now();
|
||||||
|
|
||||||
|
constructor(_audioDataurl: string, _senderUserId: string) {
|
||||||
|
this.audioDataUrl = _audioDataurl;
|
||||||
|
this.senderUserId = _senderUserId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Link {
|
||||||
|
id: string = uuid();
|
||||||
|
|
||||||
|
url: string;
|
||||||
|
name: string;
|
||||||
|
type: LinkType;
|
||||||
|
|
||||||
|
createdByUserId: string;
|
||||||
|
createdDate: Timestamp = Timestamp.now();
|
||||||
|
|
||||||
|
constructor(_name: string, _linkUrl: string, _senderUserId: string) {
|
||||||
|
this.createdByUserId = _senderUserId;
|
||||||
|
this.url = _linkUrl;
|
||||||
|
this.name = _name;
|
||||||
|
this.type = Link.getLinkType(_linkUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getLinkType(url: string): LinkType {
|
||||||
|
if (url.includes(LinkType.github)) {
|
||||||
|
return LinkType.github;
|
||||||
|
} else if (url.includes(LinkType.atlassian)) {
|
||||||
|
return LinkType.atlassian;
|
||||||
|
} else if (
|
||||||
|
url.includes(LinkType.googleDrive) ||
|
||||||
|
url.includes("docs.google")
|
||||||
|
) {
|
||||||
|
return LinkType.googleDrive;
|
||||||
|
} else if (
|
||||||
|
url.includes(".png") ||
|
||||||
|
url.includes(".jpg") ||
|
||||||
|
url.includes(".svg") ||
|
||||||
|
url.includes(".gif") ||
|
||||||
|
url.includes(LinkType.pastePics)
|
||||||
|
) {
|
||||||
|
return LinkType.image;
|
||||||
|
} else if (url.includes(LinkType.pdf)) {
|
||||||
|
return LinkType.pdf;
|
||||||
|
} else if (url.includes(LinkType.codePile)) {
|
||||||
|
return LinkType.codePile;
|
||||||
|
} else {
|
||||||
|
return LinkType.default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum LinkType {
|
||||||
|
default = "default",
|
||||||
|
github = "github",
|
||||||
|
atlassian = "atlassian",
|
||||||
|
googleDrive = "drive.google",
|
||||||
|
onedrive = "onedrive",
|
||||||
|
image = "image",
|
||||||
|
pdf = "pdf",
|
||||||
|
codePile = "codepile",
|
||||||
|
pastePics = "paste.pics",
|
||||||
|
googleMeet = "googleMeet",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import { v4 as uuid } from "uuid";
|
|
||||||
import { Timestamp } from "firebase/firestore";
|
|
||||||
|
|
||||||
export default class UserConversation {
|
|
||||||
id: string = uuid();
|
|
||||||
|
|
||||||
userId: string;
|
|
||||||
conversationId: string;
|
|
||||||
state: UserConversationState;
|
|
||||||
|
|
||||||
createdDate: Timestamp = Timestamp.now();
|
|
||||||
lastUpdatedDate?: Timestamp;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
_userId: string,
|
|
||||||
_conversationId: string,
|
|
||||||
_state: UserConversationState
|
|
||||||
) {
|
|
||||||
this.userId = _userId;
|
|
||||||
this.conversationId = _conversationId;
|
|
||||||
this.state = _state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum UserConversationState {
|
|
||||||
inbox = "inbox",
|
|
||||||
default = "default",
|
|
||||||
priority = "priority",
|
|
||||||
later = "later",
|
|
||||||
done = "done",
|
|
||||||
// blocked = "blocked"
|
|
||||||
}
|
|
||||||
@@ -36,8 +36,8 @@ export default function Conversations() {
|
|||||||
|
|
||||||
{/* row of live room cards */}
|
{/* row of live room cards */}
|
||||||
<span className="flex flex-row flex-wrap">
|
<span className="flex flex-row flex-wrap">
|
||||||
{/* engineering rooms */}
|
{/* engineering liveroom */}
|
||||||
<span className="group relative flex flex-row items-center bg-slate-50 rounded-lg border p-5">
|
<span className="group relative flex flex-row items-center bg-slate-50 rounded-lg border p-5 animate-pulse">
|
||||||
<Avatar.Group
|
<Avatar.Group
|
||||||
maxCount={3}
|
maxCount={3}
|
||||||
size={{ xs: 1000 }}
|
size={{ xs: 1000 }}
|
||||||
|
|||||||
Reference in New Issue
Block a user