Skip to content

Commit

Permalink
feat(Path View): ✨ Right click TrailLength button to go backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Apr 29, 2022
1 parent 96ef0cb commit 9f340f0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
44 changes: 25 additions & 19 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15364,21 +15364,21 @@ function add_css$b() {

function get_each_context$7(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[14] = list[i];
child_ctx[15] = list[i];
return child_ctx;
}

function get_each_context_1$4(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[17] = list[i];
child_ctx[19] = i;
child_ctx[18] = list[i];
child_ctx[20] = i;
return child_ctx;
}

// (29:8) {:else}
function create_else_block$3(ctx) {
let each_1_anchor;
let each_value_1 = /*trail*/ ctx[14];
let each_value_1 = /*trail*/ ctx[15];
let each_blocks = [];

for (let i = 0; i < each_value_1.length; i += 1) {
Expand All @@ -15402,7 +15402,7 @@ function create_else_block$3(ctx) {
},
p(ctx, dirty) {
if (dirty & /*trailSeperator, trailsToShow, openOrSwitch, app, hoverPreview, view, getAlt, plugin, dropDendron, settings*/ 378) {
each_value_1 = /*trail*/ ctx[14];
each_value_1 = /*trail*/ ctx[15];
let i;

for (i = 0; i < each_value_1.length; i += 1) {
Expand Down Expand Up @@ -15474,22 +15474,22 @@ function create_if_block_2$3(ctx) {
// (30:10) {#each trail as crumb, i}
function create_each_block_1$4(ctx) {
let span;
let t0_value = (getAlt(/*crumb*/ ctx[17], /*plugin*/ ctx[1]) ?? dropDendron(/*crumb*/ ctx[17], /*settings*/ ctx[4])) + "";
let t0_value = (getAlt(/*crumb*/ ctx[18], /*plugin*/ ctx[1]) ?? dropDendron(/*crumb*/ ctx[18], /*settings*/ ctx[4])) + "";
let t0;
let t1;
let if_block_anchor;
let mounted;
let dispose;

function click_handler(...args) {
return /*click_handler*/ ctx[10](/*crumb*/ ctx[17], ...args);
return /*click_handler*/ ctx[10](/*crumb*/ ctx[18], ...args);
}

function mouseover_handler(...args) {
return /*mouseover_handler*/ ctx[11](/*crumb*/ ctx[17], ...args);
return /*mouseover_handler*/ ctx[11](/*crumb*/ ctx[18], ...args);
}

let if_block = /*i*/ ctx[19] < /*trail*/ ctx[14].length - 1 && create_if_block_2$3(ctx);
let if_block = /*i*/ ctx[20] < /*trail*/ ctx[15].length - 1 && create_if_block_2$3(ctx);

return {
c() {
Expand Down Expand Up @@ -15518,9 +15518,9 @@ function create_each_block_1$4(ctx) {
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (dirty & /*trailsToShow, plugin*/ 10 && t0_value !== (t0_value = (getAlt(/*crumb*/ ctx[17], /*plugin*/ ctx[1]) ?? dropDendron(/*crumb*/ ctx[17], /*settings*/ ctx[4])) + "")) set_data(t0, t0_value);
if (dirty & /*trailsToShow, plugin*/ 10 && t0_value !== (t0_value = (getAlt(/*crumb*/ ctx[18], /*plugin*/ ctx[1]) ?? dropDendron(/*crumb*/ ctx[18], /*settings*/ ctx[4])) + "")) set_data(t0, t0_value);

if (/*i*/ ctx[19] < /*trail*/ ctx[14].length - 1) {
if (/*i*/ ctx[20] < /*trail*/ ctx[15].length - 1) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
Expand Down Expand Up @@ -15550,7 +15550,7 @@ function create_each_block$7(ctx) {
let t;

function select_block_type(ctx, dirty) {
if (!/*trail*/ ctx[14].length) return create_if_block_1$4;
if (!/*trail*/ ctx[15].length) return create_if_block_1$4;
return create_else_block$3;
}

Expand Down Expand Up @@ -15609,7 +15609,11 @@ function create_if_block$7(ctx) {
append(button, t);

if (!mounted) {
dispose = listen(button, "click", /*click_handler_1*/ ctx[12]);
dispose = [
listen(button, "click", /*click_handler_1*/ ctx[12]),
listen(button, "contextmenu", /*contextmenu_handler*/ ctx[13])
];

mounted = true;
}
},
Expand All @@ -15619,7 +15623,7 @@ function create_if_block$7(ctx) {
d(detaching) {
if (detaching) detach(div);
mounted = false;
dispose();
run_all(dispose);
}
};
}
Expand Down Expand Up @@ -15718,14 +15722,15 @@ function instance$k($$self, $$props, $$invalidate) {
const { view } = app.workspace.activeLeaf;
let { showAll, noPathMessage, trailSeperator } = settings;

function getNextTrailLength(curr) {
return TRAIL_LENGTHS[(TRAIL_LENGTHS.indexOf(curr) + 1) % TRAIL_LENGTHS.length];
function getTrailLength(curr, offset = 1) {
return TRAIL_LENGTHS[(TRAIL_LENGTHS.indexOf(curr) + offset) % TRAIL_LENGTHS.length];
}

let trail_length = showAll;
const click_handler = async (crumb, e) => await openOrSwitch(app, crumb, e);
const mouseover_handler = (crumb, e) => hoverPreview(e, view, crumb);
const click_handler_1 = () => $$invalidate(2, trail_length = getNextTrailLength(trail_length));
const click_handler_1 = () => $$invalidate(2, trail_length = getTrailLength(trail_length));
const contextmenu_handler = () => $$invalidate(2, trail_length = getTrailLength(trail_length, -1));

$$self.$$set = $$props => {
if ("sortedTrails" in $$props) $$invalidate(0, sortedTrails = $$props.sortedTrails);
Expand All @@ -15752,10 +15757,11 @@ function instance$k($$self, $$props, $$invalidate) {
view,
noPathMessage,
trailSeperator,
getNextTrailLength,
getTrailLength,
click_handler,
mouseover_handler,
click_handler_1
click_handler_1,
contextmenu_handler
];
}

Expand Down
7 changes: 4 additions & 3 deletions src/Components/TrailPath.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
const { view } = app.workspace.activeLeaf;
let { showAll, noPathMessage, trailSeperator } = settings;
function getNextTrailLength(curr: string) {
function getTrailLength(curr: string, offset: number = 1) {
return TRAIL_LENGTHS[
(TRAIL_LENGTHS.indexOf(curr) + 1) % TRAIL_LENGTHS.length
(TRAIL_LENGTHS.indexOf(curr) + offset) % TRAIL_LENGTHS.length
];
}
Expand Down Expand Up @@ -59,7 +59,8 @@
<div>
<button
class="button-div"
on:click={() => (trail_length = getNextTrailLength(trail_length))}
on:click={() => (trail_length = getTrailLength(trail_length))}
on:contextmenu={() => (trail_length = getTrailLength(trail_length, -1))}
>
{trail_length}
</button>
Expand Down

0 comments on commit 9f340f0

Please sign in to comment.