mirror of
https://github.com/wassname/talk.git
synced 2026-07-06 03:09:49 +08:00
wip :0
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export const ENABLE_PLUGINS_DEBUG = 'ENABLE_PLUGINS_DEBUG';
|
||||
export const DISABLE_PLUGINS_DEBUG = 'DISABLE_PLUGINS_DEBUG';
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as actions from '../constants/debug';
|
||||
|
||||
const initialState = {
|
||||
plugins: false,
|
||||
};
|
||||
|
||||
export default function DEBUG(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case actions.ENABLE_PLUGINS_DEBUG:
|
||||
return {
|
||||
plugins: true,
|
||||
};
|
||||
case actions.DISABLE_PLUGINS_DEBUG:
|
||||
return {
|
||||
plugins: false,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import embed from './embed';
|
||||
import configure from './configure';
|
||||
import stream from './stream';
|
||||
import profile from './profile';
|
||||
import debug from './debug';
|
||||
|
||||
export default {
|
||||
login,
|
||||
@@ -10,4 +11,5 @@ export default {
|
||||
configure,
|
||||
stream,
|
||||
profile,
|
||||
debug,
|
||||
};
|
||||
|
||||
@@ -161,6 +161,10 @@ export default class Stream {
|
||||
);
|
||||
}
|
||||
|
||||
dispatch(action) {
|
||||
this.pym.sendMessage('dispatch', action);
|
||||
}
|
||||
|
||||
login(token) {
|
||||
this.pym.sendMessage('login', token);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ export default class StreamInterface {
|
||||
this._stream = stream;
|
||||
}
|
||||
|
||||
dispatch(action) {
|
||||
return this._stream.dispatch(action);
|
||||
}
|
||||
|
||||
on(eventName, callback) {
|
||||
return this._stream.emitter.on(eventName, callback);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class Slot extends React.Component {
|
||||
defaultComponent: DefaultComponent,
|
||||
queryData,
|
||||
fill,
|
||||
debugPlugins,
|
||||
} = this.props;
|
||||
const { plugins } = this.context;
|
||||
let children = this.getChildren();
|
||||
@@ -103,7 +104,7 @@ class Slot extends React.Component {
|
||||
className={cn(
|
||||
{
|
||||
[styles.inline]: inline,
|
||||
[styles.debug]: pluginsConfig.debug,
|
||||
[styles.debug]: debugPlugins || pluginsConfig.debug,
|
||||
},
|
||||
className,
|
||||
`talk-slot-${kebabCase(fill)}`
|
||||
@@ -156,6 +157,7 @@ Slot.propTypes = {
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
reduxState: state,
|
||||
debugPlugins: state.debug.plugins,
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, null)(Slot);
|
||||
|
||||
@@ -215,6 +215,12 @@ export async function createContext({
|
||||
pym.onMessage('logout', () => {
|
||||
store.dispatch(logout());
|
||||
});
|
||||
|
||||
pym.onMessage('dispatch', action => {
|
||||
store.dispatch({
|
||||
type: action,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const preInitList = [];
|
||||
|
||||
Reference in New Issue
Block a user