Skip to content

Commit

Permalink
feat: import @cocreate/local-storage
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Jan 29, 2023
1 parent b293a24 commit 1a24bd2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"html5-framework",
"javascript-framework"
],
"publishConfig": { "access": "public" },
"publishConfig": {
"access": "public"
},
"scripts": {
"start": "npx webpack --config webpack.config.js",
"build": "NODE_ENV=production npx webpack --config webpack.config.js",
Expand All @@ -34,7 +36,9 @@
},
"author": "CoCreate LLC",
"license": "MIT",
"bugs": { "url": "https://github.com/CoCreate-app/CoCreate-modal/issues" },
"bugs": {
"url": "https://github.com/CoCreate-app/CoCreate-modal/issues"
},
"homepage": "https://cocreate.app/docs/modal",
"funding": {
"type": "GitHub Sponsors ❤",
Expand All @@ -60,6 +64,7 @@
"@cocreate/crud-client": "^1.18.0",
"@cocreate/docs": "^1.5.9",
"@cocreate/element-prototype": "^1.4.6",
"@cocreate/local-storage": "^1.3.49",
"@cocreate/message-client": "^1.1.128",
"@cocreate/observer": "^1.5.59",
"@cocreate/position": "^1.1.41",
Expand Down
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import uuid from '@cocreate/uuid'
import action from '@cocreate/actions';
import observer from '@cocreate/observer';
import message from '@cocreate/message-client';
import localStorge from '@cocreate/local-storage';
import './index.css';

function CoCreateModal(id) {
Expand All @@ -18,15 +19,15 @@ function CoCreateModal(id) {
this.modals = new Map();
this.rootId = this.pageId;
this.parentId = this.pageId;
window.localStorage.setItem('rootId', this.pageId)
localStorage.setItem('rootId', this.pageId)
} else {
this.pageId = window.localStorage.getItem('pageId')
this.pageId = localStorage.getItem('pageId')
let viewPort = window.top.CoCreate.modal.viewPorts
if (viewPort)
viewPort.set(this.pageId, this)

// ToDo: can be depreciated if we find a better way to pass rootid and parentid
this.parentId = window.localStorage.getItem('parentId')
this.parentId = localStorage.getItem('parentId')
this.rootId = window.top.CoCreate.modal.rootId
}

Expand Down Expand Up @@ -140,7 +141,7 @@ CoCreateModal.prototype = {
break;
}

window.localStorage.setItem('parentId', openId)
localStorage.setItem('parentId', openId)

data.type = 'open';
data.parentId = openId;
Expand Down
2 changes: 1 addition & 1 deletion src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Modal(el, options, viewPort) {
this.el.setAttribute("id", this.id);
this.el.setAttribute("moveable", '');

window.localStorage.setItem('pageId', this.id)
localStorage.setItem('pageId', this.id)

this._init();
this._setModalSize();
Expand Down

0 comments on commit 1a24bd2

Please sign in to comment.