Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2d9103

Browse files
committed
fix(notices): unable to deactivate notice through socket
1 parent002411b commita2d9103

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

‎src/client/components/NoticeBanner/index.jsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class NoticeBanner extends React.Component {
2727

2828
return(
2929
<div
30+
id={'notice-banner'}
3031
style={{
3132
width:'100%',
3233
height:'30px',

‎src/client/containers/Modals/ViewAllNotificationsModal.jsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ import { makeObservable, observable } from 'mobx'
2020
importaxiosfrom'axios'
2121
importLogfrom'../../logger'
2222

23+
import{NOTIFICATIONS_MARK_READ}from'serverSocket/socketEventConsts'
24+
2325
import{hideModal}from'actions/common'
2426

2527
importBaseModalfrom'containers/Modals/BaseModal'
2628
importButtonfrom'components/Button'
2729

2830
importhelpersfrom'lib/helpers'
29-
importsocketfrom'lib/socket'
3031

3132
@observer
3233
classViewAllNotificationsModalextendsReact.Component{
@@ -55,7 +56,7 @@ class ViewAllNotificationsModal extends React.Component {
5556
if(!notification||!notification.data||!notification.data.ticket||!notification.data.ticket.uid)returnfalse
5657

5758
this.props.hideModal()
58-
socket.socket.emit('markNotificationRead',notification._id)
59+
this.props.socket.emit(NOTIFICATIONS_MARK_READ,notification._id)
5960
History.pushState(null,null,`/tickets/${notification.data.ticket.uid}`)
6061
}
6162

@@ -113,7 +114,12 @@ class ViewAllNotificationsModal extends React.Component {
113114
}
114115

115116
ViewAllNotificationsModal.propTypes={
116-
hideModal:PropTypes.func.isRequired
117+
hideModal:PropTypes.func.isRequired,
118+
socket:PropTypes.object.isRequired
117119
}
118120

119-
exportdefaultconnect(null,{ hideModal})(ViewAllNotificationsModal)
121+
constmapStateToProps=state=>({
122+
socket:state.shared.socket
123+
})
124+
125+
exportdefaultconnect(mapStateToProps,{ hideModal})(ViewAllNotificationsModal)

‎src/client/containers/Notice/NoticeContainer.jsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import axios from 'axios'
77
import{fetchNotices,deleteNotice,unloadNotices}from'actions/notices'
88
import{showModal}from'actions/common'
99

10+
import{NOTICE_SHOW,NOTICE_CLEAR}from'serverSocket/socketEventConsts'
11+
1012
importPageTitlefrom'components/PageTitle'
1113
importPageContentfrom'components/PageContent'
1214
importTablefrom'components/Table'
@@ -17,7 +19,6 @@ import ButtonGroup from 'components/ButtonGroup'
1719
importButtonfrom'components/Button'
1820

1921
importhelpersfrom'lib/helpers'
20-
importsocketfrom'lib/socket'
2122
importUIKitfrom'uikit'
2223

2324
classNoticeContainerextendsReact.Component{
@@ -46,7 +47,7 @@ class NoticeContainer extends React.Component {
4647
axios
4748
.put('/api/v2/notices/'+noticeId+'/activate',{active:true})
4849
.then(()=>{
49-
socket.ui.setShowNotice(noticeId)
50+
this.props.socket.emit(NOTICE_SHOW,{noticeId})
5051
})
5152
.catch(err=>{
5253
Log.error(err)
@@ -58,7 +59,7 @@ class NoticeContainer extends React.Component {
5859
axios
5960
.get('/api/v1/notices/clearactive')
6061
.then(()=>{
61-
socket.ui.setClearNotice()
62+
this.props.socket.emit(NOTICE_CLEAR)
6263

6364
helpers.UI.showSnackbar('Notice has been deactivated',false)
6465
})
@@ -195,6 +196,7 @@ class NoticeContainer extends React.Component {
195196
}
196197

197198
NoticeContainer.propTypes={
199+
socket:PropTypes.object.isRequired,
198200
notices:PropTypes.object.isRequired,
199201
loading:PropTypes.bool.isRequired,
200202

@@ -205,6 +207,7 @@ NoticeContainer.propTypes = {
205207
}
206208

207209
constmapStateToProps=state=>({
210+
socket:state.shared.socket,
208211
notices:state.noticesState.notices,
209212
loading:state.noticesState.loading
210213
})

‎src/models/user.js‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
* Copyright (c) 2014-2019. All rights reserved.
1313
*/
1414

15-
varasync=require('async')
16-
varmongoose=require('mongoose')
17-
varwinston=require('winston')
18-
varbcrypt=require('bcrypt')
19-
var_=require('lodash')
20-
varChance=require('chance')
15+
constasync=require('async')
16+
constmongoose=require('mongoose')
17+
constwinston=require('winston')
18+
constbcrypt=require('bcrypt')
19+
const_=require('lodash')
20+
constChance=require('chance')
2121
constutils=require('../helpers/utils')
2222

2323
// Required for linkage
2424
require('./role')
2525

26-
varSALT_FACTOR=10
27-
varCOLLECTION='accounts'
26+
constSALT_FACTOR=10
27+
constCOLLECTION='accounts'
2828

2929
/**
3030
* User Schema
@@ -79,23 +79,24 @@ var userSchema = mongoose.Schema({
7979
preferences:{
8080
tourCompleted:{type:Boolean,default:false},
8181
autoRefreshTicketGrid:{type:Boolean,default:true},
82-
openChatWindows:[{type:String,default:[]}]
82+
openChatWindows:[{type:String,default:[]}],
83+
keyboardShortcuts:{type:Boolean,default:true}
8384
},
8485

8586
deleted:{type:Boolean,default:false}
8687
})
8788

8889
userSchema.set('toObject',{getters:true})
8990

90-
varautoPopulateRole=function(next){
91+
constautoPopulateRole=function(next){
9192
this.populate('role','name description normalized _id')
9293
next()
9394
}
9495

9596
userSchema.pre('findOne',autoPopulateRole).pre('find',autoPopulateRole)
9697

9798
userSchema.pre('save',function(next){
98-
varuser=this
99+
constuser=this
99100

100101
user.username=utils.applyMaxShortTextLength(utils.sanitizeFieldPlainText(user.username.toLowerCase().trim()))
101102
user.email=utils.sanitizeFieldPlainText(user.email.trim())

‎src/socketio/noticeSocket.js‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
* Copyright (c) 2014-2019. All rights reserved.
1313
*/
1414

15-
varwinston=require('winston')
16-
varutils=require('../helpers/utils')
17-
varnoticeSchema=require('../models/notice')
15+
constwinston=require('winston')
16+
constutils=require('../helpers/utils')
17+
constnoticeSchema=require('../models/notice')
1818

19-
varevents={}
19+
constsocketEventConst=require('../socketio/socketEventConsts')
20+
21+
constevents={}
2022

2123
functionregister(socket){
2224
events.onShowNotice(socket)
@@ -26,7 +28,7 @@ function register (socket) {
2628
functioneventLoop(){}
2729

2830
events.onShowNotice=function(socket){
29-
socket.on('setShowNotice',function(noticeId){
31+
socket.on(socketEventConst.NOTICE_SHOW,function({noticeId}){
3032
noticeSchema.getNotice(noticeId,function(err,notice){
3133
if(err)returntrue
3234
notice.activeDate=newDate()
@@ -36,15 +38,15 @@ events.onShowNotice = function (socket) {
3638
returntrue
3739
}
3840

39-
utils.sendToAllConnectedClients(io,'$trudesk:notice:show',notice)
41+
utils.sendToAllConnectedClients(io,socketEventConst.NOTICE_UI_SHOW,notice)
4042
})
4143
})
4244
})
4345
}
4446

4547
events.onClearNotice=function(socket){
46-
socket.on('setClearNotice',function(){
47-
utils.sendToAllConnectedClients(io,'updateClearNotice')
48+
socket.on(socketEventConst.NOTICE_CLEAR,function(){
49+
utils.sendToAllConnectedClients(io,socketEventConst.NOTICE_UI_CLEAR)
4850
})
4951
}
5052

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp