1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

JS-3524: notification badge

This commit is contained in:
Andrew Simachev 2024-01-02 21:32:01 +01:00
parent a68550e117
commit 0f09377ab4
No known key found for this signature in database
GPG key ID: 49A163D0D14E6FD8
3 changed files with 15 additions and 4 deletions

View file

@ -95,9 +95,6 @@ nativeTheme.on('updated', () => {
});
function createWindow () {
Util.log('info', 'CreateWindow: ' + deeplinkingUrl + ' ' + JSON.stringify(process.argv));
mainWindow = WindowManager.createMain({ route: Util.getRouteFromUrl(deeplinkingUrl), isChild: false });
mainWindow.on('close', (e) => {

View file

@ -1,4 +1,5 @@
const { app, shell, BrowserWindow } = require('electron');
const { is } = require('electron-util');
const keytar = require('keytar');
const { download } = require('electron-dl');
@ -192,6 +193,12 @@ class Api {
this.setConfig(win, { languages });
};
setBadge (win, t) {
if (is.macos) {
app.dock.setBadge(t);
};
};
};
module.exports = new Api();

View file

@ -1,5 +1,5 @@
import { observable, action, computed, makeObservable, set } from 'mobx';
import { I, M } from 'Lib';
import { I, M, Renderer } from 'Lib';
class NotificationStore {
@ -20,10 +20,12 @@ class NotificationStore {
set (list: I.Notification[]): void {
this.itemList = list.map(it => new M.Notification(it));
this.setBadge();
};
add (item: I.Notification): void {
this.itemList.unshift(item);
this.setBadge();
};
update (item: I.Notification): void {
@ -36,12 +38,17 @@ class NotificationStore {
delete (id: string) {
this.itemList = this.itemList.filter(it => it.id != id);
this.setBadge();
};
clear () {
this.itemList = [];
};
setBadge () {
Renderer.send('setBadge', String(this.list.length || ''));
};
};
export const notificationStore: NotificationStore = new NotificationStore();