Skip to content

Commit ae0f6a8

Browse files
authored
Merge pull request #2183 from error414/fix-copy-layout-electron
fix copy OSD layout for electron
2 parents baa2854 + 26e45d1 commit ae0f6a8

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tabs/osd.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -3213,22 +3213,26 @@ OSD.GUI.updateAll = function() {
32133213
}
32143214
});
32153215

3216-
paste.on('click', function() {
3216+
paste.on('click', async function() {
32173217
if(layout_clipboard.filled == true){
32183218

32193219
var oldLayout = JSON.parse(JSON.stringify(OSD.data.layouts[OSD.data.selected_layout]))
32203220
OSD.data.layouts[OSD.data.selected_layout] = JSON.parse(JSON.stringify(layout_clipboard.layout));
32213221
layouts.trigger('change');
3222-
OSD.data.layouts[OSD.data.selected_layout].forEach(function(item, index){
3222+
3223+
for(var index in OSD.data.layouts[OSD.data.selected_layout])
3224+
{
3225+
var item = OSD.data.layouts[OSD.data.selected_layout][index];
32233226
if(!(item.isVisible === false && oldLayout[index].isVisible === false) && (oldLayout[index].x !== item.x || oldLayout[index].y !== item.y || oldLayout[index].position !== item.position || oldLayout[index].isVisible !== item.isVisible)){
3224-
OSD.saveItem({id: index});
3227+
await OSD.saveItem({id: index});
32253228
}
3226-
});
3229+
}
3230+
32273231
GUI.log(i18n.getMessage('osdLayoutPasteFromClipboard'));
32283232
}
32293233
});
32303234

3231-
clear.on('click', function() {
3235+
clear.on('click', async function() {
32323236
var oldLayout = JSON.parse(JSON.stringify(OSD.data.layouts[OSD.data.selected_layout]));
32333237

32343238
var clearedLayout = [];
@@ -3240,12 +3244,15 @@ OSD.GUI.updateAll = function() {
32403244

32413245
OSD.data.layouts[OSD.data.selected_layout] = clearedLayout;
32423246
layouts.trigger('change');
3243-
OSD.data.layouts[OSD.data.selected_layout].forEach(function(item, index){
3247+
3248+
for(var index in OSD.data.layouts[OSD.data.selected_layout]) {
3249+
var item = OSD.data.layouts[OSD.data.selected_layout][index];
32443250
if(oldLayout[index].isVisible === true){
3245-
OSD.saveItem({id: index});
3251+
await OSD.saveItem({id: index});
32463252
}
3247-
});
3248-
GUI.log(chrome.i18n.getMessage('osdClearLayout'));
3253+
}
3254+
3255+
GUI.log(i18n.getMessage('osdClearLayout'));
32493256
});
32503257

32513258

0 commit comments

Comments
 (0)