-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(error-watcher): Show an error message when libndi is not install…
…ed. (#564) * feat(error-watcher): Show an error message when libndi is not installed. * feat(errorwatcher): handles external links and multiple errors Adds ElectronLink component for opening a link in the default OS browser. Updates ErrorWatcher to clear errors once dismissed and to handle multiple errors gracefully. * refactor: removes local impot of global component Co-authored-by: Sam Wray <sam@wray.pro>
- Loading branch information
1 parent
134fffd
commit 697dd79
Showing
8 changed files
with
160 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* globals __dirname */ | ||
|
||
import store from "./worker/store/index"; | ||
|
||
let grandiose = undefined; | ||
|
||
export default function setupGrandiose() { | ||
if (grandiose === undefined) { | ||
/* eslint-disable */ | ||
__dirname = `${__dirname}/node_modules/grandiose`; | ||
__dirname = __dirname.replace("app.asar", "app.asar.unpacked"); | ||
/* eslint-enable */ | ||
|
||
try { | ||
grandiose = require("grandiose"); | ||
} catch (error) { | ||
if (error.message.includes("libndi.so")) { | ||
store.dispatch("errors/createMessage", { | ||
message: | ||
"libndi is not installed, please see \"Ubuntu/Debian\" in the modV <ElectronLink to='https://github.com/vcync/modV#ubuntudebian'>README</ElectronLink>." | ||
}); | ||
} else { | ||
console.error(error); | ||
} | ||
} | ||
|
||
// eslint-disable-next-line | ||
__dirname = __dirname.replace("/node_modules/grandiose", ""); | ||
} | ||
|
||
// Make sure to set grandiose to undefined as it will be an empty object otherwise | ||
if (!grandiose.isSupportedCPU) { | ||
grandiose = undefined; | ||
} | ||
|
||
return grandiose; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Vue from "vue"; | ||
import uuidv4 from "uuid/v4"; | ||
|
||
const state = { | ||
messages: {} | ||
}; | ||
|
||
const actions = { | ||
createMessage({ commit }, { message }) { | ||
if (!message) { | ||
throw new Error("No message given"); | ||
} | ||
|
||
commit("CREATE_MESSAGE", { message, id: uuidv4() }); | ||
}, | ||
|
||
deleteMessage({ commit }, { id }) { | ||
commit("REMOVE_MESSAGE", { id }); | ||
} | ||
}; | ||
|
||
const mutations = { | ||
CREATE_MESSAGE(state, { message, id }) { | ||
Vue.set(state.messages, id, message); | ||
}, | ||
|
||
REMOVE_MESSAGE(state, { id }) { | ||
Vue.delete(state.messages, id); | ||
} | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
mutations, | ||
actions | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<a @click.prevent="openUrl"><slot /></a> | ||
</template> | ||
|
||
<script> | ||
import { shell } from "electron"; | ||
export default { | ||
props: { | ||
to: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
methods: { | ||
openUrl() { | ||
shell.openExternal(this.to); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
a { | ||
cursor: pointer; | ||
text-decoration: underline; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<template> | ||
<!-- key is used to trigger re-mount of component when the next error message is available --> | ||
<Dialog | ||
v-if="message" | ||
:key="messageId" | ||
@close="dialogClosed" | ||
title="Error" | ||
style="max-width: 420px" | ||
> | ||
<component | ||
:is="{ | ||
template: `<span>${this.message}</span>` | ||
}" | ||
></component> | ||
</Dialog> | ||
</template> | ||
|
||
<script> | ||
import Dialog from "./Dialog"; | ||
export default { | ||
components: { | ||
Dialog | ||
}, | ||
computed: { | ||
message() { | ||
return Object.values(this.$modV.store.state.errors.messages)[0]; | ||
}, | ||
messageId() { | ||
return Object.keys(this.$modV.store.state.errors.messages)[0]; | ||
} | ||
}, | ||
methods: { | ||
dialogClosed() { | ||
this.$modV.store.dispatch("errors/deleteMessage", { id: this.messageId }); | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters