Merge pull request #2208 from h3poteto/iss-2088
refs #2088 Show notification when receive status notification in websocket
This commit is contained in:
commit
48cdb054c9
|
@ -25,7 +25,7 @@ import path from 'path'
|
||||||
import ContextMenu from 'electron-context-menu'
|
import ContextMenu from 'electron-context-menu'
|
||||||
import { initSplashScreen, Config } from '@trodi/electron-splashscreen'
|
import { initSplashScreen, Config } from '@trodi/electron-splashscreen'
|
||||||
import openAboutWindow from 'about-window'
|
import openAboutWindow from 'about-window'
|
||||||
import { Entity, detector } from 'megalodon'
|
import { Entity, detector, NotificationType } from 'megalodon'
|
||||||
import sanitizeHtml from 'sanitize-html'
|
import sanitizeHtml from 'sanitize-html'
|
||||||
import AutoLaunch from 'auto-launch'
|
import AutoLaunch from 'auto-launch'
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
|
@ -1365,7 +1365,7 @@ async function reopenWindow() {
|
||||||
|
|
||||||
const createNotification = (notification: Entity.Notification, notifyConfig: Notify): NotificationConstructorOptions | null => {
|
const createNotification = (notification: Entity.Notification, notifyConfig: Notify): NotificationConstructorOptions | null => {
|
||||||
switch (notification.type) {
|
switch (notification.type) {
|
||||||
case 'favourite':
|
case NotificationType.Favourite:
|
||||||
if (notifyConfig.favourite) {
|
if (notifyConfig.favourite) {
|
||||||
return {
|
return {
|
||||||
title: i18next.t('notification.favourite.title'),
|
title: i18next.t('notification.favourite.title'),
|
||||||
|
@ -1374,7 +1374,7 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
|
||||||
} as NotificationConstructorOptions
|
} as NotificationConstructorOptions
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'follow':
|
case NotificationType.Follow:
|
||||||
if (notifyConfig.follow) {
|
if (notifyConfig.follow) {
|
||||||
return {
|
return {
|
||||||
title: i18next.t('notification.follow.title'),
|
title: i18next.t('notification.follow.title'),
|
||||||
|
@ -1383,7 +1383,7 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
|
||||||
} as NotificationConstructorOptions
|
} as NotificationConstructorOptions
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'follow_request':
|
case NotificationType.FollowRequest:
|
||||||
if (notifyConfig.follow_request) {
|
if (notifyConfig.follow_request) {
|
||||||
return {
|
return {
|
||||||
title: i18next.t('notification.follow_request.title'),
|
title: i18next.t('notification.follow_request.title'),
|
||||||
|
@ -1392,7 +1392,7 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
|
||||||
} as NotificationConstructorOptions
|
} as NotificationConstructorOptions
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'mention':
|
case NotificationType.Mention:
|
||||||
if (notifyConfig.reply) {
|
if (notifyConfig.reply) {
|
||||||
return {
|
return {
|
||||||
title: `${username(notification.status!.account)}`,
|
title: `${username(notification.status!.account)}`,
|
||||||
|
@ -1404,7 +1404,7 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
|
||||||
} as NotificationConstructorOptions
|
} as NotificationConstructorOptions
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'reblog':
|
case NotificationType.Reblog:
|
||||||
if (notifyConfig.reblog) {
|
if (notifyConfig.reblog) {
|
||||||
if (notification.status && notification.status.quote) {
|
if (notification.status && notification.status.quote) {
|
||||||
return {
|
return {
|
||||||
|
@ -1421,7 +1421,7 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'emoji_reaction':
|
case NotificationType.EmojiReaction:
|
||||||
if (notifyConfig.reaction) {
|
if (notifyConfig.reaction) {
|
||||||
return {
|
return {
|
||||||
title: i18next.t('notification.reaction.title'),
|
title: i18next.t('notification.reaction.title'),
|
||||||
|
@ -1430,6 +1430,15 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
|
||||||
} as NotificationConstructorOptions
|
} as NotificationConstructorOptions
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case NotificationType.Status:
|
||||||
|
if (notifyConfig.status) {
|
||||||
|
return {
|
||||||
|
title: i18next.t('notification.status.title'),
|
||||||
|
body: i18next.t('notification.status.body', { username: username(notification.account) }),
|
||||||
|
silent: false
|
||||||
|
} as NotificationConstructorOptions
|
||||||
|
}
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue