mirror of
https://github.com/urbit/shrub.git
synced 2024-12-02 08:55:07 +03:00
Merge branch 'mp/os1/metadata-remove' (#2401)
* origin/mp/os1/metadata-remove: groups: reduce metadata updates, removal chat: reducer handles metadata removal Signed-off-by: Jared Tobin <jared@tlon.io>
This commit is contained in:
commit
2bf46d7d26
@ -7,6 +7,7 @@ export class MetadataReducer {
|
||||
this.associations(data, state);
|
||||
this.add(data, state);
|
||||
this.update(data, state);
|
||||
this.remove(data, state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +40,13 @@ export class MetadataReducer {
|
||||
state.associations = metadata;
|
||||
}
|
||||
}
|
||||
|
||||
remove(json, state) {
|
||||
let data = _.get(json, 'remove', false);
|
||||
if (data) {
|
||||
let metadata = state.associations;
|
||||
metadata.delete(data["app-path"]);
|
||||
state.associations = metadata;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,8 @@ export class MetadataReducer {
|
||||
if (data) {
|
||||
this.associations(data, state);
|
||||
this.add(data, state);
|
||||
this.update(data, state);
|
||||
this.remove(data, state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +36,35 @@ export class MetadataReducer {
|
||||
}
|
||||
metadata[data['group-path']]
|
||||
[`${data["group-path"]}/${data["app-name"]}${data["app-path"]}`] = data;
|
||||
|
||||
|
||||
state.associations = metadata;
|
||||
}
|
||||
}
|
||||
update(json, state) {
|
||||
let data = _.get(json, 'update-metadata', false);
|
||||
if (data) {
|
||||
let metadata = state.associations;
|
||||
if (!(data["group-path"] in metadata)) {
|
||||
metadata[data["group-path"]] = {};
|
||||
}
|
||||
metadata[data["group-path"]][
|
||||
`${data["group-path"]}/${data["app-name"]}${data["app-path"]}`
|
||||
] = data;
|
||||
|
||||
state.associations = metadata;
|
||||
}
|
||||
}
|
||||
|
||||
remove(json, state) {
|
||||
let data = _.get(json, 'remove', false);
|
||||
if (data) {
|
||||
let metadata = state.associations;
|
||||
if (data['group-path'] in metadata) {
|
||||
let path =
|
||||
`${data['group-path']}/${data['app-name']}${data['app-path']}`
|
||||
delete metadata[data["group-path"]][path];
|
||||
state.associations = metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user