diff --git a/package.json b/package.json index b026af29..64e55526 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "start:dev": "npm run build -w @holochain/launcher-api-scripts && npm run tauri dev", "start:dev2": "npm run build -w @holochain/launcher-api-scripts && npm run build:ui && cargo run --manifest-path ./src-tauri/Cargo.toml", "dev": "vite", - "build:ui": "vue-tsc --noEmit && vite build", + "build:ui": "vue-tsc --noEmit && vite build && npm run build -w @holochain/launcher-api-scripts -w @holochain/launcher-api", "build": "npm run build -w @holochain/launcher-api-scripts && npm run tauri -- build -v", "preview": "vite preview", "publish:apps": "ADMIN_PORT=10001 run-singleton \"node scripts/publish-apps.js --inspect\"", diff --git a/scripts/setup-binaries.sh b/scripts/setup-binaries.sh index 6cb0720c..a709ec7f 100644 --- a/scripts/setup-binaries.sh +++ b/scripts/setup-binaries.sh @@ -1,12 +1,53 @@ #!/bin/bash -rm -rf src-tauri/bins/ -mkdir src-tauri/bins +REQUIRED_HOLOCHAIN_VERSION="0.2.3-beta-rc.1" +REQUIRED_LAIR_VERSION="0.3.0" +# Check that this script is being run from the right location +if [ ! -f "package.json" ] || [ ! -f "src-tauri/tauri.conf.json" ]; +then + echo "Error: You must run this script in the root directory of the launcher repository." + exit 1 +fi + +# Check wheter cargo is available +if [ ! command -v cargo &> /dev/null ] || [ ! command -v rustc &> /dev/null ]; +then + echo "Error: You need to install Rust first." + exit 1 +fi + +# get target architecture triple, e.g. unknown-linux-gnu on Ubuntu 22.04 TARGET_TRIPLE=$(rustc -vV | sed -n 's/^.*host: \(.*\)*$/\1/p') -HOLOCHAIN_PATH=$(which holochain) -cp $HOLOCHAIN_PATH src-tauri/bins/holochain-$TARGET_TRIPLE +# create src-tauri/bins if id doesn't exist +if [ ! -d src-tauri/bins ]; + then mkdir src-tauri/bins +fi + +# check whether correct holochain binary is already in the src-tauri/bins folder +if [ -f "src-tauri/bins/holochain-v${REQUIRED_HOLOCHAIN_VERSION}-$TARGET_TRIPLE" ]; + then echo "Required holochain binary already installed." + else + echo "Installing required holochain binary from crates.io" + echo "Running command 'cargo install holochain --version $REQUIRED_HOLOCHAIN_VERSION --locked --features sqlite-encrypted'" + cargo install holochain --version $REQUIRED_HOLOCHAIN_VERSION --locked --features sqlite-encrypted + echo "Copying holochain binary to src-tauri/bins folder." + HOLOCHAIN_PATH=$(which holochain) + cp $HOLOCHAIN_PATH src-tauri/bins/holochain-v${REQUIRED_HOLOCHAIN_VERSION}-$TARGET_TRIPLE +fi + +# check whether correct lair binary is already in the src-tauri/bins folder +if [ -f "src-tauri/bins/lair-keystore-v${REQUIRED_LAIR_VERSION}-${TARGET_TRIPLE}" ]; + + then echo "Required lair-keystore binary already installed." + else + echo "Installing required lair-keystore binary from crates.io" + echo "Running command 'cargo install lair-keystore --version $REQUIRED_LAIR_VERSION --locked'" + cargo install lair_keystore --version $REQUIRED_LAIR_VERSION --locked + echo "Copying lair-keystore binary to src-tauri/bins folder." + LAIR_PATH=$(which lair-keystore) + cp $LAIR_PATH src-tauri/bins/lair-keystore-v${REQUIRED_LAIR_VERSION}-$TARGET_TRIPLE +fi -LAIR_PATH=$(which lair-keystore) -cp $LAIR_PATH src-tauri/bins/lair-keystore-$TARGET_TRIPLE +echo "done." diff --git a/src-tauri/src/commands/notifications.rs b/src-tauri/src/commands/notifications.rs index 3d70ba06..abd6c2fc 100644 --- a/src-tauri/src/commands/notifications.rs +++ b/src-tauri/src/commands/notifications.rs @@ -127,7 +127,7 @@ pub async fn clear_happ_notifications( ) -> Result<(), String> { // This tauri command is allowed to be called only by the window of the corresponding app: if window.label() != derive_window_label(&app_id) { - return Err(String::from("Unauthorized: Attempted to notifications for app that this tauri window is not associated to.")) + return Err(String::from("Unauthorized: Attempted to clear notifications for app that this tauri window is not associated to.")) } // Send notifications to admin window to store to localStorage and check diff --git a/src/App.vue b/src/App.vue index cce59c51..9d9bbd52 100644 --- a/src/App.vue +++ b/src/App.vue @@ -187,6 +187,17 @@ export default defineComponent({ async (e: Event) => { await clearHappNotifications(e.payload); this.$store.commit("loadNotificationState"); + // Check whether there are any unread messages left across all apps + // and if not, clear the systray icon dot + const overallUnreadNotifications = Object.entries( + this.$store.state.notificationState + ).filter( + ([_appId, unreadNotifications]) => + unreadNotifications && unreadNotifications.length > 0 + ); + if (overallUnreadNotifications.length === 0) { + await invoke("clear_systray_icon", {}); + } } ); diff --git a/src/store/index.ts b/src/store/index.ts index a18db054..93878c1f 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -415,6 +415,7 @@ export const store = createStore({ async fetchStateInfo({ commit }) { commit("loadStateInfo"); const StateInfo: LauncherStateInfo = await invoke("get_state_info", {}); + commit("loadNotificationState"); commit("setStateInfo", StateInfo); }, diff --git a/src/utils.ts b/src/utils.ts index e5a3dfd5..af541030 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -328,3 +328,22 @@ export function setHappNotificationSettings( ): void { setLocalStorageItem(`happNotificationSettings#${installedAppId}`, settings); } + +/** + * Deletes all notification storage related to an app. To be called upon unsinstalling the app + */ +export function deleteNotificationStorage( + installedAppId: InstalledAppId +): void { + window.localStorage.removeItem(`happNotificationSettings#${installedAppId}`); + window.localStorage.removeItem(`happNotificationsUnread#${installedAppId}`); + // Remove all historical notificationss + Object.keys(window.localStorage).forEach((key) => { + if ( + key.includes("happNotifications#") && + key.includes(`#${installedAppId}`) + ) { + window.localStorage.removeItem(key); + } + }); +} diff --git a/src/views/Settings.vue b/src/views/Settings.vue index d4fc9708..b09a037a 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -545,6 +545,7 @@ import { isAppRunning, locatorToLocatorB64, capitalizeFirstLetter, + deleteNotificationStorage, } from "../utils"; import { mapGetters } from "vuex"; @@ -915,6 +916,7 @@ export default defineComponent({ try { await invoke("uninstall_app", { appId, holochainId: app.holochainId }); + deleteNotificationStorage(appId); await this.refreshAppStates(); this.showMessage(`Uninstalled ${appId}`); } catch (e) {