@@ -72,6 +72,8 @@ MultiBot:SetScript("OnUpdate", function(_, pElapsed)
7272
7373local MAINBAR_MIGRATION_VERSION = 1
7474local LAYOUT_MIGRATION_VERSION = 1
75+ local MAINBAR_MIGRATION_KEY = " mainBarStateVersion"
76+ local LAYOUT_MIGRATION_KEY = " layoutStateVersion"
7577
7678local MAINBAR_STATE_KEYS = {
7779 " AttackButton" ,
@@ -105,31 +107,6 @@ local function getLegacyStateStore()
105107 return MultiBotSave
106108end
107109
108- local function getProfileMigrationStore ()
109- local profile = MultiBot .db and MultiBot .db .profile
110- if not profile then return nil end
111- profile .migrations = profile .migrations or {}
112- return profile .migrations
113- end
114-
115- local function shouldSyncLegacyState (versionKey , targetVersion )
116- local migrations = getProfileMigrationStore ()
117- if not migrations then
118- return true
119- end
120-
121- local version = migrations [versionKey ]
122- return type (version ) ~= " number" or version < targetVersion
123- end
124-
125- local function markLegacyStateMigrated (versionKey , targetVersion )
126- local migrations = getProfileMigrationStore ()
127- if not migrations then
128- return
129- end
130- migrations [versionKey ] = targetVersion
131- end
132-
133110local function getMainBarProfileStore ()
134111 local profile = MultiBot .db and MultiBot .db .profile
135112 if not profile then return nil end
@@ -139,7 +116,7 @@ local function getMainBarProfileStore()
139116end
140117
141118local function migrateLegacyMainBarStateIfNeeded (profileStore )
142- if not profileStore or not shouldSyncLegacyState ( " mainBarStateVersion " , MAINBAR_MIGRATION_VERSION ) then
119+ if not profileStore or not MultiBot . ShouldSyncLegacyState ( MAINBAR_MIGRATION_KEY , MAINBAR_MIGRATION_VERSION ) then
143120 return
144121 end
145122
@@ -150,7 +127,7 @@ local function migrateLegacyMainBarStateIfNeeded(profileStore)
150127 end
151128 end
152129
153- markLegacyStateMigrated ( " mainBarStateVersion " , MAINBAR_MIGRATION_VERSION )
130+ MultiBot . MarkLegacyStateMigrated ( MAINBAR_MIGRATION_KEY , MAINBAR_MIGRATION_VERSION )
154131end
155132
156133local function getSavedMainBarValue (key )
@@ -161,7 +138,7 @@ local function getSavedMainBarValue(key)
161138 end
162139
163140 local value = profileStore and profileStore [key ] or legacy [key ]
164- if profileStore and value == nil and shouldSyncLegacyState ( " mainBarStateVersion " , MAINBAR_MIGRATION_VERSION ) then
141+ if profileStore and value == nil and MultiBot . ShouldSyncLegacyState ( MAINBAR_MIGRATION_KEY , MAINBAR_MIGRATION_VERSION ) then
165142 value = legacy [key ]
166143 if value ~= nil then
167144 profileStore [key ] = value
@@ -177,7 +154,7 @@ local function setSavedMainBarValue(key, value)
177154 profileStore [key ] = value
178155 end
179156
180- if shouldSyncLegacyState ( " mainBarStateVersion " , MAINBAR_MIGRATION_VERSION ) then
157+ if MultiBot . ShouldSyncLegacyState ( MAINBAR_MIGRATION_KEY , MAINBAR_MIGRATION_VERSION ) then
181158 local legacy = getLegacyStateStore ()
182159 legacy [key ] = value
183160 end
@@ -193,7 +170,7 @@ local function getLayoutProfileStore()
193170end
194171
195172local function migrateLegacyLayoutStateIfNeeded (profileStore )
196- if not profileStore or not shouldSyncLegacyState ( " layoutStateVersion " , LAYOUT_MIGRATION_VERSION ) then
173+ if not profileStore or not MultiBot . ShouldSyncLegacyState ( LAYOUT_MIGRATION_KEY , LAYOUT_MIGRATION_VERSION ) then
197174 return
198175 end
199176
@@ -204,7 +181,7 @@ local function migrateLegacyLayoutStateIfNeeded(profileStore)
204181 end
205182 end
206183
207- markLegacyStateMigrated ( " layoutStateVersion " , LAYOUT_MIGRATION_VERSION )
184+ MultiBot . MarkLegacyStateMigrated ( LAYOUT_MIGRATION_KEY , LAYOUT_MIGRATION_VERSION )
208185end
209186
210187local function getSavedLayoutValue (key )
@@ -215,7 +192,7 @@ local function getSavedLayoutValue(key)
215192 end
216193
217194 local value = profileStore and profileStore [key ] or legacy [key ]
218- if profileStore and value == nil and shouldSyncLegacyState ( " layoutStateVersion " , LAYOUT_MIGRATION_VERSION ) then
195+ if profileStore and value == nil and MultiBot . ShouldSyncLegacyState ( LAYOUT_MIGRATION_KEY , LAYOUT_MIGRATION_VERSION ) then
219196 value = legacy [key ]
220197 if value ~= nil then
221198 profileStore [key ] = value
@@ -231,7 +208,7 @@ local function setSavedLayoutValue(key, value)
231208 profileStore [key ] = value
232209 end
233210
234- if shouldSyncLegacyState ( " layoutStateVersion " , LAYOUT_MIGRATION_VERSION ) then
211+ if MultiBot . ShouldSyncLegacyState ( LAYOUT_MIGRATION_KEY , LAYOUT_MIGRATION_VERSION ) then
235212 local legacy = getLegacyStateStore ()
236213 legacy [key ] = value
237214 end
0 commit comments