Skip to content

Commit b7bc949

Browse files
committed
fixed empty snapshots bug
1 parent b2c52b2 commit b7bc949

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/app/reducers/mainReducer.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function mainReducer(state, action) {
1313
if (snapshots.length > 0 && sliderIndex > 0) {
1414
const newIndex = sliderIndex - 1;
1515

16-
port.postMessage({ action: 'jumpToSnap', payload: snapshots[newIndex] });
16+
port.postMessage({ action: 'jumpToSnap', payload: snapshots[newIndex], tabId: currentTab });
1717
clearInterval(intervalId);
1818

1919
tabs[currentTab].sliderIndex = newIndex;
@@ -30,7 +30,7 @@ export default function mainReducer(state, action) {
3030
if (sliderIndex < snapshots.length - 1) {
3131
const newIndex = sliderIndex + 1;
3232

33-
port.postMessage({ action: 'jumpToSnap', payload: snapshots[newIndex] });
33+
port.postMessage({ action: 'jumpToSnap', payload: snapshots[newIndex], tabId: currentTab });
3434

3535
tabs[currentTab].sliderIndex = newIndex;
3636

@@ -58,16 +58,16 @@ export default function mainReducer(state, action) {
5858
};
5959
}
6060
case types.CHANGE_SLIDER: {
61-
port.postMessage({ action: 'jumpToSnap', payload: snapshots[action.payload] });
61+
port.postMessage({ action: 'jumpToSnap', payload: snapshots[action.payload], tabId: currentTab });
6262
tabs[currentTab].sliderIndex = action.payload;
6363
return { ...state, tabs };
6464
}
6565
case types.EMPTY: {
66-
port.postMessage({ action: 'emptySnap', tabd: currentTab });
66+
port.postMessage({ action: 'emptySnap', tabId: currentTab });
6767
tabs[currentTab].sliderIndex = 0;
6868
tabs[currentTab].viewIndex = -1;
6969
tabs[currentTab].playing = false;
70-
tabs[currentTab].snapshots = [];
70+
tabs[currentTab].snapshots.splice(1);
7171
return {
7272
...state,
7373
tabs,
@@ -77,7 +77,7 @@ export default function mainReducer(state, action) {
7777
return { ...state, port: action.payload };
7878
}
7979
case types.IMPORT: {
80-
port.postMessage({ action: 'import', payload: action.payload });
80+
port.postMessage({ action: 'import', payload: action.payload, tabId: currentTab });
8181
tabs[currentTab].snapshots = action.payload;
8282
return {
8383
...state,
@@ -100,7 +100,7 @@ export default function mainReducer(state, action) {
100100
break;
101101
default:
102102
}
103-
port.postMessage({ action: actionText, payload: newMode });
103+
port.postMessage({ action: actionText, payload: newMode, tabId: currentTab });
104104
return { ...state, tabs };
105105
}
106106
case types.PAUSE: {

src/extension/background.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ chrome.runtime.onConnect.addListener((port) => {
7272
// now we can send messages to specific tabs that we specify
7373
// using tabId
7474
// ---------------------------------------------------------------
75-
// chrome.tabs.sendMessage(tabId, msg);
75+
chrome.tabs.sendMessage(tabId, msg);
7676
// ---------------------------------------------------------------
77-
// find active tab
78-
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
79-
// send message to tab
80-
chrome.tabs.sendMessage(tabs[0].id, msg);
81-
});
8277
});
8378
});
8479

0 commit comments

Comments
 (0)