Skip to content

Commit

Permalink
fix regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
blurymind committed Jul 29, 2024
1 parent 9637105 commit 579dd2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/js/classes/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export var App = function(name, version) {
};

this.setGistCredentials = function(gist, e) {
self.log("SET CREDENTIALS")
const { token, file } = gist;
self.log("SET CREDENTIALS", {token, file})
data.storage.setCredentials(token, file);
};

Expand Down
23 changes: 14 additions & 9 deletions src/js/classes/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export const data = {
}).then(result => {
if (result.value) {
data.askForFileName();
} else {
data.startNewFile('NewFile');
}
});
},
Expand Down Expand Up @@ -174,8 +176,6 @@ export const data = {
);
},
saveAppStateToLocalStorage: Utils.debounce(function(writeCurrent = true) {
if (!app.settings.restoreSessionEnabled()) return;

const storage = app.settings.storage;
data.isDocumentDirty(true);
data.lastEditedUnix(new Date());
Expand All @@ -196,14 +196,20 @@ export const data = {
app.log('--- storage.clear() ---');
storage.clear(); //TODO remove later
}

const appStatesData = await data.db.getDbValue('appStates');
//const appStates = JSON.parse(storage.getItem('appStates')); // appStateS <- new key
const appStates = JSON.parse(appStatesData); // appStateS <- new key

const currentDocState = appStates[app.settings.selectedFileTab()];
if(app.settings.restoreSessionEnabled() === false) {
if (currentDocState) {
app.pluginStorage = currentDocState.pluginStorage;
}
app.settings.selectedFileTab(0)
data.startNewFile();
return;
}
data.appInstanceStates(appStates);
app.log('APP state', appStates, currentDocState);
app.log('APP state', appStates, currentDocState);
if (currentDocState) {
const {
editingPath,
Expand All @@ -225,8 +231,6 @@ export const data = {
} = currentDocState;
app.pluginStorage = pluginStorage;

if (!app.settings.restoreSessionEnabled()) return; // to ignore sometimes?

app.tags(tags);
data.editingPath(editingPath);
data.editingName(editingName);
Expand Down Expand Up @@ -1062,16 +1066,17 @@ export const data = {
},

trySaveGist: function(gists) {
console.log({gists})
if (data.storage.hasGistSettings()) {
data.storage.getGistFile().then(gist => {
const gistFiles = Object.keys(gist.body.files);
app.log(gistFiles);
data.promptFileNameAndFormat(({ editingName, yarnData }) => {
data.editingName(editingName);
data.storage.editGist(gists.file, editingName, yarnData);
data.storage.editGist(data.storage.gistId, editingName, yarnData);
Swal.fire(
'Saved!',
`The Yarn has been saved to gist ${gists.file}`,
`The Yarn has been saved to gist ${data.storage.gistId}`,
'success'
);
data.lastStorageHost('GIST');
Expand Down

0 comments on commit 579dd2b

Please sign in to comment.