Files

34 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
# Q3 fix: activeTracksRef.current = effective ALWAYS (solo-out stale ref),
# remove _prevActiveTracks restore.
import io
P = r'app/static/js/app.jsx'
s = io.open(P, 'r', encoding='utf-8').read() # universal newline -> \n
old_effective = " const effective = (trackId && patch) ? list.map(t => t.id === trackId ? { ...t, ...patch } : t) : list;"
new_effective = old_effective + "\n // V45.3: LUON ghi ref voi state da patch (mute/solo). Truoc day chi ghi trong\n // nhanh becameAudible roi restore STALE -> solo-out khong co track became\n // audible -> D18b guard (25423) + scheduler (25498) + toggleTrackSoloEvaluate\n // (setTimeout 60ms restart) thay trang thai PRE-solo -> Qin note van fire\n // (tremolo). Render ke tiep tu dong dong bo lai ref.\n activeTracksRef.current = effective;"
assert s.count(old_effective) == 1, 'effective line not unique/found'
s = s.replace(old_effective, new_effective)
old_restore = """ const _prevActiveTracks = activeTracksRef.current;
activeTracksRef.current = effective;
try {
startTrackPlayback(resumeAt);
} finally {
activeTracksRef.current = _prevActiveTracks;
}"""
new_restore = """ // V45.3: ref da = effective (dau ham) -> restart thay trang thai moi ngay.
startTrackPlayback(resumeAt);"""
assert s.count(old_restore) == 1, 'restore block not unique/found'
s = s.replace(old_restore, new_restore)
out = io.open(P, 'w', encoding='utf-8', newline='\r\n')
out.write(s)
out.close()
# verify CRLF
raw = open(P, 'rb').read()
print('CRLF count:', raw.count(b'\r\n'), 'LF only:', raw.count(b'\n') - raw.count(b'\r\n'))
print('patch ok')