~ghost08/photon

1

Re: ~ghost08/photon#6: Photon

Details
Message ID
<CJGJ9ABNJ3F9.38QAVWF36CQXM@rek2system>
DKIM signature
missing
Download raw message
Awesome,
I am trying to modify the current script that marks readed cards with
purple.
and I was able to delete the card that was already seen, when closing
and opening it will not be there.. the issue I have is to do it with out
having to do so as well.. but I get it always to crash, not very
familiar with LUA.

This below works.
```
photon = require("photon")
localStorage = require("localStorage")

photon.events.subscribe(
	photon.events.FeedsDownloaded,
	function(e)
		for i = 1, photon.cards:len(), 1 do
			local card = photon.cards:get(i)
			local link = card:link()
			local item = localStorage.getItem(link)
			if item ~= nil then
				photon.visibleCards:del(i)
				--card:foreground(photon.ColorPurple)
			end
		end
	end
)
```
but when I modify other function, is when it crash and I am sure is because of lack of LUA knowladge
```
function opened(e)
	if localStorage.getItem(e:link()) ~= nil then
		return
	end
	localStorage.setItem(e:link(), "")
	photon.selectedCard:del(card())
	--e:card():foreground(photon.ColorRed)
end
```

Any tips to get this working?

Thanks
ReK2

Re: ~ghost08/photon#6: Photon

Details
Message ID
<CJJ44DF8RVP6.NEZKYWSYQZ80@micro-pc>
In-Reply-To
<CJGJ9ABNJ3F9.38QAVWF36CQXM@rek2system> (view parent)
DKIM signature
missing
Download raw message
I've made a new plugin that deletes the already visited cards

https://git.sr.ht/~ghost08/photon/tree/master/item/plugins/delete_readed.lua

The trick is in that you cannot delete the cards while you loop trough
the array. So I've just edited the `readed.lua` plugin so that it
collects the indices and then deletes them in another loop.
Reply to thread Export thread (mbox)