Access IndexedDB Instance as different website in Electron - javascript

I have an Angular Application running over Electron that is already in production, however I've made an update that is not yet released that has a serious issue.
I use IndexedDB do store the application data, and as for now I've been loading the app internal website with
mainWindow.loadURL('file://' + __dirname + '/index.html#');
However I had to create a custom protocol with registerBufferProtocol for loading files and now I load them like this
mainWindow.loadURL('customprotocol://localhost/index.html#');
It seems that Electron thinks this is a different website, so instead of accessing the same localStorage and indexedDB instances it provides a new one.
I need to find a way to instantiate and load the main browser windows using my new protocol, but keeping the old app data accessible in the same way as before.
On the Developer Tools Window of the old version of my app shows the localStorage session belongs to file://
However in the new App Version I made it shows that the localStorage session belongs to the other "new" site which loads with my custom protocol fredata://localhost
On the App Data path, the folder of all the different website files are still present, I was wondering if a simple rename would suffice, but I don't think it is that simple.

Related

Get the local directory path of the app where web app is loaded

Can I get the path of chrome/Mozilla where my web app is loaded which is created in react can fetch the local directory path of the app(Chrome/Mozilla etc)? Because I want to store the data of website on that location.
Like if I am browsing on Chrome, then I get the path of chrome where it is stored in the local directory.
You cannot browse through the client’s machine using javascript. It would be a major security flaw if you could do that. Just think, someone from the internet having access to your local files! If you are looking to store some data persistantly on the client side you can use.
cookie
localStorage
indexDB
sessionStorage
Thats pretty much it.

In-App Data For Chrome Apps

I'm developing a Chrome App to allow users to create virtual documents that are stored within the app itself, meaning I don't want the users to have direct access to the files.
The reason why this is is because when the app first starts, it's a screen showing previews/thumbnails of all the created files. If I gave users control over where the files were stored, this could be interferred with by having multiple files in various locations.
What I'd like to do is store everything inside of the app. If possible, I'd like to use JavaScript to create, modify, and edit files within the packaged app, not through the user-accessible file system. Is there any way to dynamically add files and folders to a packaged app using JavaScript?
If not, what are my options for a controlled system in which users cannot move their files to a different directory to keep my thumbnails/previews intact?
You only have read-only access to your package directory.
For an isolated virtual filesystem specific to your app, you should use the HTML5 Filesystem API. Yes, it has a big warning regarding its status, but it's the basis of Chrome's own APIs so it is not going anywhere in Chrome.
You should carefully consider though if it's really the best experience for your users. The good part though, if you ever wish to allow to use a location on the real filesystem, you don't need to change much - the chrome.fileSystem API simply provides another DirectoryEntry, but the rest of working with it is pretty much the same.

Force live users to expire assets for JS Web Apps

Our web application is built on AngularJS and Ruby on Rails. Sometimes we find a bug in the JS and need to patch it immediately. We push up an update to Heroku and the new JS files are then live. However, users on the site (who are currently on the site) and do not refresh their page, are still using the old JS file.
Is there a way to force refresh of the assets on deployment with Heroku? Or, is there a better way to handle this type of problem?
I am thinking of using web sockets to possibly handle the scenario.

Phonegap localStorage not backing up to iTunes

So I'm building an app using Phonegap and have come across an issue in my ad hoc testing phase.
After installing the app on my iDevices, I've tried to back up the data contained within localStorage to iTunes. For some reason, none of the things I've saved to localStorage seem to be retrieved when I re install the app. I've changed BackupWebStorage in my config file to "local" but that has not helped.
I know that ios 5.1 created many issues for localStorage being backed up and am wondering if that's still the case. If so, what would be my best alternative to localStorage? I'm content with using the File API or a local SQL database, I just need some direction before I rewrite a large amount of code.
Thanks!

SharePoint App DOM Manipulation and Deployment

I've got some issues with development and deployment of a sharepoint app. The App is going to be an App Part in a SharePoint site.
One issue is, that the app (provider hosted) is not high trusted, although I went through the msdn tutorial how to create a high trusted app (with certificate etc.) Everytime I deploy the app, I get the error: The specified application identifier is invalid or does not exist.
The second issue is, that the App uses JavaScript to manipulate the DOM. The problem is, that I can only manipulate the DOM of the App Part. But I want to manipulate the DOM of the SharePoint site itself, and all DOMs laying in it (all other Web or App Parts included in the Site).
Is this possible?
For example, in the App I want to manipulate the Menu of the SharePoint Site this way:
document.getElementById("zz15_RootAspMenu"). do something
This way I could add Menu-points. But I have no access to zz15_RootAspMenu because its in the outer DOM.
Could it be possible, that the solution to the first issue leads to the solution of the second?
The App is currently running on the SharePoint Machine on "localhost". (I'm working with a Remote Desktop so the App is running on the SharePoint Server but is called via localhost from there) If the App is deployed correctly, could it be that only then the App is imported correctly into the Site and then I can access it's DOM?

Categories

Resources