提案 #1255 » 1255-2.patch
core/plugin/current_world/current_world.rb | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 | |
3 | 3 |
Plugin.create(:current_world) do |
4 |
UserConfig[:last_world_slug] ||= nil |
|
5 |
UserConfig[:restore_last_world] ||= true |
|
6 | ||
4 | 7 |
# 現在選択されているアカウントに対応するModelを返すフィルタ。 |
5 | 8 |
filter_world_current do |result| |
6 | 9 |
if result |
... | ... | |
16 | 19 |
if self.current_world != new |
17 | 20 |
self.current_world = new |
18 | 21 |
Plugin.call(:primary_service_changed, current_world) |
22 |
UserConfig[:last_world_slug] = current_world.slug |
|
19 | 23 |
end |
20 | 24 |
rescue RuntimeError => err |
21 | 25 |
error err |
... | ... | |
43 | 47 |
@current = new |
44 | 48 |
end |
45 | 49 | |
50 |
def restore_last_world |
|
51 |
slug = UserConfig[:last_world_slug] |
|
52 |
return unless slug |
|
53 |
world = Enumerator.new { |y| Plugin.filtering :worlds, y } |
|
54 |
.find { |w| w.slug == slug } |
|
55 |
Plugin.call(:world_change_current, world) if world |
|
56 |
end |
|
57 | ||
58 |
restore_last_world if UserConfig[:restore_last_world] |
|
46 | 59 |
end |
- « Previous
- 1
- 2
- Next »