Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/erin/jjs' into marston/draft-box
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Feb 14, 2024
2 parents 6ed0c53 + d1fbe22 commit ec38916
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
54 changes: 52 additions & 2 deletions src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ interface IBStore {

getOwnedRns(): IRnsOwnedHashMap | null
getJackalAddress(): string
getWorkspaceFolder(): FolderHandler
getDraftsFolder(): FolderHandler
getPublishedFolder(): FolderHandler
loadDraft(name: string): Promise<string>

saveDraft(name: string, source: string): Promise<void>
publishFinal(name: string, source: string): Promise<void>
compilePublications(): Promise<void>

isWalletInit(): boolean
isFileIoInit(): boolean
Expand All @@ -37,6 +39,7 @@ class BStore implements IBStore {
private jackalAddress: string
private ownedRns: IRnsOwnedHashMap | null

private workspaceFolder: IFolderHandler | null
private draftsFolder: IFolderHandler | null
private publishedFolder: IFolderHandler | null

Expand All @@ -47,6 +50,7 @@ class BStore implements IBStore {
this.jackalAddress = ''

this.ownedRns = null
this.workspaceFolder = null
this.draftsFolder = null
this.publishedFolder = null
}
Expand Down Expand Up @@ -75,6 +79,13 @@ class BStore implements IBStore {
return this.jackalAddress
}

async getWorkspaceFolder(): FolderHandler {
if (!this.workspaceFolder) {
throw Error('no workspace')
}
return this.workspaceFolder
}

async getDraftsFolder(): FolderHandler {
if (!this.draftsFolder) {
throw Error('no drafts')
Expand Down Expand Up @@ -142,6 +153,41 @@ class BStore implements IBStore {
}
await this.globalFileIo.staggeredUploadFiles(upload, this.publishedFolder, { complete: 0, timer: 0 })
await this.fetchPublishedFolder()

await this.compilePublications()
}

async compilePublications(): Promise<void> {
if (!this.globalFileIo || !this.publishedFolder) {
throw 'oh fuck file io'
}

const folder = this.getPublishedFolder()
const final = {}
const children = folder.getChildFiles()
for (const name in children) {
final[name] = children[name].lastModified
}

await this.globalFileIo.shuffle()

const fileName = 'worx'
const worxFile = new File([JSON.stringify(final)], fileName)
const handler = await FileUploadHandler.trackFile(worxFile, this.workspaceFolder.getMyPath())
const upload: IUploadList = {}
upload[fileName] = {
data: null,
exists: false,
handler,
key: fileName,
uploadable: await handler.getForPublicUpload()
}
await this.globalFileIo.staggeredUploadFiles(upload, this.workspaceFolder, { complete: 0, timer: 0 })
await this.fetchWorkspaceFolder()
}

private async fetchWorkspaceFolder(): Promise<void> {
this.workspaceFolder = await this.globalFileIo.downloadFolder(['s', workspace].join('/'))
}

private async fetchDraftsFolder(): Promise<void> {
Expand All @@ -164,12 +210,16 @@ class BStore implements IBStore {
throw 'oh fuck file io'
}
if (await this.globalFileIo.checkFolderIsFileTree(['s', workspace].join('/'))) {
await this.fetchWorkspaceFolder()
await this.fetchDraftsFolder()
await this.fetchPublishedFolder()
} else {
await this.globalFileIo.generateInitialDirs(null, [workspace])
const beacon = await this.globalFileIo.downloadFolder(['s', workspace].join('/'))
await this.globalFileIo.createFolders(beacon, ['drafts', 'published'])
await this.fetchWorkspaceFolder()
if (!this.workspaceFolder) {
throw 'oh fuck workspace folder'
}
await this.globalFileIo.createFolders(this.workspaceFolder, ['drafts', 'published'])

await this.fetchDraftsFolder()
await this.fetchPublishedFolder()
Expand Down
9 changes: 6 additions & 3 deletions src/views/UserPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { bStore } from '@/store/main.ts'
const shell = ref<HTMLElement | null>(null)
const peoples = ref<HTMLElement | null>(null)
const route = useRoute()
async function requestData(owner: string): Promise<string> {
// TODO: Get user page data
return owner
const url = `https://jackal.link/p/${owner}/beacon/worx`
return fetch(url)
.then(resp => resp.text())
.catch(err => {
throw err
})
}
onMounted(async () => {
Expand Down

0 comments on commit ec38916

Please sign in to comment.