Buttons to merge streams

Recently I’ve found myself merging a lot of streams tiddlers and needed some fast and efficient ways of doing it without the aid of the Fusion plugin. Thought I’d post my results here in case they’re ever useful to anyone.

Single Tiddler Button

<$button>
<$action-setfield
  $tiddler=<<currentTiddler>>
  text={{{ [<currentTiddler>get-stream-nodes[]] :map[get[text]] +[join[<br><br>]] }}}
/>
<$list filter="[<currentTiddler>get-stream-nodes[]] -[<currentTiddler>]" variable="streamChild">
<$action-deletetiddler $tiddler=<<streamChild>>/>
</$list>
<$action-deletefield $tiddler=<<currentTiddler>> $field="stream-list"/>
Merge This Stream
</$button>

All stream tiddlers in a wiki

<$button>
<$list filter="[all[tiddlers]has[stream-list]!has[parent]]" variable="streamRoot">
<$action-setfield
  $tiddler=<<streamRoot>>
  text={{{ [<streamRoot>get-stream-nodes[]] :map[get[text]] +[join[<br><br>]] }}}
/>
<$list filter="[<streamRoot>get-stream-nodes[]] -[<streamRoot>]" variable="streamChild">
<$action-deletetiddler $tiddler=<<streamChild>>/>
</$list>
<$action-deletefield $tiddler=<<streamRoot>> $field="stream-list"/>
</$list>
Merge All Streams
</$button>

Toolbar button (Appears just in the toolbar of Streams tiddlers)
Tagged $:/tags/ViewToolbar

<$list filter="[<currentTiddler>has[stream-list]]" variable="ignore">
<$button class="tc-btn-invisible">
<$action-setfield
  $tiddler=<<currentTiddler>>
  text={{{ [<currentTiddler>get-stream-nodes[]] :map[get[text]] +[join[<br><br>]] }}}
/>
<$list filter="[<currentTiddler>get-stream-nodes[]] -[<currentTiddler>]" variable="streamChild">
<$action-deletetiddler $tiddler=<<streamChild>>/>
</$list>
<$action-deletefield $tiddler=<<currentTiddler>> $field="stream-list"/>
{{$:/core/images/chevron-down}}
</$button>
</$list>
3 Likes

@well-noted

This is really cool! Do you think your toolbar button could be adapted to copy the merged stream-nodes text to the clipboard instead of merging into a new tiddler? That’s the feature I use most in streams-fusion.

Just let me know, thanks!

-Tyler

I don’t see why not :slight_smile: Anyone else wanna take a crack at it is welcome, if I don’t get to it first.

1 Like

Try this @Xyvir and let me know if it works for you as expected :slight_smile:

<$list filter="[<currentTiddler>has[stream-list]]" variable="ignore">
<$button class="tc-btn-invisible">
<$action-sendmessage
  $message="tm-copy-to-clipboard"
  $param={{{ [<currentTiddler>get-stream-nodes[]] :map[get[text]] +[join[

]] }}}
/>
{{$:/core/images/copy-clipboard}}
</$button>
</$list>

1 Like

This is great! It’s about the only feature I use from streams-fusion so I don’t need the whole plugin if I can use a little snippet like this to accomplish basically the same thing.

The only other thing is I wish it preserved the implied streams indentation, right now it just copies everything ‘flat’. Though this might be nontrivial? Anyway thanks for whipping this up it’s super helpful as it is!

Understood about implied streams indentation, it’s an annoyance for me too – I’m working on a WYSIWYG outliner/editor that uses four spaces to indicate one indent :slight_smile:

1 Like

Neat! Do you a demo up yet or anything? I’d love to check it out when it is ready.

1 Like

It’s getting close to ready :slight_smile: Here’s a preview https://tiddlymesh-canvas.tiddlyhost.com

1 Like