feat: use last community in community form
This commit is contained in:
1 parent
d22d9b09fd
commit
6c7073fcfc
6 files changed
+70
-10
No files matched your search
@@ -19,6 +19,13 @@
|
||||
*/
|
||||
export let editingPost: Post | undefined = undefined
|
||||
|
||||
export let passedCommunity:
|
||||
| {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
| undefined = undefined
|
||||
|
||||
let data: {
|
||||
community: number | null
|
||||
title: string
|
||||
@@ -65,14 +72,19 @@
|
||||
data.title = editingPost.name
|
||||
}
|
||||
|
||||
const list = await getClient().listCommunities({
|
||||
auth: $profile?.jwt,
|
||||
type_: 'Subscribed',
|
||||
sort: 'Active',
|
||||
limit: 40,
|
||||
})
|
||||
if (passedCommunity) {
|
||||
data.community = passedCommunity.id
|
||||
communitySearch = passedCommunity.name
|
||||
} else {
|
||||
const list = await getClient().listCommunities({
|
||||
auth: $profile?.jwt,
|
||||
type_: 'Subscribed',
|
||||
sort: 'Active',
|
||||
limit: 40,
|
||||
})
|
||||
|
||||
communities = list.communities.map((c) => c.community)
|
||||
communities = list.communities.map((c) => c.community)
|
||||
}
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
interface SessionStorage {
|
||||
lastSeenCommunity: // prettier-ignore
|
||||
{
|
||||
id: number
|
||||
name: string
|
||||
} | undefined
|
||||
postData: {}
|
||||
}
|
||||
|
||||
export const setSessionStorage = (
|
||||
key: keyof SessionStorage,
|
||||
value: SessionStorage[typeof key]
|
||||
) => {
|
||||
if (value == undefined) {
|
||||
sessionStorage.removeItem(key)
|
||||
} else {
|
||||
sessionStorage.setItem(key, JSON.stringify(value))
|
||||
}
|
||||
}
|
||||
|
||||
export const getSessionStorage = (
|
||||
key: keyof SessionStorage
|
||||
): SessionStorage[typeof key] => {
|
||||
return JSON.parse(sessionStorage.getItem(key)!)
|
||||
}
|
||||
@@ -17,3 +17,6 @@ export const searchParam = (
|
||||
invalidateAll: true,
|
||||
})
|
||||
}
|
||||
|
||||
export const fullCommunityName = (name: string, actorId: string) =>
|
||||
`${name}@${new URL(actorId).hostname}`
|
||||
Reference in new issue
Block a user