Skip to content

Commit

Permalink
Merge branch 'trunk' into fix-activate-teapot
Browse files Browse the repository at this point in the history
  • Loading branch information
CurtlyCritchlow authored Dec 5, 2024
2 parents 9588771 + 476d10e commit 459431a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -60,7 +60,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
uses: github/codeql-action/autobuild@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -73,6 +73,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
sarif_file: results.sarif
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'dart:io';

import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:npt_flutter/app.dart';
import 'package:npt_flutter/features/favorite/favorite.dart';
import 'package:npt_flutter/features/onboarding/cubit/onboarding_cubit.dart';
import 'package:npt_flutter/features/profile/profile.dart';
import 'package:npt_flutter/features/profile_list/profile_list.dart';
import 'package:npt_flutter/features/settings/settings.dart';
Expand All @@ -23,7 +26,8 @@ class TrayManager extends StatefulWidget {
State<TrayManager> createState() => _TrayManagerState();
}

class _TrayManagerState extends State<TrayManager> with TrayListener, WindowListener {
class _TrayManagerState extends State<TrayManager>
with TrayListener, WindowListener {
/// Must strongly type [context] here or Dart will infer the wrong type for
/// the [.read()] extension which causes an error
void reloadTray(BuildContext context, Loggable state) async {
Expand All @@ -36,7 +40,8 @@ class _TrayManagerState extends State<TrayManager> with TrayListener, WindowList
case ProfilesRunningState _:
cubit.reload(profilesRunningState: state);
case SettingsLoadedState _:
var localizations = await AppLocalizations.delegate.load(state.settings.language.locale);
var localizations = await AppLocalizations.delegate
.load(state.settings.language.locale);
cubit.reload(localizations: localizations);
case ProfileState _:
cubit.reload(profileState: state);
Expand Down Expand Up @@ -78,12 +83,14 @@ class _TrayManagerState extends State<TrayManager> with TrayListener, WindowList
listener: reloadTray,
// Only call listener when the language changes in settings
listenWhen: (prev, next) {
if (prev is SettingsLoadedState && next is SettingsLoadedState) {
if (prev is SettingsLoadedState &&
next is SettingsLoadedState) {
return prev.settings.language != next.settings.language;
}
// This may cause some extra reloading (very occasionally, settings shouldn't change often)
// but it should catch all of the edge cases
return prev is SettingsLoadedState || next is SettingsLoadedState;
return prev is SettingsLoadedState ||
next is SettingsLoadedState;
}),

/// Yeah I really hate this... an indefinite list of listeners
Expand Down Expand Up @@ -114,6 +121,7 @@ class _TrayManagerState extends State<TrayManager> with TrayListener, WindowList
trayManager.addListener(this);
super.initState();
windowManager.setPreventClose(true);
windowManager.setVisibleOnAllWorkspaces(true);
var dispatcher = SchedulerBinding.instance.platformDispatcher;

// This callback is called every time the brightness changes.
Expand Down Expand Up @@ -143,6 +151,12 @@ class _TrayManagerState extends State<TrayManager> with TrayListener, WindowList

@override
void onWindowClose() async {
await windowManager.hide();
var onboardingCubit = App.navState.currentContext?.read<OnboardingCubit>();
if (onboardingCubit?.state.status == OnboardingStatus.onboarded) {
await windowManager.hide();
} else {
await windowManager.destroy();
exit(0);
}
}
}
7 changes: 5 additions & 2 deletions packages/dart/npt_flutter/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:npt_flutter/constants.dart';
import 'package:window_manager/window_manager.dart';
Expand All @@ -7,10 +9,11 @@ import 'app.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();

var windowOptions = const WindowOptions(
var windowOptions = WindowOptions(
title: "NoPorts Desktop",
minimumSize: Constants.kWindowsMinWindowSize,
skipTaskbar: true,
skipTaskbar: Platform.isWindows,
alwaysOnTop: true,
);
windowManager.ensureInitialized();
windowManager.waitUntilReadyToShow(windowOptions);
Expand Down
4 changes: 2 additions & 2 deletions packages/dart/sshnoports/tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile
# Build image for a containerized instance of sshnpd

FROM dart:3.5.4@sha256:09330bd172355c74cdf60bc2794b0f69489afe0b325510e810090f9195282d2b AS buildimage
FROM dart:3.5.4@sha256:3f3877b9a75a1695dd284151d2dab5787bc6cefd04313b6a8e0bee98230d347b AS buildimage
ENV PACKAGEDIR=packages/dart/sshnoports
ENV BINARYDIR=/usr/local/at
SHELL ["/bin/bash", "-c"]
Expand All @@ -17,7 +17,7 @@ RUN \
dart compile exe bin/srv.dart -o ${BINARYDIR}/srv

# Second stage of build FROM debian-slim
FROM debian:stable-20241202-slim@sha256:eb37f58646a901dc7727cf448cae36daaefaba79de33b5058dab79aa4c04aefb
FROM debian:stable-20241202-slim@sha256:4d63ef53faef7bd35c92fbefb1e9e2e7b6777e3cbec6c34f640e96b925e430eb
ENV USER=atsign
ENV HOMEDIR=/${USER}
ENV BINARYDIR=/usr/local/at
Expand Down
4 changes: 2 additions & 2 deletions packages/dart/sshnoports/tools/Dockerfile.activate
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dockerfile.activate
# Build image for a containerized call of the at_activate binary
FROM dart:3.5.4@sha256:09330bd172355c74cdf60bc2794b0f69489afe0b325510e810090f9195282d2b AS buildimage
FROM dart:3.5.4@sha256:3f3877b9a75a1695dd284151d2dab5787bc6cefd04313b6a8e0bee98230d347b AS buildimage
ENV PACKAGEDIR=packages/dart/sshnoports
ENV BINARYDIR=/usr/local/at
SHELL ["/bin/bash", "-c"]
Expand All @@ -15,7 +15,7 @@ RUN \
dart compile exe bin/activate_cli.dart -o ${BINARYDIR}/at_activate

# Second stage of build FROM debian-slim
FROM debian:stable-20241202-slim@sha256:eb37f58646a901dc7727cf448cae36daaefaba79de33b5058dab79aa4c04aefb
FROM debian:stable-20241202-slim@sha256:4d63ef53faef7bd35c92fbefb1e9e2e7b6777e3cbec6c34f640e96b925e430eb
ENV USER=atsign
ENV HOMEDIR=/${USER}
ENV BINARYDIR=/usr/local/at
Expand Down
2 changes: 1 addition & 1 deletion packages/dart/sshnoports/tools/Dockerfile.sshnpd-slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# as of 5th Feb 2024 - Will check state as 3.3 Stable is released
#FROM dart:beta-sdk AS buildimage

FROM dart:3.5.4@sha256:09330bd172355c74cdf60bc2794b0f69489afe0b325510e810090f9195282d2b AS buildimage
FROM dart:3.5.4@sha256:3f3877b9a75a1695dd284151d2dab5787bc6cefd04313b6a8e0bee98230d347b AS buildimage
ENV PACKAGEDIR=packages/dart/sshnoports
ENV OPENSSH=tools/static-openssh
ENV BINARYDIR=/usr/local/at
Expand Down
8 changes: 4 additions & 4 deletions tests/end2end_tests/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BASE
FROM debian:stable-20241202-slim@sha256:eb37f58646a901dc7727cf448cae36daaefaba79de33b5058dab79aa4c04aefb AS base
FROM debian:stable-20241202-slim@sha256:4d63ef53faef7bd35c92fbefb1e9e2e7b6777e3cbec6c34f640e96b925e430eb AS base

ENV USER=atsign
ENV HOMEDIR=/${USER}
Expand All @@ -26,7 +26,7 @@ RUN set -eux ; \

# BRANCH
# BUILD BRANCH
FROM dart:3.5.4@sha256:09330bd172355c74cdf60bc2794b0f69489afe0b325510e810090f9195282d2b AS build-branch
FROM dart:3.5.4@sha256:3f3877b9a75a1695dd284151d2dab5787bc6cefd04313b6a8e0bee98230d347b AS build-branch

ENV URL=https://github.com/atsign-foundation/noports.git
ENV REPO_DIR=/app/repo
Expand Down Expand Up @@ -65,7 +65,7 @@ ENTRYPOINT cp -r /mount/. ${HOMEDIR} && sudo service ssh start && sh ${HOMEDIR}/

# LOCAL
# BUILD LOCAL
FROM dart:3.5.4@sha256:09330bd172355c74cdf60bc2794b0f69489afe0b325510e810090f9195282d2b AS build-local
FROM dart:3.5.4@sha256:3f3877b9a75a1695dd284151d2dab5787bc6cefd04313b6a8e0bee98230d347b AS build-local

ENV REPO_DIR=/app/repo
ENV PACKAGE_DIR=${REPO_DIR}/packages/dart/sshnoports
Expand Down Expand Up @@ -101,7 +101,7 @@ ENTRYPOINT cp -r /mount/. ${HOMEDIR} && sudo service ssh start && sh ${HOMEDIR}/

# RELEASE
# BUILD RELEASE
FROM debian:stable-20241202-slim@sha256:eb37f58646a901dc7727cf448cae36daaefaba79de33b5058dab79aa4c04aefb AS build-release
FROM debian:stable-20241202-slim@sha256:4d63ef53faef7bd35c92fbefb1e9e2e7b6777e3cbec6c34f640e96b925e430eb AS build-release

ARG release

Expand Down

0 comments on commit 459431a

Please sign in to comment.