ui: scratchpad: seperate code store

This commit is contained in:
undefined committed 2021-11-14 16:33:27 +08:00
1 parent 803885330d
commit 17b6c2f6af
4 files changed
+8 -5

No files matched your search

@@ -1,10 +1,13 @@
let cacheKey = `${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`;
if (UiContext.tdoc?._id && UiContext.tdoc.rule !== 'homework') cacheKey += `@${UiContext.tdoc._id}`;
export default function reducer(state = {
lang: UiContext.codeLang,
code: localStorage.getItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`) || UiContext.codeTemplate,
code: localStorage.getItem(cacheKey) || UiContext.codeTemplate,
}, action) {
switch (action.type) {
case 'SCRATCHPAD_EDITOR_UPDATE_CODE': {
localStorage.setItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`, action.payload);
localStorage.setItem(cacheKey, action.payload);
return {
...state,
code: action.payload,
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.26.16",
"version": "4.26.17",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
+1 -1
View File
@@ -269,7 +269,7 @@ export namespace Time {
else if (isMoment(timestamp)) _timestamp = timestamp.toDate().getTime();
else _timestamp = timestamp.getTime();
const hexSeconds = Math.floor(_timestamp / 1000).toString(16);
return new ObjectID(`${hexSeconds}${allZero ? '0000000000000000' : new ObjectID().toHexString().substr(8, 12)}`);
return new ObjectID(`${hexSeconds}${allZero ? '0000000000000000' : new ObjectID().toHexString().substr(8)}`);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/utils",
"version": "1.1.6",
"version": "1.1.7",
"description": "hydrooj utils",
"main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git",