mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix pinnedDomains (#564)
This commit is contained in:
1 parent
314c64e766
commit
a0b2e65319
2 files changed
+12
-2
No files matched your search
@@ -441,7 +441,7 @@ class HomeDomainHandler extends Handler {
|
|||||||
|
|
||||||
@param('id', Types.String)
|
@param('id', Types.String)
|
||||||
async postStar(domainId: string, id: string) {
|
async postStar(domainId: string, id: string) {
|
||||||
await user.setById(this.user._id, { pinnedDomains: this.user.pinnedDomains.concat(id) });
|
await user.setById(this.user._id, { pinnedDomains: [...this.user.pinnedDomains, id] });
|
||||||
this.back({ star: true });
|
this.back({ star: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ class HomeDomainCreateHandler extends Handler {
|
|||||||
await Promise.all([
|
await Promise.all([
|
||||||
domain.edit(domainId, { avatar }),
|
domain.edit(domainId, { avatar }),
|
||||||
domain.setUserRole(domainId, this.user._id, 'root'),
|
domain.setUserRole(domainId, this.user._id, 'root'),
|
||||||
user.setById(this.user._id, undefined, undefined, { pinnedDomains: [domainId] }),
|
user.setById(this.user._id, undefined, undefined, { pinnedDomains: domainId }),
|
||||||
]);
|
]);
|
||||||
this.response.redirect = this.url('domain_dashboard', { domainId });
|
this.response.redirect = this.url('domain_dashboard', { domainId });
|
||||||
this.response.body = { domainId };
|
this.response.body = { domainId };
|
||||||
|
|||||||
@@ -587,6 +587,16 @@ const scripts: UpgradeScript[] = [
|
|||||||
await document.coll.updateMany({ docType: document.TYPE_TRAINING, pin: true }, { $set: { pin: 1 } });
|
await document.coll.updateMany({ docType: document.TYPE_TRAINING, pin: true }, { $set: { pin: 1 } });
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
async function _81_82() {
|
||||||
|
return await iterateAllUser((udoc) => {
|
||||||
|
let pinnedDomains = new Set<string>();
|
||||||
|
for (const d of udoc.pinnedDomains) {
|
||||||
|
if (typeof d === 'string') pinnedDomains.add(d);
|
||||||
|
else pinnedDomains = Set.union(pinnedDomains, d);
|
||||||
|
}
|
||||||
|
return user.setById(udoc._id, { pinnedDomains: Array.from(pinnedDomains) });
|
||||||
|
});
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default scripts;
|
export default scripts;
|
||||||
Reference in new issue
Block a user