提案 #1255 » 1255-2.patch
| core/plugin/current_world/current_world.rb | ||
|---|---|---|
|
# -*- coding: utf-8 -*-
|
||
|
Plugin.create(:current_world) do
|
||
|
UserConfig[:last_world_slug] ||= nil
|
||
|
UserConfig[:restore_last_world] ||= true
|
||
|
# 現在選択されているアカウントに対応するModelを返すフィルタ。
|
||
|
filter_world_current do |result|
|
||
|
if result
|
||
| ... | ... | |
|
if self.current_world != new
|
||
|
self.current_world = new
|
||
|
Plugin.call(:primary_service_changed, current_world)
|
||
|
UserConfig[:last_world_slug] = current_world.slug
|
||
|
end
|
||
|
rescue RuntimeError => err
|
||
|
error err
|
||
| ... | ... | |
|
@current = new
|
||
|
end
|
||
|
def restore_last_world
|
||
|
slug = UserConfig[:last_world_slug]
|
||
|
return unless slug
|
||
|
world = Enumerator.new { |y| Plugin.filtering :worlds, y }
|
||
|
.find { |w| w.slug == slug }
|
||
|
Plugin.call(:world_change_current, world) if world
|
||
|
end
|
||
|
restore_last_world if UserConfig[:restore_last_world]
|
||
|
end
|
||