Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Oct 11, 2023
2 parents 2b046de + c5cb2b1 commit 7f6dec0
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"",
Expand Down
53 changes: 47 additions & 6 deletions scripts/setup-binaries.sh
Original file line number Diff line number Diff line change
@@ -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."
2 changes: 1 addition & 1 deletion src-tauri/src/commands/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ export default defineComponent({
async (e: Event<InstalledAppId>) => {
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", {});
}
}
);
Expand Down
1 change: 1 addition & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ export const store = createStore<LauncherAdminState>({
async fetchStateInfo({ commit }) {
commit("loadStateInfo");
const StateInfo: LauncherStateInfo = await invoke("get_state_info", {});
commit("loadNotificationState");

commit("setStateInfo", StateInfo);
},
Expand Down
19 changes: 19 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
2 changes: 2 additions & 0 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ import {
isAppRunning,
locatorToLocatorB64,
capitalizeFirstLetter,
deleteNotificationStorage,
} from "../utils";
import { mapGetters } from "vuex";
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7f6dec0

Please sign in to comment.