mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-10 18:21:34 +03:00
Merge pull request #3130 from urbit/lf/base-hash
interface: show base hash
This commit is contained in:
commit
a40d8c0f92
@ -223,7 +223,28 @@
|
||||
==
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
|^
|
||||
?+ path (on-peek:def path)
|
||||
[%x %clay %base %hash ~] ``hash+!>(base-hash)
|
||||
==
|
||||
:: stolen from +trouble
|
||||
:: TODO: move to a lib?
|
||||
++ base-hash
|
||||
^- @uv
|
||||
=+ .^ ota=(unit [=ship =desk =aeon:clay])
|
||||
%gx /(scot %p our.bowl)/hood/(scot %da now.bowl)/kiln/ota/noun
|
||||
==
|
||||
?~ ota
|
||||
*@uv
|
||||
=/ parent (scot %p ship.u.ota)
|
||||
=+ .^(=cass:clay %cs /[parent]/[desk.u.ota]/1/late/foo)
|
||||
%^ end 3 3
|
||||
.^(@uv %cz /[parent]/[desk.u.ota]/(scot %ud ud.cass))
|
||||
--
|
||||
|
||||
++ on-agent on-agent:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
|
@ -41,7 +41,6 @@
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek
|
||||
|= =path
|
||||
~& peeking=path
|
||||
^- (unit (unit cage))
|
||||
?+ path (on-peek:def path)
|
||||
[* %kiln *] (on-peek:kiln-core path)
|
||||
|
14
pkg/arvo/mar/hash.hoon
Normal file
14
pkg/arvo/mar/hash.hoon
Normal file
@ -0,0 +1,14 @@
|
||||
|_ hash=@uv
|
||||
::
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun hash
|
||||
++ json
|
||||
s+(rsh 3 2 (scot %uv hash))
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun @uv
|
||||
--
|
||||
--
|
@ -61,6 +61,7 @@ export default class App extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.subscription.start();
|
||||
this.api.local.getBaseHash();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -53,4 +53,8 @@ export default class BaseApi<S extends object = {}> {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
scry<T>(app: string, path: Path): Promise<T> {
|
||||
return fetch(`/~/scry/${app}${path}.json`).then(r => r.json() as Promise<T>);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,13 @@ import BaseApi from "./base";
|
||||
import { StoreState } from "../store/type";
|
||||
import { SelectedGroup } from "../types/local-update";
|
||||
|
||||
|
||||
|
||||
export default class LocalApi extends BaseApi<StoreState> {
|
||||
getBaseHash() {
|
||||
this.scry<string>('file-server', '/clay/base/hash').then(baseHash => {
|
||||
this.store.handleEvent({ data: { local: { baseHash } } });
|
||||
});
|
||||
}
|
||||
|
||||
setSelected(selected: SelectedGroup[]) {
|
||||
this.store.handleEvent({
|
||||
data: {
|
||||
|
@ -24,6 +24,7 @@ export default class LaunchApp extends React.Component {
|
||||
const { props } = this;
|
||||
|
||||
return (
|
||||
<div className="h-100 flex flex-column h-100">
|
||||
<div className='v-mid ph2 dtc-m dtc-l dtc-xl flex justify-between flex-wrap' style={{ maxWidth: '40rem' }}>
|
||||
<Welcome firstTime={props.launch.firstTime} api={props.api} />
|
||||
<Tiles
|
||||
@ -34,6 +35,8 @@ export default class LaunchApp extends React.Component {
|
||||
weather={props.weather}
|
||||
/>
|
||||
</div>
|
||||
<div className="gray2-d gray2 ml4 mb4 f8"> {props.baseHash} </div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { StoreState } from '../store/type';
|
||||
import { Cage } from '../types/cage';
|
||||
import { LocalUpdate } from '../types/local-update';
|
||||
|
||||
type LocalState = Pick<StoreState, 'sidebarShown' | 'selectedGroups'>;
|
||||
type LocalState = Pick<StoreState, 'sidebarShown' | 'selectedGroups' | 'baseHash'>;
|
||||
|
||||
export default class LocalReducer<S extends LocalState> {
|
||||
reduce(json: Cage, state: S) {
|
||||
@ -11,8 +11,14 @@ export default class LocalReducer<S extends LocalState> {
|
||||
if (data) {
|
||||
this.sidebarToggle(data, state);
|
||||
this.setSelected(data, state);
|
||||
this.baseHash(data, state);
|
||||
}
|
||||
}
|
||||
baseHash(obj: LocalUpdate, state: S) {
|
||||
if ('baseHash' in obj) {
|
||||
state.baseHash = obj.baseHash;
|
||||
}
|
||||
}
|
||||
|
||||
sidebarToggle(obj: LocalUpdate, state: S) {
|
||||
if ('sidebarToggle' in obj) {
|
||||
|
@ -38,6 +38,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
pendingMessages: new Map(),
|
||||
chatInitialized: false,
|
||||
sidebarShown: true,
|
||||
baseHash: null,
|
||||
invites: {},
|
||||
associations: {
|
||||
chat: {},
|
||||
|
@ -16,6 +16,7 @@ export interface StoreState {
|
||||
// local state
|
||||
sidebarShown: boolean;
|
||||
selectedGroups: SelectedGroup[];
|
||||
baseHash: string | null;
|
||||
// invite state
|
||||
invites: Invites;
|
||||
// metadata state
|
||||
|
@ -2,7 +2,8 @@ import { Path } from './noun';
|
||||
|
||||
export type LocalUpdate =
|
||||
LocalUpdateSidebarToggle
|
||||
| LocalUpdateSelectedGroups;
|
||||
| LocalUpdateSelectedGroups
|
||||
| LocalUpdateBaseHash;
|
||||
|
||||
interface LocalUpdateSidebarToggle {
|
||||
sidebarToggle: boolean;
|
||||
@ -12,4 +13,8 @@ interface LocalUpdateSelectedGroups {
|
||||
selected: SelectedGroup[];
|
||||
}
|
||||
|
||||
interface LocalUpdateBaseHash {
|
||||
baseHash: string;
|
||||
}
|
||||
|
||||
export type SelectedGroup = [Path, string];
|
||||
|
Loading…
Reference in New Issue
Block a user