graph-store: restore @ud encoding

This commit is contained in:
Liam Fitzgerald 2020-10-05 15:27:26 +10:00
parent 627937f5a0
commit fdbf225c66
3 changed files with 16 additions and 2 deletions

View File

@ -513,7 +513,7 @@
=/ =ship (slav %p i.t.t.path)
=/ =term i.t.t.t.path
=/ =index:store
(turn t.t.t.t.path |=(=cord (rash cord dem:ag)))
(turn t.t.t.t.path (cury slav %ud))
=/ node=(unit node:store) (get-node ship term index)
?~ node [~ ~]
:- ~ :- ~ :- %graph-update

View File

@ -4,6 +4,7 @@ import { Patp, Path, PatpNoSig } from '~/types/noun';
import _ from 'lodash';
import {makeResource, resourceFromPath} from '../lib/group';
import {GroupPolicy, Enc, Post, NodeMap} from '~/types';
import { numToUd } from '~/logic/lib/util';
export const createPost = (contents: Object[], parentIndex: string = '') => {
return {
@ -203,9 +204,10 @@ export default class GraphApi extends BaseApi<StoreState> {
}
getNode(ship: string, resource: string, index: string) {
const idx = index.split('/').map(numToUd).join('/');
return this.scry<any>(
'graph-store',
`/node/${ship}/${resource}${index}`
`/node/${ship}/${resource}${idx}`
).then((node) => {
this.store.handleEvent({
data: node

View File

@ -323,3 +323,15 @@ export function scrollIsAtBottom(container) {
}
}
/**
* Formats a numbers as a `@ud` inserting dot where needed
*/
export function numToUd(num) {
return _.chain(num.toString())
.split('')
.reverse()
.chunk(3)
.reverse()
.map(s => s.join('')).join('.')
.value();
}