Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/development/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
},
"remoteUser": "developer",
"postCreateCommand": "yarn install",
"mounts": [
"source=${localEnv:HOME}/.local/share/gnome-shell/extensions/,target=/home/developer/.local/share/gnome-shell/extensions/,type=bind,consistency=cached"
],
"customizations": {
"vscode": {
"settings": {
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
"typescript": "^4.8.4"
},
"dependencies": {
"@girs/gjs": "4.0.0-beta.16",
"@girs/gnome-shell": "47.0.0-next.4",
"@girs/soup-3.0": "3.6.0-4.0.0-beta.16"
"@girs/gjs": "4.0.0-beta.36",
"@girs/gnome-shell": "48.0.4",
"@girs/soup-3.0": "3.6.5-4.0.0-beta.36"
},
"resolutions": {
"@girs/adw-1": "1.6.0-4.0.0-beta.16",
"@girs/clutter-15": "15.0.0-4.0.0-beta.16",
"@girs/gdk-4.0": "4.0.0-4.0.0-beta.16",
"@girs/gdkpixbuf-2.0": "2.0.0-4.0.0-beta.16",
"@girs/gio-2.0": "2.82.0-4.0.0-beta.16",
"@girs/glib-2.0": "2.82.0-4.0.0-beta.16",
"@girs/gobject-2.0": "2.82.0-4.0.0-beta.16",
"@girs/gtk-4.0": "4.15.5-4.0.0-beta.16",
"@girs/st-15": "15.0.0-4.0.0-beta.16"
"@girs/adw-1": "1.8.0-4.0.0-beta.36",
"@girs/clutter-16": "16.0.0-4.0.0-beta.36",
"@girs/gdk-4.0": "4.0.0-4.0.0-beta.36",
"@girs/gdkpixbuf-2.0": "2.0.0-4.0.0-beta.36",
"@girs/gio-2.0": "2.84.4-4.0.0-beta.36",
"@girs/glib-2.0": "2.84.4-4.0.0-beta.36",
"@girs/gobject-2.0": "2.84.4-4.0.0-beta.36",
"@girs/gtk-4.0": "4.19.1-4.0.0-beta.36",
"@girs/st-16": "16.0.0-4.0.0-beta.36"
}
}
4 changes: 2 additions & 2 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const metadata: ExtensionMetadata = JSON.parse(data) as ExtensionMetadata;
const explicitMappings = new Map<string, string>(
Object.entries({
'@girs/adw-1': 'gi://Adw',
'@girs/clutter-15': 'gi://Clutter',
'@girs/clutter-16': 'gi://Clutter',
'@girs/gdk-4.0': 'gi://Gdk',
'@girs/gdkpixbuf-2.0': 'gi://GdkPixbuf',
'@girs/gio-2.0': 'gi://Gio',
'@girs/glib-2.0': 'gi://GLib',
'@girs/gobject-2.0': 'gi://GObject',
'@girs/gtk-4.0': 'gi://Gtk',
'@girs/soup-3.0': 'gi://Soup?version=3.0',
'@girs/st-15': 'gi://St',
'@girs/st-16': 'gi://St',
})
);

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"shell-version": [
"45",
"46",
"47"
"47",
"48"
],
"gettext-domain": "github-manager@mackdk-on-github",
"version": 1
Expand Down
4 changes: 2 additions & 2 deletions src/main/typescript/client/GitHubClientImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export class GitHubClientImpl implements GitHubClient {

private static readonly DEFAULT_API_POLL_INTERVAL: number = 60;

private readonly engine: HttpEngine;

private _pollInterval: number;

private _domain: string;

private _token: string;

private engine: HttpEngine;

public constructor(domain: string, token: string, engine: HttpEngine) {
this._pollInterval = GitHubClientImpl.DEFAULT_API_POLL_INTERVAL;

Expand Down
6 changes: 3 additions & 3 deletions src/main/typescript/client/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export enum HttpMethod {
}

export class HttpRequest {
private _url: string;
private _method: HttpMethod;
private _body: RequestBody | undefined;
private readonly _url: string;
private readonly _method: HttpMethod;
private readonly _headers: Map<string, string>;
private _body: RequestBody | undefined;

public constructor(method: HttpMethod, url: string, body?: RequestBody, headers?: Map<string, string>) {
this._method = method;
Expand Down
3 changes: 0 additions & 3 deletions src/main/typescript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ declare global {
};
};
/* eslint-enable no-var */

export function log(message: string): void;
export function logError(e: unknown, message: string): void;
}
37 changes: 35 additions & 2 deletions src/main/typescript/notifications/DefaultNotificationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,57 @@ import { GitHub } from '@github-manager/client';
import { NotificationProvider } from './NotificationProvider';

export class DefaultNotificationProvider implements NotificationProvider {
private readonly projectSourceMap: Map<string, MessageTray.Source>;

private digestSource: MessageTray.Source | undefined;

public constructor() {
this.projectSourceMap = new Map();
this.digestSource = undefined;
}

public newProjectNotification(data: GitHub.Thread): MessageTray.Notification {
const repositoryName = data.repository.name;
const repositoryIcon = Gio.icon_new_for_string(data.repository.owner.avatar_url);
const projectSource = this.getOrCreateProjectSource(repositoryName, repositoryIcon);

return new MessageTray.Notification({
source: new MessageTray.Source({ title: repositoryName, icon: repositoryIcon }),
source: projectSource,
title: repositoryName,
body: data.subject.title,
isTransient: false,
});
}

public newDigestNotification(digestIcon: Gio.Icon, title: string, body: string): MessageTray.Notification {
if (this.digestSource === undefined) {
this.digestSource = new MessageTray.Source({ title: 'Github Notification', icon: digestIcon });
this.digestSource.connect('destroy', (_source, _reason) => {
this.digestSource = undefined;
});
}

return new MessageTray.Notification({
source: new MessageTray.Source({ title: 'Github Notification', icon: digestIcon }),
source: this.digestSource,
title: title,
body: body,
isTransient: false,
});
}

private getOrCreateProjectSource(repositoryName: string, repositoryIcon: Gio.Icon): MessageTray.Source {
let source: MessageTray.Source | undefined = this.projectSourceMap.get(repositoryName);
if (source !== undefined) {
return source;
}

source = new MessageTray.Source({ title: repositoryName, icon: repositoryIcon });
source.connect('destroy', (_source, _reason) => {
this.projectSourceMap.delete(repositoryName);
source = undefined;
});

this.projectSourceMap.set(repositoryName, source);
return source;
}
}
2 changes: 0 additions & 2 deletions src/main/typescript/preferences/SettingRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ export class SettingRow extends Adw.ActionRow {
'prefix',
'Prefix widget',
'Widget at the beginning of the setting row',
// @ts-expect-error girs type is currently broken here
GObject.ParamFlags.READWRITE,
Gtk.Widget.$gtype
),
suffix: GObject.ParamSpec.object(
'suffix',
'Suffix widget',
'Widget at the end of the setting row',
// @ts-expect-error girs type is currently broken here
GObject.ParamFlags.READWRITE,
Gtk.Widget.$gtype
),
Expand Down
1 change: 1 addition & 0 deletions src/main/typescript/utils/LimitedRetriableTimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class LimitedRetriableTimer {
private runTaskAndSchedule(): void {
this.task()
.then((outcome: boolean) => {
this.timerHandle = undefined;
this.computeCurrentInterval(outcome);
this.scheduleNextRun();
LimitedRetriableTimer.LOGGER.debug(
Expand Down
10 changes: 5 additions & 5 deletions src/main/typescript/utils/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Logger {
}
});
} catch (error) {
logError(error, `[${Logger.domainName}] Logger initialization error while loading configuration file`);
globalThis.console.log(`[${Logger.domainName}] Error while loading configuration file`, error);
}
}

Expand Down Expand Up @@ -177,13 +177,13 @@ export class Logger {
const logMessage = `[${Logger.domainName}] ${this.loggerName} ${LogLevel[level]} ${message}`;

if (err instanceof Error) {
logError(err, logMessage);
globalThis.console.log(logMessage, err);
} else if (typeof err === 'string') {
log(`${logMessage} - ${err}`);
globalThis.console.log(`${logMessage} - ${err}`);
} else if (err !== undefined) {
log(`${logMessage} - Additional object of type ${typeof err}: ${err?.toString() ?? '(n/a)'}`);
globalThis.console.log(`${logMessage} - Error of type ${typeof err}: ${err?.toString() ?? '(n/a)'}`);
} else {
log(logMessage);
globalThis.console.log(logMessage);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/utils/gnome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface BaseGObject<K extends GObject.Object> {
export function registerGObject<K extends GObject.Object, T extends BaseGObject<K>>(target: T): T {
// Note that we use 'hasOwnProperty' because otherwise we would get inherited meta infos.
// This would be bad because we would inherit the GObjectName too, which is supposed to be unique.
if (target.metaInfo !== undefined && Object.prototype.hasOwnProperty.call(target, 'metaInfo')) {
if (target.metaInfo !== undefined && Object.hasOwn(target, 'metaInfo')) {
LOGGER.debug('Registering GObject {0} with metaInfo', typeof target);
return GObject.registerClass(target.metaInfo, target);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/typescript/widget/GitHubWidget.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Clutter from '@girs/clutter-15';
import Clutter from '@girs/clutter-16';
import Gio from '@girs/gio-2.0';
import { Button } from '@girs/gnome-shell/dist/ui/panelMenu';
import GObject from '@girs/gobject-2.0';
import St from '@girs/st-15';
import St from '@girs/st-16';

import { GObjectMetaInfo, registerGObject } from '@github-manager/utils/gnome';

Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/widget/WidgetController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Clutter from '@girs/clutter-15';
import Clutter from '@girs/clutter-16';
import Gdk from '@girs/gdk-4.0';
import Gio from '@girs/gio-2.0';
import { Extension } from '@girs/gnome-shell/dist/extensions/extension';
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/test/stubs/girs/gnome-shell/dist/ui/messageTray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export class Source {
public addNotification(notification: Notification) {}

public destroy(reason: NotificationDestroyedReason) {}

public connect(sigName: 'destroy', callback: ($obj: Source, reason: NotificationDestroyedReason) => void): number {
return 0;
}
}

export class Notification {
Expand Down
File renamed without changes.
31 changes: 11 additions & 20 deletions src/test/typescript/utils/Logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,27 @@ import { LogLevel, Logger } from '@github-manager/utils/Logger';
import '@test-suite/globals';

describe('Logger', () => {
let logSpy: SinonSpy<[message: string], void>;
let logErrorSpy: SinonSpy<[e: unknown, message: string], void>;
let logSpy: SinonSpy<[message?: unknown, ...addtionalPamaraters: unknown[]], void>;

const getUserDataDirStub: SinonStub<[], string> = stub(GLib, 'get_user_data_dir');
const newForPathStub: SinonStub<[path: string], Gio.File> = stub(Gio.File, 'new_for_path');

before(() => {
logSpy = spy(globalThis, 'log');
logErrorSpy = spy(globalThis, 'logError');
logSpy = spy(globalThis.console, 'log');
Logger.domain = 'TestSuite';
});

beforeEach(() => {
Logger.resetConfiguration();

logSpy.resetHistory();
logErrorSpy.resetHistory();

newForPathStub.reset();
getUserDataDirStub.reset();
});

after(() => {
logSpy.restore();
logErrorSpy.restore();

newForPathStub.restore();
getUserDataDirStub.restore();
});
Expand Down Expand Up @@ -104,25 +99,22 @@ describe('Logger', () => {

// Single error argument
logger.warn('Log entry with an error', error);
assert.isTrue(logSpy.notCalled);
assert.isTrue(logErrorSpy.calledOnce);
assert.isTrue(logErrorSpy.calledWithExactly(error, '[TestSuite] Logger.test WARN Log entry with an error'));
assert.isTrue(logSpy.calledOnce);
assert.isTrue(logSpy.calledWithExactly('[TestSuite] Logger.test WARN Log entry with an error', error));

// Error argument with other format arguments
logger.error('Unable to get item #{0} due to {1}', 65, 'E_DUPLICATE_KEY', error);
assert.isTrue(logSpy.notCalled);
assert.isTrue(logErrorSpy.calledTwice);
assert.isTrue(logSpy.calledTwice);
assert.isTrue(
logErrorSpy.calledWithExactly(
error,
'[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY'
logSpy.calledWithExactly(
'[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY',
error
)
);

// Error argument as string
logger.error('Unable to get item #{0} due to {1}', 65, 'E_DUPLICATE_KEY', 'Error text');
assert.isTrue(logSpy.calledOnce);
assert.isTrue(logErrorSpy.calledTwice);
assert.isTrue(logSpy.callCount === 3);
assert.isTrue(
logSpy.calledWithExactly(
'[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY - Error text'
Expand All @@ -132,11 +124,10 @@ describe('Logger', () => {
// Error argument as object
const errorObject = { toString: () => 'Error in object' };
logger.error('Unable to get item #{0} due to {1}', 65, 'E_DUPLICATE_KEY', errorObject);
assert.isTrue(logSpy.calledTwice);
assert.isTrue(logErrorSpy.calledTwice);
assert.isTrue(logSpy.callCount === 4);
assert.isTrue(
logSpy.calledWithExactly(
'[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY - Additional object of type object: Error in object'
'[TestSuite] Logger.test ERROR Unable to get item #65 due to E_DUPLICATE_KEY - Error of type object: Error in object'
)
);
});
Expand Down
Loading
Loading