@@ -37,7 +37,7 @@ import {
3737 getDeeperType ,
3838} from './Playground/DocExplorer/utils'
3939import { setStacks } from '../actions/graphiql-docs'
40- import { isEqual } from 'lodash'
40+ import { isEqual , mapValues } from 'lodash'
4141import Share from './Share'
4242
4343export type Theme = 'dark' | 'light'
@@ -1237,14 +1237,45 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
12371237 }
12381238
12391239 private toggleShareHistory = ( ) => {
1240- this . setState ( state => ( { ...state , shareHisotry : ! state . shareHistory } ) )
1240+ this . setState ( state => ( { ...state , shareHistory : ! state . shareHistory } ) )
12411241 }
12421242
12431243 private share = ( ) => {
12441244 this . saveSessions ( )
12451245 this . saveHistory ( )
12461246 this . storage . saveProject ( )
1247- this . props . share ( this . storage . project )
1247+ let sharingProject : any = this . storage . project
1248+
1249+ if ( ! this . state . shareHttpHeaders ) {
1250+ sharingProject = {
1251+ ...sharingProject ,
1252+ sessions : mapValues ( sharingProject . sessions , ( session : Session ) => {
1253+ session . headers = [ ]
1254+ return session
1255+ } ) ,
1256+ }
1257+ }
1258+
1259+ if ( ! this . state . shareAllTabs ) {
1260+ const currentSession : Session = this . state . sessions [
1261+ this . state . selectedSessionIndex
1262+ ]
1263+ sharingProject = {
1264+ ...sharingProject ,
1265+ sessions : {
1266+ [ currentSession . id ] : currentSession ,
1267+ } ,
1268+ }
1269+ }
1270+
1271+ if ( ! this . state . shareHistory ) {
1272+ sharingProject = {
1273+ ...sharingProject ,
1274+ history : [ ] ,
1275+ }
1276+ }
1277+
1278+ this . props . share ( sharingProject )
12481279 this . setState ( { changed : false } )
12491280 }
12501281}
0 commit comments