New collections (#1484)

* [WIP] Transfer collections to own branch

* fixes

* rewrite js

* Add visibility dropdown to collection edit modal

* Add visibility badges to collection page

* Update visibility options and icons in collection
page

* Add delete functionality to collection modal

* Collection project deletion flow

* remove "visit project" button on overflow

* Remove via checklist not individually

* Update manage title in settings.vue

* remove collections from settings page

* hook up collections page

* collection header to look like project header

* Refactor layout.scss and collections.vue

* fix omorphia

* Update

* Conform collections to old design structure

* Update navigation links and remove unused code

* Add collection view and collections to user page

* Refactor user project display logic

* Add collection creation functionality and update profile labels

* Add function calls to initialize user collections

* Refactor collection page layout and functionality

* Add initialization of user collections in create function

* Fix styling issue in collection page

* Update collection status to private

* remove name

* Refactor card component and update grid layout

* Finish collections

---------

Co-authored-by: Carter <safe@fea.st>
This commit is contained in:
Geometrically
2023-12-27 13:27:50 -05:00
committed by GitHub
parent e319d19a54
commit 3a735ea0ce
24 changed files with 1396 additions and 123 deletions

View File

@@ -25,6 +25,7 @@ export const useCosmetics = () =>
shader: 'gallery',
datapack: 'list',
user: 'list',
collection: 'list',
},
}
}

View File

@@ -19,12 +19,12 @@ export const initUser = async () => {
if (auth.user && auth.user.id) {
try {
const [notifications, follows] = await Promise.all([
useBaseFetch(`user/${auth.user.id}/notifications`),
const [follows, collections] = await Promise.all([
useBaseFetch(`user/${auth.user.id}/follows`),
useBaseFetch(`user/${auth.user.id}/collections`, { apiVersion: 3 }),
])
user.notifications = notifications
user.collections = collections
user.follows = follows
user.lastUpdated = Date.now()
} catch (err) {
@@ -35,13 +35,13 @@ export const initUser = async () => {
return user
}
export const initUserNotifs = async () => {
export const initUserCollections = async () => {
const auth = (await useAuth()).value
const user = (await useUser()).value
if (auth.user && auth.user.id) {
try {
user.notifications = await useBaseFetch(`user/${auth.user.id}/notifications`)
user.collections = await useBaseFetch(`user/${auth.user.id}/collections`, { apiVersion: 3 })
} catch (err) {
console.error(err)
}
@@ -74,6 +74,28 @@ export const initUserProjects = async () => {
}
}
export const userCollectProject = async (collection, projectId) => {
const user = (await useUser()).value
const add = !collection.projects.includes(projectId)
const projects = add
? [...collection.projects, projectId]
: [...collection.projects].filter((x) => x !== projectId)
const idx = user.collections.findIndex((x) => x.id === collection.id)
if (idx >= 0) {
user.collections[idx].projects = projects
}
await useBaseFetch(`collection/${collection.id}`, {
method: 'PATCH',
body: {
new_projects: projects,
},
apiVersion: 3,
})
}
export const userFollowProject = async (project) => {
const user = (await useUser()).value
@@ -100,29 +122,6 @@ export const userUnfollowProject = async (project) => {
})
}
export const userDeleteNotification = async (id) => {
const user = (await useUser()).value
user.notifications = user.notifications.filter((x) => x.id !== id)
}
export const userDeleteNotifications = async (ids) => {
const user = (await useUser()).value
user.notifications = user.notifications.filter((x) => !ids.includes(x.id))
}
export const userReadNotifications = async (ids) => {
const user = (await useUser()).value
user.notifications = user.notifications.map((x) => {
if (ids.includes(x.id)) {
x.read = true
}
return x
})
}
export const resendVerifyEmail = async () => {
const app = useNuxtApp()