-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: transform collaborative store into app store
- Loading branch information
1 parent
3c38fe0
commit fa362be
Showing
8 changed files
with
63 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { AppSlug } from '@/types/enums/AppSlug.ts'; | ||
import { useSessionStorage } from '@vueuse/core'; | ||
import { defineStore } from 'pinia'; | ||
import { ref } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
|
||
export const useAppStore = defineStore('app', () => { | ||
const router = useRouter(); | ||
|
||
/** | ||
* App context state | ||
*/ | ||
const isApp = ref<boolean>(false); | ||
|
||
/* -- Rooms -- */ | ||
|
||
const ownedRooms = useSessionStorage< | ||
Array<{ roomId: string; appType: AppSlug; fileId: number | undefined; saveOnFile: boolean }> | ||
>(`${__APP_SLUG__}.owned-rooms`, []); | ||
|
||
/** | ||
* Id of file to load in the room | ||
*/ | ||
const initFileId = ref<number | undefined>(); | ||
|
||
const initRoom = (roomId: string, appType: AppSlug, fileId: number | undefined, saveOnFile: boolean): void => { | ||
initFileId.value = fileId; | ||
ownedRooms.value.push({ roomId, appType, fileId, saveOnFile }); | ||
router.push({ name: `collaborative-${appType}`, params: { roomId } }); | ||
}; | ||
|
||
/* -- Store actions -- */ | ||
|
||
const reset = (): void => { | ||
initFileId.value = undefined; | ||
}; | ||
|
||
return { | ||
isApp, | ||
ownedRooms, | ||
initFileId, | ||
initRoom, | ||
reset, | ||
}; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters