Skip to content

Commit

Permalink
Merge pull request #119 from gagan-suie/dev
Browse files Browse the repository at this point in the history
Fix: unaccessible stores
  • Loading branch information
gagansuie authored Jan 15, 2023
2 parents 065cd84 + 6a44f5a commit f093cee
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 58 deletions.
33 changes: 16 additions & 17 deletions src/lib/stores/chatStore.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { writable, type Writable } from 'svelte/store'
import { socketStore } from '$lib/stores/socketStore'
import { env } from '$env/dynamic/public'
import { userStore } from '$lib/stores/userStore'
import { authStore } from '$lib/stores/authStore'
import { channelStore } from '$lib/stores/channelStore'
// import { currentUser } from './userStore'
// import { currentChannel } from './channelStore'

class ChatStore {
public lastMessageSendDate: Date = new Date()
Expand Down Expand Up @@ -280,7 +279,7 @@ class ChatStore {
}

public async activateChatTab({ chat }: { chat: any }) {
const user = authStore.currentUser
// const user = authStore.currentUser
if (this.checkAlreadyExist(chat)) return
//TODO: get writable activeTabs
// this.activeTabs.push(chat)
Expand All @@ -289,7 +288,7 @@ class ChatStore {
}

public async activateGroupTab({ group }: { group: any }) {
const user = authStore.currentUser
// const user = authStore.currentUser
if (this.checkAlreadyExist(group)) return
//TODO: get writable activeTabs
// socketStore.emitChannelSubscribeByUser(group.channelId, user._id)
Expand All @@ -309,8 +308,8 @@ class ChatStore {
}

public async incomingMessageActivateChatTab(data: any) {
const user = authStore.currentUser
const otherUser = userStore.getUserById(data.source1)
// const user = authStore.currentUser
// const otherUser = userStore.getUserById(data.source1)
const chat = null
//TODO: get writable currentUser
// const existingChat = await this.getChat({
Expand Down Expand Up @@ -382,16 +381,16 @@ class ChatStore {
}

public async commitDeleteMessage({ oneVone, message }: { oneVone: boolean, message: any }) {
let chan = null
if (oneVone || !channelStore.currentChannel) {
chan = { _id: message.channelId } // if friend chat
} else {
chan = channelStore.currentChannel // if channel chat
}
if (chan) {
//TODO: get writable channel id
// this.deleteMessage({ message, channelId: chan._id })
}
// let chan = null
// if (oneVone || !channelStore.currentChannel) {
// chan = { _id: message.channelId } // if friend chat
// } else {
// chan = channelStore.currentChannel // if channel chat
// }
// if (chan) {
// //TODO: get writable channel id
// this.deleteMessage({ message, channelId: chan._id })
// }
}
}

Expand Down
44 changes: 22 additions & 22 deletions src/lib/stores/streamStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writable, type Writable } from 'svelte/store'
import { env } from '$env/dynamic/public'
import { channelStore } from '$lib/stores/channelStore'
// import { currentChannel } from '$lib/stores/channelStore'
import { socketStore } from '$lib/stores/socketStore'

class StreamStore {
Expand Down Expand Up @@ -522,20 +522,20 @@ class StreamStore {
}

async leaveRoom() {
if (channelStore.currentChannel) {
this.disconnected()
this.stopObsStream()
this.stopScreenStream()
this.stopWebcamStream()
this.stopAudioStream()
//TODO: fix subscribring to room members writeable
// if (this.roomMembersSubscription) {
// this.roomMembersSubscription.unsubscribe()
// }
// if (this.userActionsSubscription) {
// this.userActionsSubscription.unsubscribe()
// }
}
// if (channelStore.currentChannel) {
this.disconnected()
this.stopObsStream()
this.stopScreenStream()
this.stopWebcamStream()
this.stopAudioStream()
//TODO: fix subscribring to room members writeable
// if (this.roomMembersSubscription) {
// this.roomMembersSubscription.unsubscribe()
// }
// if (this.userActionsSubscription) {
// this.userActionsSubscription.unsubscribe()
// }
// }
}

toggleRaiseHand() {
Expand Down Expand Up @@ -625,13 +625,13 @@ class StreamStore {
}

sendDataToRoom(message: any) {
if (channelStore.currentChannel) {
socketStore.emitUserActions({
channelId: '',//TODO: get channelId from writeable channelStore.currentChannel._id,
userData: this.userData,
message: JSON.stringify(message)
})
}
// if (channelStore.currentChannel) {
socketStore.emitUserActions({
channelId: '',//TODO: get channelId from writeable channelStore.currentChannel._id,
userData: this.userData,
message: JSON.stringify(message)
})
// }
}

public waitOneSecondObs() {
Expand Down
8 changes: 4 additions & 4 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { redirect } from '@sveltejs/kit'

/** @type {import('./$types').LayoutServerLoad} */
export function load({ locals }) {
if (!locals.user) {
throw redirect(307, '/browse')
}
export function load({ locals }: { locals: any }) {
if (!locals.user) {
throw redirect(307, '/browse')
}
}
30 changes: 15 additions & 15 deletions src/routes/legal/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
import { adminStore } from '../../lib/stores/adminStore'
import { getLegalDocs } from '../../lib/stores/adminStore'

export const load = (async () => {
//const post = await adminStore.getLegalDocs()
const post = [
{ name: "Privacy Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/privacy.pdf" },
{ name: "Cookie Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/cookie.pdf" },
{ name: "Copyright Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/copyright.pdf" },
{ name: "GDPR Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/gdpr.pdf" },
{ name: "Terms of Service", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/terms.pdf" }
]
if (post) {
return {
post
}
}
throw error(404, 'Not found')
// const post = await getLegalDocs()
const post = [
{ name: "Privacy Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/privacy.pdf" },
{ name: "Cookie Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/cookie.pdf" },
{ name: "Copyright Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/copyright.pdf" },
{ name: "GDPR Policy", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/gdpr.pdf" },
{ name: "Terms of Service", url: "https://code-crow-legal-docs.s3.amazonaws.com/legal/terms.pdf" }
]
if (post) {
return {
post
}
}
throw error(404, 'Not found')
}) satisfies PageServerLoad

0 comments on commit f093cee

Please sign in to comment.