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:
parent
a68550e117
commit
0f09377ab4
3 changed files with 15 additions and 4 deletions
|
@ -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) => {
|
||||
|
|
|
@ -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();
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue