diff --git a/src/js/router.js b/src/js/router.js
index 916299e..a185e99 100644
--- a/src/js/router.js
+++ b/src/js/router.js
@@ -17,6 +17,18 @@ const checkLogin = (to, from, next) => {
}
const routes = [
+ {
+ path: '',
+ beforeEnter (to, from, next) {
+ const state = store.state;
+ if (state.github.githubKey &&
+ !window.folderJSON.isEmpty()) {
+ next('/list');
+ } else {
+ next();
+ }
+ }
+ },
{
path: '/list/:path*',
component: List,
diff --git a/src/js/store/gistux.js b/src/js/store/gistux.js
index 2dcff67..fee12b5 100644
--- a/src/js/store/gistux.js
+++ b/src/js/store/gistux.js
@@ -95,9 +95,8 @@ export default {
}
// If we didn't find a config file
- return context.dispatch('updateFolderJSON').then(() => {
- context.dispatch('updateGistUXConfig');
- });
+ context.dispatch('updateFolderJSON');
+ return context.dispatch('updateGistUXConfig');
}
// If we have an existing folderJSON object when this is called
@@ -113,8 +112,13 @@ export default {
const fileContent = resp.data.files[context.getters.gistUXFileName].content;
if (!window.folderJSON.validateFile(fileContent)) {
context.dispatch('setError', 'Invalid GistUX file found. Do you have another file with the same name?');
- return Promise.reject();
+
+ // If we can't read the config file, assume there isn't one, but don't write to it
+ context.commit('setGistPermission', false);
+ context.dispatch('updateFolderJSON');
+ return context.dispatch('updateGistUXConfig');
}
+
context.dispatch('updateFolderJSON', JSON.parse(fileContent));
context.commit('setFolderJSONConfigFileID', folderJSONConfigFile.id);
@@ -151,7 +155,11 @@ export default {
);
}
},
- updateGistUXConfig (context) {
+ updateGistUXConfig (context, force = false) {
+ // If we know that we can't write to the gist
+ if (!context.rootState.github.ghGistPermission && !force)
+ return Promise.resolve(null);
+
return context.dispatch(
'writeGistContent',
{
diff --git a/src/js/store/github.js b/src/js/store/github.js
index 4eede9b..8c16ca1 100644
--- a/src/js/store/github.js
+++ b/src/js/store/github.js
@@ -7,7 +7,7 @@ export default {
gh: null,
ghUser: null,
ghUserData: null,
- ghGistPermission: null
+ ghGistPermission: true
},
mutations: {
setGithubKey (state, key) {
diff --git a/src/js/views/list.vue b/src/js/views/list.vue
index edee4db..48df852 100644
--- a/src/js/views/list.vue
+++ b/src/js/views/list.vue
@@ -5,6 +5,9 @@
Fix this by regenerating your Github Token and giving it the gist permission.
+ Alternatively, if you have already given the gist permission, this may be caused by an existing file named {{$store.getters.gistUXFileName}}
that doesn't have valid config information.
+
+
If you wish to go ahead with this, you may import/export your temporary config file from