Skip to content

Commit

Permalink
Merge pull request #256 from gagan-suie/dev
Browse files Browse the repository at this point in the history
Feat: completed contact page and updated chat sockets
  • Loading branch information
gagansuie authored Feb 8, 2023
2 parents df7ce87 + 8223b4b commit ed93b51
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 273 deletions.
28 changes: 15 additions & 13 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { redirect, type HandleFetch, type Handle } from '@sveltejs/kit'
import { get as getWritableVal } from 'svelte/store'
import {
isMaintenanceModeEnabled,
isFeatureVideoResponsesEnabled,
isFeatureGroupChatEnabled,
isFeatureMintPageEnabled,
isFeaturePremiumPageEnabled
is_maintenance_mode_enabled,
is_feature_video_responses_enabled,
is_feature_group_chat_enabled,
is_feature_mint_page_enabled,
is_feature_premium_page_enabled
} from '$lib/stores/remoteConfigStore'
import { Authenticate } from '$lib/authentication/authentication'
import { env } from '$env/dynamic/public'
Expand All @@ -20,22 +20,24 @@ export const handle: Handle = async ({ event, resolve }) => {
let user: any = event.locals.user?.user || '',
isBanned = false
const role = getWritableVal(user_role)

let maintenance_mode
const remoteConfigs = await get('remote-configs', { userId, token })
if (remoteConfigs && remoteConfigs.length) {
remoteConfigs.map((config: { flagKey: string; flagValue: boolean }) => {
if (config.flagKey === 'maintenance-mode') isMaintenanceModeEnabled.set(config.flagValue)
if (config.flagKey === 'maintenance-mode') {
is_maintenance_mode_enabled.set(config.flagValue)
maintenance_mode = config.flagValue
}
if (config.flagKey === 'feature-video-responses')
isFeatureVideoResponsesEnabled.set(config.flagValue)
if (config.flagKey === 'feature-group-chat') isFeatureGroupChatEnabled.set(config.flagValue)
if (config.flagKey === 'feature-mint-page') isFeatureMintPageEnabled.set(config.flagValue)
is_feature_video_responses_enabled.set(config.flagValue)
if (config.flagKey === 'feature-group-chat')
is_feature_group_chat_enabled.set(config.flagValue)
if (config.flagKey === 'feature-mint-page') is_feature_mint_page_enabled.set(config.flagValue)
if (config.flagKey === 'feature-premium-page')
isFeaturePremiumPageEnabled.set(config.flagValue)
is_feature_premium_page_enabled.set(config.flagValue)
})
}

const maintenance_mode = getWritableVal(isMaintenanceModeEnabled) || false

if (token && userId) {
if (!user) {
const response = await get('auth/me', { userId, token })
Expand Down
12 changes: 12 additions & 0 deletions src/lib/assets/icons/contact/IconEmail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/lib/assets/icons/contact/IconSocialDiscordInverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 7 additions & 9 deletions src/lib/components/Browse/CreateChannelDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
const addChannel = async () => {
const channel = await post('/channel', newChannel)
await put(`/users/host-channels?hostChannelId=${channel._id}`)
//TODO: set currentChannel
goto(`/channel/${channel._id}`)
}
</script>
Expand All @@ -84,15 +83,15 @@
Create a new channel
</p>
<div class="flex flex-col p-3">
<p class="text-xs">
When you create a channel, you may allow viewer's to observe your desktop as you host
your channel
<p class="text-s">
When you create a channel, you may share your screen, webcam, and chat with the
community
</p>
<p class="text-lg font-semibold mt-10">
<p class="text-lg font-semibold mt-10">
Please hide all sensitive data before going live.
</p>

<div class="flex flex-row justify-center w-full">
<!-- <div class="flex flex-row justify-center w-full">
<div class="card w-40 shadow-xl">
<div class="card-body items-center max-h-40 {showThumbnail ? '!p-3' : ''}">
{#if showThumbnail}
Expand All @@ -108,8 +107,7 @@
bind:this={fileuploader}
on:change={fileupload}
type="file"
class="file-input file-input-bordered file-input-primary w-full mt-5" />

class="file-input file-input-bordered file-input-primary w-full mt-5" /> -->
<input
bind:value={newChannel.title}
type="text"
Expand All @@ -123,7 +121,7 @@
name="description"
required
class="textarea textarea-primary mt-5 text-base w-full h-28" />
<p class="text-base text-gray-500 mt-5">Suggested Tags</p>
<p class="text-base text-gray-500 mt-5 mb-2">Suggested Tags</p>
<div class="flex flex-wrap">
{#if $tags && $tags.length > 0}
{#each $tags as tag}
Expand Down
File renamed without changes.
71 changes: 6 additions & 65 deletions src/lib/components/Chat/ChatDrawer.svelte
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
<script lang="ts">
import { onMount } from 'svelte'
import ChatInput from '$lib/components/Chat/ChatInput.svelte'
import ChatMessage from '$lib/components/Chat/ChatMessage.svelte'
export let showDrawer: boolean
export let channel: any = undefined
let username = 'Gagan',
message =
'Hello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello World',
role = 'Host'
let sender = { username, message, role }
let youSender = { username: 'Singh', message: 'hewrewrwe ehe', role: 'You' }
let modSender = { username: 'Simmi', message: 'hewe rew rwe rwhe', role: 'Mod' }
let otherSender = { username: 'Arjan', message: 'he wer wer wehe', role: 'Rando' }
onMount(async () => {
// if (!$tags.length) {
// await getTags()
// }
})
const sendMessage = async () => {
// await createChannel(newChannel)
}
export let showDrawer: boolean,
channel: any = undefined,
chatHistory: any = []
</script>

<div class="drawer drawer-end absolute w-full z-20 top-0 right-0">
Expand All @@ -35,51 +16,11 @@
<p class="p-3 text-xl mb-5 pb-2 border-purple-500 font-semibold border-b-2">
{channel.title || 'Chat'}
</p>

<div class="flex flex-col-reverse p-3 grow h-80 overflow-y-auto">
<ChatMessage bind:sender />
<ChatMessage bind:sender />
<ChatMessage bind:sender />
<ChatMessage bind:sender={youSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={modSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={otherSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={youSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={modSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={otherSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender />
<ChatMessage bind:sender />
<ChatMessage bind:sender={youSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={modSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={otherSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={youSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={modSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={otherSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender />
<ChatMessage bind:sender />
<ChatMessage bind:sender={youSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={modSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={otherSender} />
<ChatMessage bind:sender={youSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={modSender} />
<ChatMessage bind:sender />
<ChatMessage bind:sender={otherSender} />
{#each chatHistory as sender}
<ChatMessage bind:sender />
{/each}
</div>

<div class="flex flex-row mt-auto p-3 w-full">
<ChatInput />
</div>
Expand Down
21 changes: 12 additions & 9 deletions src/lib/components/Chat/ChatInput.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<script lang="ts">
import IconChatAttachment from '$lib/assets/icons/chat/IconChatAttachment.svelte'
import IconChatEmoji from '$lib/assets/icons/chat/IconChatEmoji.svelte'
import IconChatGif from '$lib/assets/icons/chat/IconChatGif.svelte'
import IconChatCode from '$lib/assets/icons/chat/IconChatCode.svelte'
// import IconChatAttachment from '$lib/assets/icons/chat/IconChatAttachment.svelte'
// import IconChatEmoji from '$lib/assets/icons/chat/IconChatEmoji.svelte'
// import IconChatGif from '$lib/assets/icons/chat/IconChatGif.svelte'
// import IconChatCode from '$lib/assets/icons/chat/IconChatCode.svelte'
import IconChatSendMessage from '$lib/assets/icons/chat/IconChatSendMessage.svelte'
const sendMessage = async () => {
// await createChannel(newChannel)
}
</script>

<form class="rounded-lg bg-base-100 p-2 w-96">
<label for="chat" class="sr-only">Your message</label>
<button
<!-- <button
type="button"
class="inline-flex justify-center p-2 text-gray-500 rounded-lg cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600">
<IconChatAttachment />
Expand All @@ -31,13 +34,13 @@
class="p-2 text-gray-500 rounded-lg cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600">
<IconChatCode />
<span class="sr-only">Add code snippet</span>
</button>
</button> -->
<div class="flex items-center py-2 rounded-lg">
<textarea
id="chat"
rows="1"
class="focus:h-32 block mx-2 p-2.5 w-full text-sm textarea textarea-bordered textarea-secondary"
placeholder="Your message..." />
class="block mx-2 p-2.5 w-full text-sm textarea textarea-bordered textarea-secondary"
placeholder="Your message..." /><!--focus:h-32 -->
<button
type="submit"
class="inline-flex justify-center p-2 text-secondary rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:hover:text-white dark:hover:bg-gray-600">
Expand Down
48 changes: 23 additions & 25 deletions src/lib/components/MainDrawer/MainDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import { env } from '$env/dynamic/public'
import { current_user, user_role } from '$lib/stores/authStore'
import {
isMaintenanceModeEnabled
// isFeatureMintPageEnabled,
// isFeaturePremiumPageEnabled,
// isFeatureGroupChatEnabled,
// isFeatureVideoResponsesEnabled
is_maintenance_mode_enabled
// is_feature_mint_page_enabled,
// is_feature_premium_page_enabled,
// is_feature_group_chat_enabled,
// is_feature_video_responses_enabled
} from '$lib/stores/remoteConfigStore'
import IconMageText from '$lib/assets/icons/IconMageText.svg'
import IconMageTextDark from '$lib/assets/icons/IconMageTextDark.svg'
Expand Down Expand Up @@ -180,26 +180,24 @@
Settings</a>
</li>
{/if}
{#if !$isMaintenanceModeEnabled}
{#if $current_user}
<li>
<button on:click={logout}>
<IconDrawerLogOut />
Log Out</button>
</li>
{:else}
<li>
<button
on:click={() => {
$is_login_modal_open = true
if (nav_drawer.checked) {
nav_drawer.checked = false
}
}}>
<IconDrawerLogOut />
Log In</button>
</li>
{/if}
{#if $current_user}
<li>
<button on:click={logout}>
<IconDrawerLogOut />
Log Out</button>
</li>
{:else}
<li>
<button
on:click={() => {
$is_login_modal_open = true
if (nav_drawer.checked) {
nav_drawer.checked = false
}
}}>
<IconDrawerLogOut />
Log In</button>
</li>
{/if}
</ul>

Expand Down
54 changes: 26 additions & 28 deletions src/lib/components/MainDrawer/SmallDrawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import { env } from '$env/dynamic/public'
import { current_user, user_role } from '$lib/stores/authStore'
import {
isMaintenanceModeEnabled,
isFeatureMintPageEnabled,
isFeaturePremiumPageEnabled,
isFeatureGroupChatEnabled,
isFeatureVideoResponsesEnabled
is_maintenance_mode_enabled,
is_feature_mint_page_enabled,
is_feature_premium_page_enabled,
is_feature_group_chat_enabled,
is_feature_video_responses_enabled
} from '$lib/stores/remoteConfigStore'
import IconMageLogo from '$lib/assets/icons/IconMageLogo.svg'
import IconMageLogoDark from '$lib/assets/icons/IconMageLogoDark.svg'
Expand Down Expand Up @@ -108,7 +108,7 @@
</a>
</li>
{/if} -->
{#if $current_user && $isFeatureVideoResponsesEnabled}
{#if $current_user && $is_feature_video_responses_enabled}
<li>
<a href="/videos">
<IconDrawerVideos />
Expand All @@ -118,7 +118,7 @@
<a href="/creator-space"> <IconDrawerCreatorSpace /></a>
</li>
{/if}
{#if $current_user && $isFeatureMintPageEnabled}
{#if $current_user && $is_feature_mint_page_enabled}
<li>
<a
href="https://mint.codecrow.io"
Expand All @@ -129,7 +129,7 @@
</a>
</li>
{/if}
{#if $current_user && $isFeaturePremiumPageEnabled}
{#if $current_user && $is_feature_premium_page_enabled}
<li>
<a href="/premium" class="text-pink-500">
<IconDrawerPremium />
Expand Down Expand Up @@ -157,26 +157,24 @@
</a>
</li>
{/if}
{#if !$isMaintenanceModeEnabled}
{#if $current_user}
<li>
<button on:click={logout}>
<IconDrawerLogOut />
</button>
</li>
{:else}
<li>
<button
on:click={() => {
$is_login_modal_open = true
if (nav_drawer.checked) {
nav_drawer.checked = false
}
}}>
<IconDrawerLogOut />
</button>
</li>
{/if}
{#if $current_user}
<li>
<button on:click={logout}>
<IconDrawerLogOut />
</button>
</li>
{:else}
<li>
<button
on:click={() => {
$is_login_modal_open = true
if (nav_drawer.checked) {
nav_drawer.checked = false
}
}}>
<IconDrawerLogOut />
</button>
</li>
{/if}
</ul>
</div>
Expand Down
Loading

0 comments on commit ed93b51

Please sign in to comment.