aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/plugins/modules
diff options
context:
space:
mode:
authorRémy Raes <contact@remyraes.com>2023-04-10 14:25:32 +0200
committerGitHub <noreply@github.com>2023-04-10 14:25:32 +0200
commit6d58e6793d40df4fec518f37351868803a02a033 (patch)
tree8ba8b1fdf503579314e9475bee409e0ba549e7ad /src-vue/src/plugins/modules
parent0d4744ad1f05ea6410b4cbe4e1e0270e67055ce6 (diff)
downloadFlightCore-6d58e6793d40df4fec518f37351868803a02a033.tar.gz
FlightCore-6d58e6793d40df4fec518f37351868803a02a033.zip
refactor: Notifications (#259)
* feat: wrap ElNotification class in a showNotification method * refactor: replace notification invocations in mod views * feat: add 'info' type to showNotification method * refactor: replace notification invocations in repair view * refactor: replace notification invocations in settings view * refactor: replace notification invocations in developer view * feat: showNotification method now returns a NotificationHandle * feat: showNotification has a duration argument * refactor: replace notification invocations in pull requests module * refactor: replace notification invocation in repair view * refactor: replace notification invocations in UI store * refactor: remove unused import from play view * refactor: use showErrorNotification method to wrap up error display * fix: add missing showErrorNotification imports * style: format code * style: format ThunderstoreModCard.vue * style: format pull_requests.ts * style: format SettingsView.vue * style: format RepairView.vue * style: format DeveloperView.vue * refactor: remove useless import * refactor: add missing showErrorNotification invocation * feat: showErrorNotification has an optional title argument * style: format LocalModsView.vue
Diffstat (limited to 'src-vue/src/plugins/modules')
-rw-r--r--src-vue/src/plugins/modules/pull_requests.ts66
1 files changed, 14 insertions, 52 deletions
diff --git a/src-vue/src/plugins/modules/pull_requests.ts b/src-vue/src/plugins/modules/pull_requests.ts
index 227888f2..ff9ec322 100644
--- a/src-vue/src/plugins/modules/pull_requests.ts
+++ b/src-vue/src/plugins/modules/pull_requests.ts
@@ -1,8 +1,8 @@
-import { ElNotification } from "element-plus";
import { invoke, shell } from "@tauri-apps/api";
import { PullsApiResponseElement } from "../../../../src-tauri/bindings/PullsApiResponseElement";
import { PullRequestType } from '../../../../src-tauri/bindings/PullRequestType';
import { store } from "../store";
+import { showErrorNotification, showNotification } from "../../utils/ui";
interface PullRequestStoreState {
searchValue: string,
@@ -33,12 +33,7 @@ export const pullRequestModule = {
}
})
.catch((error) => {
- ElNotification({
- title: 'Error',
- message: error,
- type: 'error',
- position: 'bottom-right'
- });
+ showErrorNotification(error);
});
},
async downloadLauncherPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
@@ -48,12 +43,7 @@ export const pullRequestModule = {
shell.open(url);
})
.catch((error) => {
- ElNotification({
- title: 'Error',
- message: error,
- type: 'error',
- position: 'bottom-right'
- });
+ showErrorNotification(error);
});
},
async downloadModsPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
@@ -62,32 +52,16 @@ export const pullRequestModule = {
},
async installLauncherPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
// Send notification telling the user to wait for the process to finish
- const notification = ElNotification({
- title: `Installing launcher PR ${pull_request.number}`,
- message: 'Please wait',
- duration: 0,
- type: 'info',
- position: 'bottom-right'
- });
+ const notification = showNotification(`Installing launcher PR ${pull_request.number}`, 'Please wait', 'info', 0);
await invoke("apply_launcher_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_path })
.then((message) => {
console.log(message);
// Show user notification if mod install completed.
- ElNotification({
- title: `Done`,
- message: `Installed ${pull_request.number}: "${pull_request.title}"`,
- type: 'success',
- position: 'bottom-right'
- });
+ showNotification(`Done`, `Installed ${pull_request.number}: "${pull_request.title}"`);
})
.catch((error) => {
- ElNotification({
- title: 'Error',
- message: error,
- type: 'error',
- position: 'bottom-right'
- });
+ showErrorNotification(error);
})
.finally(() => {
// Clear old notification
@@ -96,32 +70,20 @@ export const pullRequestModule = {
},
async installModsPR(state: PullRequestStoreState, pull_request: PullsApiResponseElement) {
// Send notification telling the user to wait for the process to finish
- const notification = ElNotification({
- title: `Installing mods PR ${pull_request.number}`,
- message: 'Please wait',
- duration: 0,
- type: 'info',
- position: 'bottom-right'
- });
+ const notification = showNotification(`Installing mods PR ${pull_request.number}`, 'Please wait', 'info', 0);
await invoke("apply_mods_pr", { pullRequest: pull_request, gameInstallPath: store.state.game_path })
.then((message) => {
// Show user notification if mod install completed.
- ElNotification({
- title: `Done`,
- message: `Installed ${pull_request.number}: "${pull_request.title}"\nMake sure to launch via batch file or by specifying correct profile!`,
- type: 'success',
- duration: 7_000, // in ms
- position: 'bottom-right'
- });
+ showNotification(
+ `Done`,
+ `Installed ${pull_request.number}: "${pull_request.title}"\nMake sure to launch via batch file or by specifying correct profile!`,
+ 'success',
+ 7000
+ );
})
.catch((error) => {
- ElNotification({
- title: 'Error',
- message: error,
- type: 'error',
- position: 'bottom-right'
- });
+ showErrorNotification(error);
})
.finally(() => {
// Clear old notification